Introduction: Arduino and LCD- 0 Volt -- 1000 Volt – User Selectable Digital Volt Meter

Abstract

The Arduino inbuilt 10 bit ADC, can be used for constructing / measuring the 0 Volt to 1000 Volt user selectable Digital Volt Meter. The 16x2 LCD display driver, connected with Arduino Uno will be used for displaying the measured voltage. This voltmeter can read only DC voltage.

Parts and components

Arduino Uno board

16x2 LCD = 1 No

1K Potentiometer = 1 No

4 Way, 2 Pole Rotary switch = 1 No

Resistor 10 K = 4 Nos

Resistor 1 K = 1 No

Resistor 9 K = 1 No

Resistor 90 K = 1 No

Resistor 900 K = 1 No

IN5913B 3.3 Volt Zener diode = 1 No

Step 1: Schematic

The 16x2 is very common type LCD, with two rows, and each row displays 16 characters of either 5x7 or 5x8 dot matrix characters.

The LCD is available in a 16 pin package. It consists of back light and contrast adjustment function and each dot matrix has 5×8 dot resolution.

The 16x2 LCD display is connected to the Arduino (13,12,11,10,9 and 8) digital IO pins, where LCD operates at 4 bit data mode.

If the display is not visible, adjust the Contrast pot (1K), to make it visible.

A Rotary switch operates by rotation of its spindle / shaft. Rotary switches are chosen when more than 2 positions are needed.

A four way, two pole rotary switch used for this design. One pole is connected to the voltage divider network and then A0 analog input pin of Arduino.

And another pole is connected to 5,4,3 and 2 Digital IO pins, used for selecting the DVM range Voltage divider circuit is used to divide voltage into two parts (measurement and drop).

Internal Vref (1100 mV) of Arduino is selected for measurement.

IN5913B 3.3 Volt Zener diode, at A0 pin, will product the Arduino, from over voltage inputs.

ADC Resolution = Vref / (1024 -1).

ADC Resolution = 1.1 V / 1023 = 1100mV / 1023 = 1.075 mV.

1000 mVolt Scale

  • 0 to 1 Volt measurement voltage is directly fed to A0 analog input.
  • There is no potential divider is used for measuring the 0 to 1Volt.
  • If Vin is 1 Volt then Vmeasurment = 1.0 V = 1000 mV.
  • DVM Resolution = (1.1 / 1023) 1 Volt = 1.075 mV.

10 Volt Scale

  • 0 to 10 Volt measurement voltage is fed to A0 analog input, through potential divider (R19 : R7) (1K and 9K).
  • If Vin is 10 Volt then Vmeasurment = 10 (1K / 10K) = 1000 mV.
  • DVM Resolution = (1.1 / 1023) 10 Volt = 10.75 mV.

100 Volt Scale

  • 0 to 100 Volt measurement voltage is fed to A0 analog input, through potential divider (R19 : R7+R8) (1K and (9K+90K)).
  • If Vin is 100 Volt then Vmeasurment = 100 (1K / 100K) = 1000 mV.
  • DVM Resolution = (1.1 / 1023) 100 Volt = 107.52 mV.

1000 Volt Scale

  • 0 to 1000 Volt measurement voltage is fed to A0 analog input, through potential divider (R19 : R7+R8+R5) (1K and (9K+90K+900K)).
  • If Vin is 1000 Volt then Vmeasurment = 1000 (1K / 1000K) = 1000 mV.
  • DVM Resolution = (1.1 / 1023) 1000 Volt = 1075.2 mV. = 1.075 Volt

Step 2: Software

The Arduino LiquidCrystal library is used for displaying the measured voltage at 16x2 LCD.

The 1.1V internal reference is chosen for the ADC.

The voltage divider will, provide the input voltage between 0 to 1100mV.

Hence the software will measure and display the values between 00.00 Volt to 1000.00 Volt, in accordance with the Scale selection.

Sine 4 way 2 pole rotary switch is used, the Scale selection and voltage divider selection happens in parallel.

Initially the software will display the “DC Volt meter” for about one second.

If over voltage is fed, the software will display the over voltage indication too (> 1 mVolt, > 10 Volt, > 100 Volt, > 1000 Volt).

10 bit ADC reading is mapped to 1100 mV, which is the Vref mille volt.

Every 500 mSec the ADC is polled and displays the new reading.

// Experiment of measuring 0 Volt - 1000 Volt DC
// Display it on a 16x2.

// The Arduino circuit connection for LCD: // LCD RS pin to digital pin 13 // LCD Enable pin to digital pin 12 // LCD D4 pin to digital pin 11 // LCD D5 pin to digital pin 10 // LCD D6 pin to digital pin 9 // LCD D7 pin to digital pin 8

// The Arduino circuit connection for the scale // Rotary pin for 1 Volt scale is connected pin 2 of digital IO // Rotary pin for 10 Volt scale is connected pin 3 of digital IO // Rotary pin for 100 Volt scale is connected pin 4 of digital IO // Rotary pin for 1000 Volt scale is connected pin 5 of digital IO

// Analog pin A0 is connected to the potential divider

// Name:- M.Pugazhendi // Date:- 20thJul2016 // Version:- V0.1 // e-mail:- muthuswamy.pugazhendi@gmail.com

// include the library code: #include <LiquidCrystal.h>

//initialize the library with the numbers of the interface pins LiquidCrystal lcd(13,12,11,10,9,8);

// Arduino pins used for the switches #define S1 5 #define S2 4 #define S3 3 #define S4 2

// State of each switch (0 or 1) int s1_state; int s2_state; int s3_state; int s4_state;

int analogPin1 = 0; int val = 0; // variable to store the value read float f_converted = 0; int i_converted = 0;

void setup() { // Select the internal analog reference 1.1 Volt. analogReference(INTERNAL); // pins for switches are inputs pinMode(S1, INPUT); pinMode(S2, INPUT); pinMode(S3, INPUT); pinMode(S4, INPUT);

// set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("DC Volt meter");

// One sencond delay delay(1000); }

void loop() { // Read the DC voltage measurment scale. s1_state = digitalRead(S1); s2_state = digitalRead(S2); s3_state = digitalRead(S3); s4_state = digitalRead(S4);

// read the Analog input pin val = analogRead(analogPin1);

//Clear screen lcd.clear(); if(s1_state == 0x00) { // set the cursor to line 1 lcd.print("1000V Scale"); // set the cursor to line 2 lcd.setCursor(0, 1); if(val >= 931) { lcd.print("> 1000.00 Volt"); } else { f_converted = fmap(val, 0, 1023, 0.0, 1100.00); lcd.print(f_converted); lcd.print(" Volt"); } } if(s2_state == 0x00) { // set the cursor to line 1 lcd.print("100V Scale"); // set the cursor to line 2 lcd.setCursor(0, 1); if(val >= 931) { lcd.print("> 100.00 V"); } else { f_converted = fmap(val, 0, 1023, 0.0, 110.00); lcd.print(f_converted); lcd.print(" Volt"); } } if(s3_state == 0x00) { // set the cursor to line 1 lcd.print("10V Scale"); // set the cursor to line 2 lcd.setCursor(0, 1); if(val >= 931) { lcd.print("> 10.00 V"); } else { f_converted = fmap(val, 0, 1023, 0.0, 11.00); lcd.print(f_converted); lcd.print(" Volt"); } } if(s4_state == 0x00) { // set the cursor to line 1 lcd.print("1000 mVolt Scale"); // set the cursor to line 2 lcd.setCursor(0, 1); if(val >= 931) { lcd.print("> 1000 mVolt"); } else { i_converted = map(val, 0, 1023, 0, 1100); lcd.print(i_converted); lcd.print(" mVolt"); } }

//500mS delay delay(500); }

//Float interpolation function, for mapping the ADC reading

float fmap(float x, float in_min, float in_max, float out_min, float out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; }

Step 3: Conclusion

The project is successfully simulated by using the Proteus.

The measured DC voltage is displayed 16x2 LCD display.

Below illustration will demonstrate the accuracy and measured values.

Comments

author
soylo (author)2017-05-18

rotary switches connect to arduino and resistor

Please explain

author
IndikaP2 (author)2016-07-25

Very nice projects and I am looking for this for AC main voltage monitor. I will do some modification and let you know what happens. Thanking you for shearing this cool and valuable knowledge.