# Independent Arduino by (chargable) battery

Hey guys,

I want to make my Arduino Uno independent. So here is the plan:

In the first step I'd like to read the battery level of a 9V battery which is connected to DC.

I just read this topic How to test battery level with Arduino and I tried to adapt it for my own project. I just want to know if I'm right before testing it under real conditions.

As you can see, I'm using a two resistor voltage divider (10k and 150k).

Am I able to read the voltage by using Wawas Code?

``````/*
0 - ~17volt voltmeter
works with 3.3volt and 5volt Arduinos
uses the internal 1.1volt reference
150k resistor from A1 to +batt
10k resistor from A1 to ground
optional 100n capacitor from A1 to ground for stable readings
*/
float Aref = 1.063; // change this to the actual Aref voltage of ---YOUR--- Arduino, or adjust to get accurate voltage reading (1.000- 1.200)
unsigned int total; // A/D output
float voltage; // converted to volt
//
void setup() {
analogReference(INTERNAL); // use the internal ~1.1volt reference, change (INTERNAL) to (INTERNAL1V1) for a Mega
Serial.begin(9600); // ---set serial monitor to this value---
}
//
void loop() {
for (int x = 0; x < 16; x++) { // 16 analogue readings and 1/16 voltage divider = no additional maths
}
voltage = total * Aref / 1024; // convert readings to volt
// print to serial monitor
Serial.print("The battery is ");
Serial.print(voltage);
Serial.println(" volt");
total = 0; // reset value
``````

Are there other options to read the battery level?

Thank you!

Regards

Marc

Is there no one who can help me?

Regards

Marc

That circuit should work fine, I've used it myself, what kind of options are you thinking about?

Yes it's should be working , but I am wonder how long the battery can be working with the Arduino?

I'm gonna try it when I got my 150k resistor.

In the second step I'd like to connect the battery via Vin pin. But I'm not sure how this would look like. Maybe like that?

Would the code be the same?

In the third step I'd like to read the battery status and let the Arduino beep OR visualize by LEDs when the battery level is low.
In the fourth step I'd like to replace the battery by a chargeable battery and it would be great when the chargeable battery can be charged while it is connected to the Arduino.

But first things first (-> second step)

Regards

Marc

Connecting to the VIN pin is same as connecting to barrel jack.
Do you have a "beeper" or some kind of display yet?

I use a Polulu soft switch and if the voltage is too low, I trigger a shutdown of the switch from the arduino. Also helps if I leave the device on... it shuts itself off after a few minutes.

outsider:
Connecting to the VIN pin is same as connecting to barrel jack.

Not quite. The barrel jack has a polarity protection diode. The voltage on Vin will be lower when the battery is connected to the jack.

Connecting to the VIN pin is same as connecting to barrel jack

So is the second fritzing-sketch right for combining step one and two?

Do you have a "beeper" or some kind of display yet?

I got a piezo speaker and a LCD module, but I'm planning to use the speaker and a LED.
You said you used the same code like i'm planning to use. What was your project?

I use a Polulu soft switch and if the voltage is too low, I trigger a shutdown of the switch from the arduino. Also helps if I leave the device on... it shuts itself off after a few minutes.

That's a nice function! I just need the Arduino to catch somebodies attention (->step three) in order to make the person charge the chargeable battery (-> step four). What did you do to power it off after a few minutes?

The barrel jack has a polarity protection diode

so what exactely does it mean?

Regards

Marc

It means when you plug in a barrel jack with center-negative polarity then it doesn't destroy your Arduino with a cloud of smoke.

So is the second fritzing-sketch right for combining step one and two? - marCenzeichen

please, I really really need to get this to work. Is the sketch in reply #4 right?

Well, what happened when you tried it? I expect that would work to power the Arduino and measure battery voltage.

However it's a Fritzing diagram which means you don't have all the symbols you need to represent your real battery. Do you really have one of those square 9V batteries? Or is it some other kind of battery you haven't told us about? It looks like a 9V battery and "expect that would work" is based on that perception but if your battery is different then it might release the magic smoke.