Go Down

### Topic: Reading power state on Arduino Uno (Read 1 time)previous topic - next topic

#### RudolfFourie101

##### Oct 23, 2012, 07:20 am
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.

#### Chagrin

#1
##### Oct 23, 2012, 11:16 am
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.

#### RudolfFourie101

#2
##### Oct 23, 2012, 08:50 pm

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?

#### Christian_K

#3
##### Oct 23, 2012, 09:37 pm
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.

Arduino based CNC Controller / CAM Software: www.estlcam.com

#### Chagrin

#4
##### Oct 23, 2012, 09:53 pm

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.

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.

#### RudolfFourie101

#5
##### Oct 24, 2012, 08:39 am
See attached drawing. This is how I interpert your advice. Is it correct?

#### Chagrin

#6
##### Oct 24, 2012, 04:41 pm
Yes, that's correct.

When R1 = R2 like you have here the voltage at A1 will be exactly half the battery voltage. Ensure that your battery is not over 10V so that you're not sending a voltage greater than 5V to an Arduino pin. It also requires that the battery is over ~7V and the onboard regulator is providing a stable 5V voltage to power the board so a stable reference is available.

Go Up

Please enter a valid email to subscribe