Can Arduino Measure its own power supply

Hi. I have a very short and simple question, "Can arduino meausure its own power supply?". I know the analog pins can meausre up to 5v but I am measuring 2 18650 batteries in series which sums up to 7.4v.

I am doing this to measure the voltage of the battery to know how much power it has left to warn me whenever I need to recharge. I might use a voltage divider to step down the voltage and just tweek the code, but I am not sure if this will work. The Arduino IS ALSO POWERED by the SAME POWER SUPPLY (2 18650 batteries). It connects to the Vin pin, so it a bit confusing for me. Looking forward to your reply​:grinning::grinning::grinning:

Hi Gabriel, yes of course - but the best solution depends which arduino you are using.

Of course but that does mean there will be a permanent current drain on the battery. You can make the voltage divider chain very high resisitance since the voltage will not be changing very fast.
You will need to use a voltage reference as a basis for measurement, but the "INTERNAL" reference will be good enough for this application.

1 Like

If you really wanted you could use a FET to switch the voltage divider onto the battery - possibly a good idea anyway to stop the processor being back fed via an analog input when switched off .

Hi, Thank you so much for the reply. So it would work. I don't really know how to use the ARef but I think it plays a significant role in accuracy of the reading which I need since I am measuring my battery life. If ever,may I ask?

Thank you also hammy for that idea, yeah, the arduino powers because the vcc is connected to the analog pin and common ground connection. Now I know it work I need to make sure how to make it accurate.:grinning::grinning::grinning:

Note that the INTERNAL reference on the AVR-based Arduinos has a tolerance of +/-10% which is a lot - you typically have to calibrate it for each Arduino if you want good accuracy. Its repeatability and stability should be OK for this, but the absolute accuracy needs checking.


With a "regular Arduino" the default is the 5V supply. Either directly from your power supply, USB power, or in your case with batteries the output from the onboard 5V regulator. The default through the regulator is pretty good (nothing is "perfect") until your batteries drop to around 5V (or less).

Vin is never used as the reference.

If you wanted to use the Aref pin, you have to supply the reference voltage.

The internal reference is super stable and it's low enough to be reliable even when the Arduino's power supply drops below 5V. But as Mark says, it's not necessarily that accurate so you have to calibrate (adjust your software calculation) if you want it accurate and stable.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.