# Reading power state on Arduino Uno

Good Day,

Is there a way that one could read the power state of an Arduino Uno.
I want my remote unit to let me know when its power source, a battery, is running below a certain threshold.
Please let me know if this is possible and how can it be achieved. Only by code, or with added hardware solution?

Thanks for the help.

Just two resistors are needed.

Create a voltage divider and choose resistors that will give you close to but not over 5V output when the battery is full. In the diagram, Vin is from the battery and Vout goes to an analog pin.

If the math is confusing or you're uncertain of your result, post the details of your battery (type/peak voltage) and what you think the resistors should be. Take into account that the total value of both resistors should be ~10K ohms to prevent excessive power waste.

I am not quite sure how the circuit will look.
So, I'll be connecting two resistors in series with the positive of my battery before it reaches the arduino.
Between the resistors i'm breaking out to my analogue input.
The diagram in your link I understand, but to apply it to the arduino I am not so sure how the wiring will work.
What happens to the ground indicated in the diagram, is that the negative of my battery or the ground for my analogue pin?

Hello,

there is a little trap:

• If you use a battery together with a voltage regulator and the battery has a reasonably higher voltage than the regulator output it will work as described above. The voltage regulator will supply a stable reference voltage to the AD converter against which the battery power can be measured.
• If you supply your Arduino directly from the battery without a voltage regulator you'll need to select the AVRs internal voltage reference (1.1V for Atmega328) and also adjust the voltage divider to this reference voltage. If you don't do this you'll measure supply against supply - this will always report "full" no matter what voltage your battery delivers because the reference voltage drops equally to the measured voltage.

RudolfFourie101:
So, I'll be connecting two resistors in series with the positive of my battery before it reaches the arduino.
Between the resistors i'm breaking out to my analogue input.

Correct.

RudolfFourie101:
What happens to the ground indicated in the diagram, is that the negative of my battery or the ground for my analogue pin?

The battery negative and ground on the Arduino (GND) are functionally the same thing. Also, the battery positive and Vin are functionally identical; I mention this because it might make your wiring a little neater -- R1 would be between Vin and your analog pin, and R2 would be between your analog pin and GND.

See attached drawing. This is how I interpert your advice. Is it correct?