Anda di halaman 1dari 3

Arduino Voltmeter - techprolet_ wiki

http://wiki.techprolet.com/index.php?title=Arduino_Volt...

Arduino Voltmeter
From techprolet_ wiki 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 dierents 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.

Example implementation
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 rst cell, red - end of second cell). We measure the voltage dierence between GRND and the second cell, which has a nominal voltage 7.4V.
Breadboard schematic of the simple voltmeter example

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 Arduinos Analog Input 0.
Simple voltmeter breadboard

1 of 3

03/31/2013 08:39 PM

Arduino Voltmeter - techprolet_ wiki

http://wiki.techprolet.com/index.php?title=Arduino_Volt...

Arduino Code:

/* Simple Voltmeter Copyright 2013 Pavlos Iliopoulos, techprolet.com This program is free software: you can redistribute i it under the terms of the GNU General Public License the Free Software Foundation, either version 3 of the (at your option) any later version.
Serial This program is distributed in the hope that it output will of the simple voltmeter sketch but WITHOUT ANY WARRANTY; without even thearduino implied wa MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. GNU General Public License for more details.

You should have received a copy of the GNU General Pu along with this program. If not, see <http://www.gnu */ //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 sec 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 read }

The Quadcopter Battery Monitor builds on the logic described here.

2 of 3

03/31/2013 08:39 PM

Arduino Voltmeter - techprolet_ wiki

http://wiki.techprolet.com/index.php?title=Arduino_Volt...

References
1. arduino analogReference [1] (http://arduino.cc/en/Reference/AnalogReference) Retrieved from "http://wiki.techprolet.com/index.php?title=Arduino_Voltmeter& oldid=43" Categories: Arduino Batteries DC Power Quadcopter This page was last modied on 24 February 2013, at 16:29. This page has been accessed 38 times.

3 of 3

03/31/2013 08:39 PM

Anda mungkin juga menyukai