0
\$\begingroup\$

Hi I am building a pocket altitude, temperature and humidity meter with 1.8" TFT display. I have a 1000mah 3.3v Li-ion battery to power the whole system. I also need to display the battery level in percentage in the device. I am confused about which way i need to use. The same battery is powering the device so using voltage divider is not useful because of the ADC reference depends on the battery. Can you guys help me to overcome this?

\$\endgroup\$

marked as duplicate by winny, Finbarr, laptop2d, Warren Hill, Bimpelrekkie Apr 4 at 12:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0
\$\begingroup\$

The same battery is powering the device so using voltage divider is not useful because of the ADC reference depends on the battery.

It sounds like you are running this without a voltage regulator, such that the supply voltage to the MCU varies with the battery.

In that situation, the best course of action is typically to momentarily turn on the ATmega's internal bandgap reference, measure that with the supply-referenced ADC, and then calculate backwards from the data sheet's value of the bandgap reference to the supply voltage that would produce the measured ADC counts. (Some MCU's also get a factory-measured item-unique calibration value stored somewhere you can read at runtime, not sure the ATmega does however)

Then you can turn the internal reference back off to save power. Probably you want to put some thought into what else you can turn off, and sleeping the processor, turning off the display, etc to save power. Or even give it a manual power switch.

\$\endgroup\$
  • \$\begingroup\$ maybe i can use a linear voltage regulator, in that case what you prefer? \$\endgroup\$ – Suhail Jr. Apr 2 at 15:43
  • \$\begingroup\$ If all of your parts can tolerate the variation in battery voltage, then a linear regulator will only waste power. There care cases where a carefully chosen switching regulator can help, but that seems likely more complex than your project. \$\endgroup\$ – Chris Stratton Apr 2 at 15:46
  • \$\begingroup\$ can you please help me to choose which is the best way to do this. You are pointing out that the voltage regulator is not needed. So if i do without the voltage regulator, which is the best way to do it. The voltage divider do the job? \$\endgroup\$ – Suhail Jr. Apr 2 at 15:49
  • \$\begingroup\$ This purpose of this site is to answer specific questions, not to "help you chose". With the technique described in this answer, you do not need a voltage divider, there is not no circuitry to the external MCU involved at all, other than ideally filtering and bypassing the analog supply. Designing for decent service life on battery power is a quite complex problem going far beyond what you are presently contemplating however. \$\endgroup\$ – Chris Stratton Apr 2 at 16:02
  • \$\begingroup\$ @ChrisStratton Somehow I have managed to read your answer and completely overlook the main point of your answer, which was to use the internal reference. Oops. \$\endgroup\$ – Hearth Apr 2 at 16:04

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