Is there any way of monitoring Voltage level of battery from arduino.
I want to monitor voltage level of battery that is connected to motor in my robot.
Thanks.
Is there any way of monitoring Voltage level of battery from arduino.
I want to monitor voltage level of battery that is connected to motor in my robot.
Thanks.
Use the ADC.
Thank leon_heller, I want to read the input Voltage is more than 5V (12V) that arudino support.
How to convert 12 to 5 v for getting correct result, 1- using Voltage regulator or 2- Voltage Driver (with two resistors).
Thanks.
That would be #2, a voltage **divider** with 2 resistors. A voltage regulator takes a voltage that may range from some low to some high value and outputs a constant voltage. If you feed this constant voltage into the ADC it won't tell you anything about the regulators input voltage. The "trick" is to get the proper values for the 2 resistors so the Arduino's ADC makes an accurate measurement.moorejohn90:
Thank leon_heller, I want to read the input Voltage is more than 5V (12V) that arudino support.How to convert 12 to 5 v for getting correct result, 1- using Voltage regulator or 2- Voltage Driver (with two resistors).
Thanks.
Thank Mee_n_Mac for your advice.
Just to add a bit of fuel to the fire, measuring voltage on a battery to guess at how much reserve capacity you have left is often an exercise in futility.
As an example, I have a single AA lithium battery that I have a 10 ohm resistor shorted across the terminals. The battery has been like this for weeks and is as dead as a door nail. If I measure the voltage across the terminals it is pretty much 0.0V. Now I disconnect the resistor and come back in 15 minutes. The battery now reads 1.7V just like a fresh battery. Replace the resistor and in short order the battery is back to 0.0V. Taking a measurement when the load was off would have indicated I had a fresh battery when in fact it is dead.
The above example is just one reason voltage is not a good indication of reserve. It is better than nothing, but only if the voltage is measured under load. A “real” solution (and those are not perfect by any means as well" is a dedicated “Coulomb” counter IC wired into the power distribution. These chips count electrons as they go by and decrement the count from how many electrons the battery is rated to push. The do pretty good but fall apart as rechargeable batteries age, or under temperature extremes.
an extra hint on the simpler voltage divider solution, be sure to pick fairly high resistors (10k+) to minimize current, otherwise you’ll drain your battery just by trying to measure it all the time. as an example, i’m reading a 0-5v analog signal on a 3.3v arduino with a divider made up of 18k and 33k resistors.
Even with just using a voltage divider you won’t know how much the battery level dropped. If the ADC compares the level of the voltage divider against Vcc (actually aVcc, like filtered battery voltage) then you only measure the divider ratio. As a drop in battery level results in proportional drop in voltage of the voltage divider. You need a voltage source that is independant of Vcc, or as much as possible constant. The good news is that AVR chips have one built in. (all Arduino bords have a AVR chip of some sort) This is often at 2.56 volt , or 1.3 volt in some devices iirc. Though could deviate based on temperature and manufacture tolerances. The ADC must select it as reference using the ADC multiplexer, and measure a pin on a voltage divider that has a level below the reference. Or, if the battery level is connected to the Aref pin then you could configure the ADC multiplexer to measure the internal voltage reference against the Aref pin. This is inverse battery level measurement, measuring the constant 2.56v against varying 5 volt. Math does the rest to make sense of it. I don’t know how this is configured with Arduino code though. You’ll have to investigate that yourself.
What you want is analogreference() http://www.arduino.cc/en/Reference/AnalogReference to configure the ADC voltage reference.
You can divide down the Vbat to a bit below the reference voltage. If Vbat feeds the power supply in your system, you should have consistent readings until it falls below the power supply’s dropout voltage. As was mentioned earlier, you should consider the effect of battery load in your program. If you have a variable load (motors for example), then you will want to figure what constitutes a “discharged” level. For example, a motor start will pull your Vbat down and you would want to avoid false alarms.