Battery Info

Is it possible to get a reading on your batteries using the API?


You mean so that you can remotely monitor battery voltage? Certainly. Just connect the battery positive to one of the A/D inputs, with a suitable resistor divider to get the voltage below 3.3V. Or you could use a Zener/resistor combination to lower the voltage, which would give you a more sensitive reading.

Of course, the downside is that this circuit will consume extra current. So some way of isolating it except when readings are to be taken would be a good addition.

Remember to disable the pullup resistor on the selected A/D line, or it will distort the readings.


Would you be so kind as to maybe post a quick schematic towards your idea of the resistor or resistor/Zener monitor circuits?

I have (3) remote XBee units, and it would be GREAT to be able to monitor their voltage from the receiving module!

For now, I am going to see if my pullup resistors being enabled (PR = 0xFF on the first one I looked at… D’oH!!) can account for earlier TMP36 readings being inaccurate.

THANKS for all your help, especially the cookbook. Quantum leap in my XBee education.

The attached gif file shows the sort of thing I had in mind. The transistor is normally off, so only its leakage current flows through the zener. When you want to read the battery voltage you turn the transistor on and pause for a moment to let the capacitor charge up, then take the reading and turn the transistor off again. The reading is then the ratio of (the zener voltage plus the C-E voltage of the transistor) to the supply voltage, and a little bit of arithmetic should yield the supply voltage. The whole process can be done with remote API commands.

I haven’t tested the circuit - it’s just the expression of the idea. None of the component values is particularly critical, and you could use pretty much any NPN transistor with a low leakage current.

Word on the street is that Digi have their own solution to this, and I’ll bet it’s better than mine. If I can find the approriate schematic on their site I’ll post a link to it.

(Edit) By the way, please forget that I ever mentioned a resistive divider. It wouldn’t work, as I should have realized at the time.

Thanks! I am going to dive into this after work. It is a little above my ‘comfort level’ :slight_smile: but I will educate and understand.