Arduino Voltmeter

Arduino boards are equipped with analog inputs. Using the input
voltage as 5V reference, one can read the analog input of any given 0-5V voltage with an accuracy of 5V/1024 = 4.88 mV (hint: don't expect accuracy to be anywhere near that number). Arduino in fact can take a different input as its voltage reference [1].

In our example, we use USB as our power source and make the assumption that reference input voltage is a constant 5V.


Step 1: Example implementation

Arduino Voltmeter
Arduino Voltmeter

What follows is a simple voltmeter used to monitor a 7.4V LiPo 2S battery pack.
The charge balancer connector of a 2S (2 cell) LiPo has 3 terminals (black - GRND, blue - end of first cell, red - end of second cell). We measure the voltage difference between GRND and the second cell, which has a nominal voltage 7.4V.

Since the analog input maxes out at 5V, we use 2 2.2kΩ resistors in series as a voltage divider. This means that when the battery pack is connected to the voltmeter, at least 7.4V/4.4kΩ = 1.7mA or (7.4^2)/4400=12.5mW are consumed.

The battery's GRND is connected to Arduino's GRND and the point between the two resistors (where the voltage is halved) is connected to Arduino's Analog Input 0.

Step 2: Arduino code

Arduino Voltmeter

Upload the following code to your arduino:

/*Simple Voltmeter Copyright 2013 Pavlos Iliopoulos, techprolet.com This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ //set reference voltage; float refVcc = 5.0; // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } // the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); // print out the value you read: Serial.print("Analog read: "); Serial.println(sensorValue); // print out the converted (voltage) value Serial.print ("Voltage: "); Serial.print (sensorValue*refVcc/1024); Serial.println ("V"); Serial.println("--------------------"); delay(1000); // delay a whole second before reading again }

Your LiPo's current juice is two times the reading you get from the Arduino (Remember, we halved the voltage before measuring)
Likewise, you can measure 3S LiPos (11.1V) by dividing voltage by 3, 4S LiPos (14.8V) by dividing by 4 etc.
This is it, enjoy your new LiPo voltmeter!

The best thing is, your Arduino can do a lot other stuff while also monitoring your LiPo!

Reference:
[1] arduino analogReference

http://arduino.cc/en/Reference/AnalogReference

Arduino Voltmeter
arduvoltmeter.ino1 KB
 
 

Tag cloud

make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel