Electronic – Read voltage of the battery that feeds ATmega328p

adcatmega328pldovoltage

I am designing a system focused on the uC ATmega328p and I am feeding it directly with a 3.7V LiPo battery.
I also have a 3.3V LDO feeding several sensors in the system.

My question is the next,
If I want to read the battery voltage [full charge = 4V, discharged = 3V (approx.)]
How should I configure the Vcc, AVcc and AREF pins of ATmega in order to achieve that result?

At the moment I feed the ATmega328p (with internal crystal 8MHz) to the battery voltage and I was thinking of connecting Vcc with AVCC and with the 3.3V that the LDO gives me to connect them to AREF and put the voltage of the battery with a voltage divider to an analog arduino input.

What do you think?
Any better solution?

PS: I would not like to add any extra components to the system.

Thank you.

Best Answer

You can use the internal 1.1V bandgap reference to indirectly measure the voltage on the Vcc pin. This 1.1V reference is built into the chip and can be connected to the ADC by setting the MUX registers correctly.

enter image description here

Full details here...

https://wp.josh.com/2014/11/06/battery-fuel-guage-with-zero-parts-and-zero-pins-on-avr/

Related Topic