Hello
i'm working on a project and i wondered if it was possible to read my battery voltage. Is there someone who has already made a program for that or that has a solution to do this?
Thanks!
Hello
i'm working on a project and i wondered if it was possible to read my battery voltage. Is there someone who has already made a program for that or that has a solution to do this?
Thanks!
What battery voltage?
You may need a voltage divider, Google is a friend.
What do you want to do with the reading?
Have you ever used the analog inputs to read voltages?
i shall give you some more information. I'm working with an adafruit huzzah esp8266 an are programming everything with the arduino ide program. To power my adafruit i use an powerbank. Now i want to see how much of my battery power is used when my adafruit is working. Now you have a bit more information. I'am an beginner and don't know how i need to realise this, that i needed an voltage divider, i know but i don't know how to program it.
that i needed an voltage divider, i know
Then you should know what to connect where. One end of the pair of resistors goes to the battery. The other end goes to ground. The middle point goes to an analog pin.
i know but i don't know how to program it.
int analagValue = analogRead(analogPin);
Now, what you do with the reading is up to you. Since the value is between 0 and 1023, and 1023 corresponds to the Arduino voltage, the battery voltage is a simple ratio of the Arduino voltage.
As you might have guessed, that ratio makes it really hard to determine the voltage of the battery powering the Arduino. As the battery goes down, so does the Arduino voltage. After all, the voltage regulator doesn't manufacture power.
A voltage divider is a simple pair of resistors that effectively divides down the input voltage in the ratio R2/(R2 + R1).
If you have an 8 V input and a 2:1 voltage divider (R2 == R1), then the output is 4V.
So, an analogRead on an input equipped with such a divider would return values roughly in the range 0 ... 820.
As the battery goes down, so does the Arduino voltage. After all, the voltage regulator doesn't manufacture power.
Not really. If the battery is above the level needed for the onboard regulator to work (~6.8V), then Aref will be stable and the readings of the divided-down battery will be correct.
If the resistor divider is made even smaller, such that the max reading is 1.1V, then the internal band-gap reference can be used instead, and Vcc below 5V could be measured.
Not really. If the battery is above the level needed for the onboard regulator to work
With that qualification, I agree. When the battery drops below that level, though, the regulator can't manufacture voltage, so the output will drop.
Yes, once the voltage drops below what the regulator needs, things get funny.
I would think that as long as Vcc is above 3.8V (and I haven't done any testing to see what happens to the regulator output when its input drops below 6V, the output will start dropping tho) the arduino would still work; using the internal 1.1V reference should still work. The voltage divider would then have to be set for 1.1V max with fully charged battery.