Hello,
I want to use my Arduino as a voltmeter to measure the voltage in Li-po battery with 11.1v.
I believe that direct connection between battery and arduino will cause a damage for arduino.
So what is the right way to do this mission?
I don't have a good background in this field so please help me.
I believe that direct connection between battery and arduino will cause a damage for arduino.
That is correct. The maximum allowable voltage on an input pin is 5V (Vcc).
The "trick" is to use a [u]voltage divider[/u] (2 resistors). Then, you simply compensate for the voltage drop/difference in software.
When the voltage divider is connected to the battery it will draw current (per [u]Ohm's Law[/u]) so if it's connected continuously, choose resistor values that draw insignificant' current (relative to the normal current draw). Very-high value resistors (i.e. in the megohm range) will be more sensitive to noise pickup, especially with long wires.
(In a "real" voltmeter where the voltage is sometimes unknown, you'd need an over-voltage protection circuit, but that's not necessary if you are always measuring the same battery.)
Wawa:
True.
Arduino's A/D, with the internal 1.1volt Aref enabled, is good enough for "simple" voltage measurements.
e.g. a 30volt range with 0.1volt resolution should not be a problem.
Try this sketch I wrote some time ago for a 12volt lead/acid battery.
Leo..
/*
0 - ~16volt voltmeter for 3.3volt and 5volt Arduinos
uses the stable internal 1.1volt reference
6k8 resistor from A0 to ground, and 100k resistor from A0 to +batt
100n capacitor from A0 to ground for stable readings
(100k + 6k8) / 6k8 = 15.70588 | used in formula
*/
float Aref = 1.075; // calibrate here | change this to the actual Aref voltage of ---YOUR--- Arduino
unsigned int total; // can hold max 64 readings
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 < 64; x++) { // multiple analogue readings for averaging
total = total + analogRead(A0); // add each value to a total
}
voltage = (total / 64.0) * 15.70588 * Aref / 1024 ; // convert readings to volt
// print to serial monitor
if (total == (1023 * 64)) { // if overflow
Serial.print("voltage too high");
}
else {
Serial.print("The battery is ");
Serial.print(voltage);
Serial.println(" volt");
}
total = 0; // reset value
delay(1000); // one second between measurements
}
Wawa:
~US$2.00 including worldwide shipping is too expensive?
This sketch might be the best a bare Arduino can do.
Leo..
/*
0 - ~17volt voltmeter
works with 3.3volt and 5volt Arduinos
uses the stable internal 1.1volt reference
10k resistor from A0 to ground, and 150k resistor from A0 to +batt
(1k8:27k or 2k2:33k are also valid 1:15 ratios)
100n capacitor from A0 to ground for stable readings
*/
unsigned int total; // holds readings
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() {
total = 0; // reset
analogRead(A0); // one unused reading to clear any ghost charge
for (int x = 0; x < 64; x++) { // 64 analogue readings for averaging
total = total + analogRead(A0); // add each value
}
voltage = total * 0.0002567; // convert readings to volt | ---calibrate by changing the last three digits---
Serial.print("The battery is ");
Serial.print(voltage); // change to (voltage, 3) for three decimal places
Serial.println(" volt");
delay(1000); // readout delay
}
Ak96:
Hello,
I want to use my Arduino as a voltmeter to measure the voltage in Li-po battery with 11.1v.
I believe that direct connection between battery and arduino will cause a damage for arduino.
With a LiPo "damage" isn't quite the right word - "explode" or "vaporize" is more like it!
LiPo's can provide enormous amounts of current and power, and its worth considering the
risks carefully - here the top resistor of the voltage divider will limit the current to safe levels
whatever the source of voltage. The wires leading up to that first resistor are capable of high
currents, so be sure to prevent any chance of them shorting out.
Other times you might need a fuse when working with a LiPo power source to prevent the wiring
catching fire should there be an accidental short-circuit. In fact I'd always recommend adding
a fuse, even for LiPo packs with full protection circuits built-in, as accidental fires can be very
expensive, not to say dangerous...