3
\$\begingroup\$

I want to measure a voltage of a battery (14 to 25 V) with an ATtiny85. The plan is to simply use two reistors. My ATtiny will get a VCC of 5V, so I need to reduce the voltage to 0 to 5 V for the ADC. Based on my calculations, 15k and 3.3k gives the approximate desired range.

enter image description here

USV is a valid ADC Pin on the ATtiny85.

Is it really this simple?

\$\endgroup\$

1 Answer 1

7
\$\begingroup\$

The divider idea works for the A/D input but it does put a continuous load on the battery. Depending on the type of battery this could discharge the battery in time. You may want to consider optimizing the resistor values to be larger to put less load on the battery. Another alternative is to use a small MOSFET to gate power to the voltage divider only at the times when you want the A/D reading to be taken.

\$\endgroup\$
4
  • \$\begingroup\$ Sadly I don't have any pins left for a MOSFET. If I pick a 100MOHM and a 20MOHM resistor, would that be something practical. The load should be extremly low with this high resistance values, right ? \$\endgroup\$ Commented Aug 26, 2020 at 12:45
  • 4
    \$\begingroup\$ You can't change the divider's values at will, because the conversion time depends on the source's impedance. From the datasheet: "The ADC is optimized for analog signals with an output impedance of approximately 10 k or less. If such a source is used, the sampling time will be negligible. If a source with higher impedance is used, the sampling time will depend on how long time the source needs to charge the S/H capacitor, with can vary widely." Going to large resistor values will give the ADC a high-impedance source, and measurements will be slow or inaccurate. \$\endgroup\$
    – ocrdu
    Commented Aug 26, 2020 at 12:57
  • \$\begingroup\$ @ocrdu I just did the calculation with 15K and 2.2K Ohm resistors. My battery has 3Ah@18V, this would drain 1.4mA from the battery, so if I want to keep the battery at 40% it would last ~55 days until it is drained. Since I use a DC DC Converter and the Attiny itself drains the battery too, maybe I can ignore this minor loss. Maybe ? \$\endgroup\$ Commented Aug 26, 2020 at 13:41
  • 1
    \$\begingroup\$ I don't know about your power budget, but it sounds acceptable. If it is a problem, another thing you could try is use larger values for the resistors, and add a small capacitor (say 100nF) from the centre point of the divider to ground, see electronics.stackexchange.com/questions/291841/… and electronics.stackexchange.com/questions/307586/…. Not an uncommon trick 8-). \$\endgroup\$
    – ocrdu
    Commented Aug 26, 2020 at 14:05

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.