For a LiPoly-accu driven device using the Olimexino-32u4 board (includes LiPoly charger) I want to measure the accu state (voltage?). How to measure the voltage without the need for a current increasing voltage divider?
Asked
Active
Viewed 361 times
1
-
Just use some very high value resistors, and maybe a capacitor to ensure a more constant voltage during measurement. Otherwise you need some way to switch on the power to the voltage-divider, like e.g. using a transistor. – Gerben Aug 06 '14 at 14:22
-
1High value resistors are fine if the battery is sized to run the device in active mode all the time. But if the device goes into a micropower sleep mode, they could end up drawing more current than budgeted for with a small lipo cell. For ideas on the lowest power solutions, it might be worth asking this as a generic question on electronics.stackexchange (reference ATmega32u4 rather than Arduino/Olimexino). – Chris Stratton Aug 06 '14 at 17:08
-
A typical approach is to measure the battery voltage with a voltage divider, and to switch off the voltage divider with a MOSFET, when the divider is not needed. [Here's a schematic.](http://electronics.stackexchange.com/a/39429/7036) [By the way, that thread is pretty much a duplicate of this one.] – Nick Alexeev Aug 07 '14 at 16:20
1 Answers
2
You can take advantage of the fact that,
- the ATmega32U4 MCU, like many other Atmel MCUs, has an internal bandgap 2.56V voltage reference.
- You can measure the output of the bandgap voltage reference while using AVcc (analog power supply voltage) or Aref as the reference for the ADC.
- You can now connect Aref (for instance), to the voltage source you want to measure.
For instance, say your battery voltage is 3.05V at a certain moment. If you measure the ADC with the procedure indicated above, you will obtain:
$$ Read Value = \frac{V_{bandgap}}{V_{ref}} 2^{10} = \frac{2.56V}{3.05V} 1024 = 859 $$
In order to obtain the external voltage value you simply have to reverse the above calculation.
The huge benefits of this approach are:
- Saves external components. No need to include a resistor voltage divider.
- Saves power (current consumption).
The drawbacks:
- This will only work for external voltages between the limits of the power supply.
- More involved programming, which may eat up some Flash program memory.
Here you can find the essentially same technique nicely and step by step explained for an ATmega48,
http://www.ikalogic.com/avr-monitor-power-supply-voltage-for-free

jose.angel.jimenez
- 2,052
- 1
- 14
- 23
-
This does seem like it would work if the MCU is run directly off a single LiPo cell (4.2v down to 3.x depending on where you set cutoff), however, there can be issues in varying the supply voltage. This technique does not seem like it would work well with a regulator. – Chris Stratton Aug 07 '14 at 16:14
-
Exactly, it's what I meant by saying that "this will only work for external voltages between the limits of the power supply". Thanks for the remark! – jose.angel.jimenez Aug 07 '14 at 17:07