0 ratings0% found this document useful (0 votes) 36 views4 pagesVoltimetro Arduino Zener
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
Code Bank
Tag Archives: arduino voltmeter
Arduino Voltmeter - 2 (more precise)
© th August 2016 Arduino arduino voltmeter
(On some Arduino boards there isa Pin labelled as AREF or Analog Reference. This pin is very useful in
cases where a stable and precise voltage reference is needed for the ADC. Practically the supplied
voltage to the board can vary abit, specially it can fall below the rated voltage depending on the load
to the board.
By default Arduino uses the voltage of the board, that is Sv or 3.3v (depending on the board). Using
the function analogReference() this can be changed, The function accepts one parameter called type.
If the type mentioned is DEFAULT then it will use the voltage of the board. INTERNAL type will use a
built-in reference equal to 1.1 volts on the ATmega168 or ATmega328 and 2.56 volts on the ATmega8.
‘And EXTERNAL will use the voltage supplied to the AREF pit
(More about analogReference can be read at https://www.arduino.cc/en/Reference/AnalogReference}
Please note the voltage at AREF can @-5 volts only and the input
voltage at the I/O pin (here A®) cannot exceed that of the AREF pin.
‘The simple voltmeter described in a previous article has been modified here. It is now supplied with a
precise reference voltage at the AREF pin.
R3
2200
Max 20 volts DC
fritzingThe 5K resistance is not a necessity, it has been added for safety (switching to the INTERNAL while
external power is given to AREF can damage the board with that resistance). I the resistance is used
then the voltage at AREF will not be exact as supplied. That is because internally there is a 32k resistor
connected to the AREF pin.
Soin above case the voltage that the AREF actually getting is 3.3°32/(32+5) = 2.8540 (the actual will
vary due to tolerance of components, so for cases where high precision is needed, the values of the
resistors will have to be measured and also the voltage of the zener, and the voltage in the code nees
‘tobe changed accordingly.
define READINGS 5
int sensorPin = AQ;
short int readingsTaken = 0;
float voltage = 0.0, readingTotal = 0.0;
void setup() {
// put your setup code here, to run once:
pinMode(sensorPin, INPUT);
analogReference (EXTERNAL) ;
Serial.begin(9600) ;
void loop() {
// put your main code here, to run repeatedly:
readingTotal = 0.0;
readingsTaken
// we will take 5 readings at 1 sec interval and then do an
average of that
while(readingsTaken < READINGS)
{
readingTotal += analogRead(sensorPin) ;
readingsTaken++s
delay(100@); //at every 1 second interval
voltage = (readingTotal/READINGS) * (2.8540/1024); // 2.8540 is
the ref voltage being used. //the value in voltage at this point is
what Arduino read based on input from voltage divider network. Need
to calculate the original -- see below
voltage = (20/2.609) * voltage; //unitary method to calculate the
actual voltage that is read. When voltage read is 2.609, the input
is 20v. With the above voltage divider used at input (10@K ohm and
15k ohm) the input voltage at the I/O (pin A@) will be 2.609 when
2ev is applied.Serial. printIn(voltage);
Voltmeter using Arduino
© 24th July 2016 Arduino # Arduino, arduino analog input, arduino voltmeter
Using precisely calculated resistors and a stable power supply, Arduino can be used to work as a
voltmeter.
Below is the schematic
Max 20 volts DC
fritzing
Though | used an Arduino Uno, but any Arduino can be used. (Ifthe 3.3v versions are used then
calculations will have to be done accordingly).
The resister for voltage divider has been chosen such that at 20 volts (measurement) supply the
voltage at Arduino input pin is 5.0v. Greater than Sv at the input pin can damage the pin.
Here is the code
define READINGS 5
int sensorPin = AQ;
short int readingsTaken = @;
float voltage = 0.0, readingTotal = 0.0;
void setup() ¢
// put your setup code here, to run once:pinMode(sensorPin, INPUT);
Serial. begin(9600) ;
void loop() {
// put your main code here, to run repeatedly:
readingTotal = 0.0;
readingsTaken = 5
// we will take 5 readings at 1 sec interval and then do an
average of that
while(readingsTaken < READINGS)
{
readingTotal +:
analogRead(sensorPin) ;
readingsTaken++;
delay(100@); //at every 1 second interval
}
voltage = (readingTotal/READINGS) * (5.0/1024); // the value in
voltage at this point is what Arduino read based on input from
voltage divider network. Need to calculate the original // 5.0 - is
the ref voltage used by ADC. It is the default configuration and
uses the voltage supplied to the board. To change the ref
voltage/source please see this article
voltage = (20/4.992) * voltage; //unitary method to calculate the
actual voltage that is read. when voltage read is 4.922 (or 5.0v),
the input is 20v. With the resistor divider at the input, the
voltage at 1/0 will be 4.992
Serial.print1n(voltage);
This isa simple and basic way. Where the precision will not be very good. Because the reference
voltage being used by the ADC, which is actually the supply voltage can vary depending on the load to
‘the circuit. To make it more precise an external reference voltage can be supplied to the Arduino. How
‘to.se an external reference voltage and the use of the AREF pin has been described in this article