# arduino 9v battery life

This is a great nifty tool that allows you to roughly check how much charge is left in a battery. This is a pretty bare bones project, but it could be extended to be a proper little battery testing kit I’ll quickly mention the equipment that you’ll need for this project: an Arduino Uno, 12.2 K, ohm, resistor, 3, 100 ohm, resistors, 15.1, volt, Zener, diode, a green red And yellow LED breadboard wire and, of course, a breadboard. This circuit is pretty easy to put together. If you have been following my tutorials, then you’ll notice, we’re using a new component in this one called the Zener diode. The Zener diode will allow you to test batteries that have a voltage greater than 8 volts. A Zener diode works by allowing current flow in one direction until it hits the breakdown voltage. This is the limit on the diode once it hits. This limit allows voltage to flow in the opposite direction. This can help protect parts that can only handle a certain amount of voltage. In our case, V Arduino, the 2.2 K ohm resistor reduces the current coming from the battery to something that the Arduino will be able to take in. If your current is too high, then it may damage the Arduino with 3. Leds will be using represents roughly how much charge varies left in the battery red will represent when the battery is almost dead, yellow will represent the battery being roughly half years and finally, the green will represent the battery being full, so let’s get building our circuit first.

Why the ground pin from the Arduino to the ground, rail, on the breadboard on the breadboard place of red, green and yellow LEDs? If you’re unsure, which pin is a negative one, it is for shorter one or the one with a larger flag. The larger flower can be seen if you look into the LED, connects the ground pins on the LED to the ground rail on the breadboard place, a 100 ohm resistor onto each of the positive ends of the LEDs. When hook a wire from the resistor to the pins on the Arduino, the LEDs should connect to a relevant pin on the Arduino red should go to pin 4 yellow should go to pin 3 in green to go. To pin 2 now connect up the analog pin 0 a0 to the breadboard at a 2.2 K, resistor amazeen, a diode with a line on the Zener diode facing the direction of the Arduino finally have a loose wire coming from the other end of a diode and, Lastly, have a loose wire connected to the ground rail. The code for his project is pretty straightforward, but we’ll explain in its section, so you can understand what we’re doing if you’re not familiar with coding. If you just want the code and no explanations, then you can download it over at Arduino my life up comm. Firstly, we need to set up all our variables V, LED variables are always signed to their relevant pin number on the arduino.

The analog value variable is where we’ll be storing the value that comes from a battery input. The voltage variable is where we will store the calculated voltage value from the analog value barrel. Finally, LED delay is how long we want our LEDs to remain on before switching them off. This is in milliseconds. The setup function is called once and is the perfect place to set up all our pins in this particular program. We need to set up all our LED pins to be outputs inside the loop function. We will need to do a couple of things. Firstly, we read the analog pin. The value from this pin will be between 0 and 1000 23. We will need to do a calculation to convert this to a voltage, so we simply multiply the analog value by zero point: zero, zero, four eight to do this! This last part. We compare our calculator voltage to our defined voltage, values for what’s, good, okay and a bad battery. Once you are done either writing the code up or downloading it, and you have done the circuit simply deploy it the Arduino. Now you will notice that keeps randomly changing between the LEDs. This is because the wire is floating and the DNA is picking up a lot of noise to stop this. You can simply ground the positive wire when it’s, not in use. You can also try a grounding. The other analog pins to help reduce noise to test it.

All you need to do is hook up a battery to the two wires place, the ground wire to the negative end of the battery and the positive wire to the positive end of the battery. You are doing, I should pick up a voltage until the relevant LED to light up first I’m, going to test a dead battery and, as you can see, it comes up as red now we’ll test a fully charged battery and again you can see it come up As green, finally, I will test a battery that is out about half charge and, as you can see, it comes out to be yellow if it doesn’t look like it’s working or you having trouble, then simply try adding some debug lines for the battery input. We should tell you, if there’s something wrong with reading the input or, if there’s a mistake for displaying the LEDs. Now this tutorial just covers the very basics of this project. You could extend it be a lot better and to be more of a permanent advice for you’ll use day to day, for example, you could print out the output to an LCD screen connected to the Arduino. This could give you a lot more accurate information. I will be going into how to set up an LCD screen with the Arduino in the very near future. You could also add a proper battery holder instead of using the two wires to check the life of the battery.

This will make it a bit safer and make it look very professional. I hope you have been able to build this basic, but cool Arduino battery tester. If you come across any issues, have feedback or anything else then feel free to drop a comment below or Arduino. My life up calm until next time have a good one, thanks for watching be sure to check out these 21 Arduino projects that anyone can do.

# arduino 9v battery life Social

official.arduino
2019-10-02T19:32:52+0000

👋 Want to bring Tony Stark-like gesture control to your projects? Learn how with the BLE-enabled MKR WiFi 1010 and Nano 33 BLE Sense boards using the ArduinoBLE library.
official.arduino
2019-10-02T19:08:01+0000

Arduin-yo ho ho! A fairground favorite, the pirate ship is a fun way to explore the oscillation of a pendulum. How much fun, you ask? Access our Science Kit Physics Lab preview and see for yourself: http://bit.ly/2oC6L0Q

🔬 Now that you’ve gotten your feet wet, dive into the kit and enjoy all nine experiments. Order yours today: http://bit.ly/2MnQ7fr

Originally posted 2017-12-14 15:33:58.

(Visited 64 times, 1 visits today)

## Comment (17)

1. Duke Togo says:

Can you use a smaller breadboard for this project?

1. Sabathras Saturday says:

of course!

2. ?¿?¿? says:

I am having issues with my code? Anywhere to look for help?

1. 2000jago says:

Did you watch the video? What did he say at 5:58?

3. Pascal Le Punk says:

is it working with car batteries ?

4. Pajerro says:

how i can i check a 12V battery

1. dhananjay ray says:

2. mediocre man says:

@dhananjay ray Use a voltage divider. Just google it if you do not know what it is, it is very simple, actually. For your arduino project, I suggest to assume the hightes voltage you might possibly get out of a 12V-battery (like 18V), divide the voltage by 4 and you are safe.

5. Gzan Gzan says:

Does this work with a “Funduino”

6. Dave Lacap says:

Hi Sir your video is really helpful thank you for uploading this. God bless you 🙂

7. Muhammad Hassan says:

Thanks for uploading video… is very helpful. Can you help me that how can i display my Li-ion cell voltage, current and capacity on LCD using arduino.

8. ruaa zaghmout says:

Thank you, this video is very helpful. you’ve mentioned that the voltage can be displayed on an LCD screen using the Arduino board, so can you please upload a video showing the steps of how to di it?

9. Jordy Vlassembrouck says:

How does this test your battery? Voltage does not give any information about the capacity, only current does.

10. ict says:

thank you for the video. It works very well .

11. Royale Channel says:

I have some question , can you do in phone to detect the percentage of the battery ?

12. K6L2 says:

cool video and cool concept, except you never actually explain any of the math behind the calculation, which is the bit that I was interested in.

13. Henry Grochola says:

Ads on YouTube are annoying enough why is you’re site just littered with ads all over the place.. my god man