Author Topic: Battery Voltage Monitoring  (Read 35048 times)

john k2ox

  • Full Member
  • ***
  • Posts: 111
Battery Voltage Monitoring
« on: January 04, 2014, 10:35:37 PM »
There was mention on the forum about using Moteino to measure its own battery supply voltage.  As already mentioned you can use a two resistor voltage divider and connect it to an analog pin.  The down side of this is that it always drains power from the battery.

Also mentioned was a solution using a transistor to turn the pwr off to the divider.  There was a concern about the number of parts/complexity.  An additional Moteino I/O pin is needed to turn the xstr on/off too.

If you decide you want to monitor your battery and not increase battery drain try this.  Take your two resistor divider and instead of connecting the bottom resistor to ground connect it to a digital I/O pin.

When you want to read the voltage set the pin for output and set it low.  After you get your analog voltage reading, set the pin to input (high impedance).

If you are crafty you can probably use a pin that is now dedicated for a single task.  For instance, say you have an I/O pin dedicated as a chip select line.  Maybe it's for external ram or the data input for a digital temperature chip.  Look at your circuit if you've run short on pins, I bet you'll figure out a way to 'code' multiplex a pin.




Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Battery Voltage Monitoring
« Reply #1 on: January 04, 2014, 10:41:13 PM »
Great idea, I'll consider this mod for the PowerShield!
Perhaps I could add a jumper to allow between direct GND and a digital pin, the default being a pin.

john k2ox

  • Full Member
  • ***
  • Posts: 111
Re: Battery Voltage Monitoring
« Reply #2 on: January 04, 2014, 10:56:27 PM »
Cool.

News Flash.   New thought.

Lets say your current design requires a pull-up resistor for some perpheral device.  For example, if I remember correctly, the DSxxxx one wire devices need a 4700 ohm pull-up.  Instead of using one resistor, use two: whos sum equals 4700 ohms and whos ratio gives the desired voltage division.

This only costs you one additional resistor and an analog pin without an additional digital pin.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Battery Voltage Monitoring
« Reply #3 on: January 05, 2014, 07:57:36 AM »
I was planning on using much higher ohm values like 470k and 1Meg rather than 4.7k.
And my feeling is it might confuse some people if I try to document how that works :)

LazyGlen

  • NewMember
  • *
  • Posts: 48
Re: Battery Voltage Monitoring
« Reply #4 on: January 05, 2014, 10:22:17 AM »
I did a little searching last night and found some references to "Arduino's secret volt meter"
Code and brief here: http://code.google.com/p/tinkerit/wiki/SecretVoltmeter

I've put this into my TemperatureGateway code and it appears to work. I realize that this is measuring on the processor side of the regulator and therefore will only start to sag after the battery voltage drops below what the regulator needs to maintain it's rated output. For pin constrained designs it might be sufficient.

LG

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Battery Voltage Monitoring
« Reply #5 on: January 05, 2014, 07:20:39 PM »
I used the same thing in the voltage monitor for the mailbox notifier. Except I ran the battery voltage through a voltage divider to scale the battery voltage below the 3.3v operating range of the Moteino.

KanyonKris

  • Full Member
  • ***
  • Posts: 113
Re: Battery Voltage Monitoring
« Reply #6 on: January 06, 2014, 06:19:05 PM »
john k2ox,

I had this same idea, to use an IO pin to switch the battery voltage divider on and off. When I discussed it with a co-worker who has done a lot of work with ATmegas he thought the over-voltage protection diodes on the IO might provide a path to ground so it wouldn't really shut off. Have you actually wired up a divider and tested this?

jbeale

  • Jr. Member
  • **
  • Posts: 62
Re: Battery Voltage Monitoring
« Reply #7 on: January 06, 2014, 08:08:23 PM »
If your battery voltage is less than one diode-drop above your CPU operating voltage, switching off the divider using an I/O pin set to "input" will work. If the battery voltage is higher than that, the difference will appear across your divider, just as you say, with the associated current draw. 

If you use a large value resistor like 470k it's not going to be too much battery drain, maybe a few microamps ?  With that high an imput impedance, you might also need to add a capacitor from the ADC to ground to make the ADC reading valid, though.

All this is just theory- I haven't tried it.

john k2ox

  • Full Member
  • ***
  • Posts: 111
Re: Battery Voltage Monitoring
« Reply #8 on: January 06, 2014, 09:40:14 PM »
All true, in this case, you get to choose your compromise.    ;)

SvendP

  • NewMember
  • *
  • Posts: 8
Re: Battery Voltage Monitoring
« Reply #9 on: January 08, 2014, 11:45:46 AM »
Hi there, first post here  :)

I have tested it with 2 x 1Mohm resistors and a 100nF capacitor, work like a charm. I was going for higher values of resistors, but didn't have some.
Have a look at: http://jeelabs.org/2013/05/16/measuring-the-battery-without-draining-it/ there it's done 10Mohm and still works.
 

GaryP

  • NewMember
  • *
  • Posts: 2
Re: Battery Voltage Monitoring
« Reply #10 on: January 08, 2014, 12:15:28 PM »
Just starting out myself. 

I went with the Felix's 10M ohm and 470K with 0.1 uF cap from the Mail Box project and this is working well.   am using 2 or 3 batteries AAA batteries with a mix of rechargeables and alkalines for a test.  I just needed to do a measurement of the battery V and then put a suitable adjustment figure in the Battery Voltage calculation in the sketch.

The sketch I am using is based on the openenergymonitor project's emonTH sensor as it has a rather useful testing function as to whether you have added a DHT 11/22 sensor and/or a DS18B20.  I have tried starting with one form of sensor and adding the other and the change was picked up just fine.  A bit of tweaking with the pin allocations and pointing to plain the plain old Jeelib library was all it needed to get running on a Moteino

http://wiki.openenergymonitor.org/index.php?title=EmonTH#DS18B20_Temperature_Sensor for more info on the emonTH

LazyGlen

  • NewMember
  • *
  • Posts: 48
Re: Battery Voltage Monitoring
« Reply #11 on: January 16, 2014, 09:47:38 AM »
I was at what my Wife and Daughters are now calling my "Arduino-Anonymous meeting" this week where the topic of battery monitoring came up. One of the attendees sent out a link to an analysis he wrote up which details the current drain associated with different methods.

http://fettricks.blogspot.com/2014/01/reducing-voltage-divider-load-to-extend.html

LG

PS - I plugged Moteino's while I was there.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Battery Voltage Monitoring
« Reply #12 on: January 16, 2014, 09:55:53 AM »
Arduino-Anonymous, ha!
Interesting, thanks!

NixHydra

  • NewMember
  • *
  • Posts: 41
Re: Battery Voltage Monitoring
« Reply #13 on: February 14, 2014, 06:36:12 AM »
Guys,

You might find this link of some interest, considering the subject matter of this thread.

http://jeelabs.net/boards/6/topics/2934?page=3

cheers,

john k2ox

  • Full Member
  • ***
  • Posts: 111
Re: Battery Voltage Monitoring
« Reply #14 on: March 15, 2014, 10:56:49 AM »