# Simple measure battery voltage

Hello, This should be a simple question to resolve, I want to measure battery voltage supplying my arduino, the maximum voltage will be 4.5v (3AA alkalines on a nano), As i understand an analogue read from a pin A3 for example, should be able to read the voltage... when i try to read it directly i get 1023, I believe the solution to this involves resistors, but do i need to use a voltage divider to read this, with it being less than 5v?

Gambituk

Yes you need to use a voltage divider e.g. in a ration 1 to 2 e.g. 1MB and 2MB (than there will be only 1.5uA flowing)

The expected voltage is then 2/3 of 4.5V == 3.00 volt. expected reading 1023*2/3 ~ 680 then 680 ==> 4.50 Volt, in code.

float Volts = analogRead(A3) * 4.50 /680;

Hi robtillaart, thanks for the response, so it is always necessary to use a volt dividerâ€¦ Thanks for confirming that. So i will build this and test, I assume (e.g. 1MB and 2MB) == 1Mohm and 2Mohm?

Thanks again.

Think for this problem a voltage divider is a standard solution. Using e.g. a separate voltage sensor seems overkill

Another option is to use the "Secret Voltmeter"

http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/

Good option when powered directly.

however it will not work e.g when you have a 12V battery that powers through the voltage regulator.

You cant power the Arduino from the same voltage you are trying to measure, otherwise you will always get 1023 as the result. You have to use some kind of voltage referance that doesnt change as the battery voltage changes. The ATmega328 has an internal 1.1v voltage referance that you can use . Heres an article on how to do it. http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/