13
\$\begingroup\$

I'm working on a little sensor platform that runs off of batteries. I'd love to be able to trigger an alert when the voltage gets too low. The problem is that anything I use to measure that voltage will be powered by that same voltage source. For what it's worth, I'm running Arduino Pro-mini clones (3.3 V) off of 4xAA rechargeables (4.8 V to start with, but the system seems to work right down to 2 V or so, including the XBee transmitter).

Does anyone have any clever ideas for how to work this? It seems like anything using the analog inputs of the ATmega chip will just be comparing the input voltage with itself. Maybe checking the difference between what comes from the regulator and what comes from the batteries themselves?

\$\endgroup\$

3 Answers 3

10
\$\begingroup\$

Most (all?) AVR's with an ADC have an internal reference voltage which is regulated to a constant value, independent of the voltage supply. Check your datasheet...in the chip I'm using, it's 2.56V. There's a register that picks between comparing against Vcc, AREF, or internal voltage reference. You'd just set it to compare against internal voltage reference, along with using a voltage divider so the maximum voltage is never over 2.56V.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ This, normally a band-gap reference, is one of the most dependable references. They are very stable over a wide temperature range. \$\endgroup\$
    – Kortuk
    Commented Dec 12, 2009 at 22:30
  • \$\begingroup\$ I'm accepting this one because: a) it would allow me to measure the voltage over time and b) might be doable with parts I already have on hand. \$\endgroup\$
    – edebill
    Commented Dec 13, 2009 at 16:02
  • \$\begingroup\$ Instructions: code.google.com/p/tinkerit/wiki/SecretVoltmeter \$\endgroup\$
    – endolith
    Commented Dec 18, 2009 at 3:15
8
\$\begingroup\$

How about a supply supervisor like these Texas ones?

Typically, they monitor the supply, and if it dips below a fixed threshold, an output pin changes state.

You can then connect this to your processor's non-maskable interrupt (or reset) pin.

\$\endgroup\$
4
  • \$\begingroup\$ this is the best answer -- you really need a hardware solution that is a comparator + pulse generator. Measuring voltage with an ADC will not protect you against fast glitches where the supply voltage drops faster than the ADC can measure it. \$\endgroup\$
    – Jason S
    Commented Dec 13, 2009 at 0:30
  • \$\begingroup\$ Are those likely to happen when running on battery? \$\endgroup\$
    – edebill
    Commented Dec 13, 2009 at 16:03
  • \$\begingroup\$ If you have a high-current load, perhaps. \$\endgroup\$
    – Jason S
    Commented Dec 13, 2009 at 16:17
  • \$\begingroup\$ Or if the 3.3V regulator fails! \$\endgroup\$
    – Jason S
    Commented Dec 13, 2009 at 16:17
1
\$\begingroup\$

If your Arduino doesn't support measuring the internal bandgap reference, just use an external reference.

The voltage at the input pin will be held constant by the reference diode, but the value you read will vary depending on the supply, since the ADCs are referenced to the supply. If your reference is 1.0 V, for instance, and your ADC reads 512 out of 1024, then you know the voltage rails are at 2 V.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.