Hello Everyone, My name is Harji Nagi. I am currently a third-year student studying electronics and communication engineering from Pranveer Singh Institute Of Technology (PSIT), Kanpur(Uttar Pradesh).I have a keen interest in robotics, Arduino, Artificial Intelligence, and Analog electronics.

 

Introduction:

It's easy to make a simple digital voltmeter using an Arduino and 16x2 liquid crystal display (LCD).

It's relatively simple to use an Arduino to measure voltages. The Arduino has several analog input pins that connect to an analog-to-digital converter (ADC) inside the Arduino. The Arduino ADC is a ten-bit converter, meaning that the output value will range from 0 to 1023. We will obtain this value by using the analogRead() function. If you know the reference voltage--in this case we will use four different power sources like 9V and 5 battery, Solar Panel. We can easily calculate the voltage present at the analog input.

To display the four measured voltages, we will use a liquid crystal display (LCD) that has two lines of 16 characters. LCDs are widely used to display data by devices such as calculators, microwave ovens, and many other electrical appliances. Therefore the monitoring system consists of 4 different parameters i.e V1, V2, V3, V4. In this project, I measured voltages of Solar panel, two 9V battery, and one 5V battery simultaneously

This project will also show you how to measure voltages above the reference voltage by using a voltage divider. In order to measure voltages greater than the 5 V reference voltage, we need to divide the input voltage so that the voltage actually input to the Arduino is 5 V or less. in this experiment, we will use a 100 Kohm resistor and a 10 Kohm resistor to create a 10:1 divider. This will allow us to measure voltages up to 50 V.

List of Components:

  • 1x Arduino Nano
  • 1x 100 Kohm resistor
  • 1x 10 Kohm resistor
  • 1x LCD (Liquid Crystal Display)
  • 1x 10k potentiometer
  • 1x breadboard
  • male and female jumper wires

 

Circuit Diagram

 

Circuit Diagram (1.0) for measuring single Voltage

In the above circuit diagram, the microcontroller is Arduino mega the same circuitry can be applied with Arduino Uno and Nano. And this circuit is for measuring a single voltage.

 

The potentiometer is connected to the 5V source and GND and the middle terminal is connected to pin 3 of LCD. Rotating this pot changes the brightness of the LCD. The four data pins DB4-DB7 are connected to the Arduino pins 4-7. Enable is connected to pin 9 of the Arduino and RS is connected to pin 8 of the Arduino. RW is connected to ground. The backlight LED is connected to 5V and ground. The following table shows the pin connections:

DB4 ----->pin4

DB5 ----->pin5

DB6 ----->pin6

DB7 ----->pin7

RS   ----->pin8

EN   ----->pin9

 

Circuit Diagram (1.1) for measuring for 4 voltages

The above circuit diagram will be the same as that of the circuit(1.0), the only difference is about the increase in the number of resistors and analog pins to measure different voltages simultaneously.

Code:

The program below uses the LiquidCrystal.h library. This library contains all of the functions needed to write to the LCD.

The loop reads the analog value from the analog input, and because the reference voltage is 5 V, it multiples that value by 5, then divides by 1024 to calculate the actual voltage value, once the voltage has been calculated we have to divide the calculated voltage by the ratio R2/(R1 + R2), which in this case is 10,000/(100000 + 10,000) ≈ 0.09.

 

, the value is written to the LCD.

 

/*1x Arduino Mega2560
1x 100 kohm resistor
1x 10 kohm resistor
1x LCD (Liquid Crystal Display)
1x 5k potentiometer
1x breadboard
female connector
jumper wires
*/
#include "LiquidCrystal.h"

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

float input_voltage = 0.0;
float temp=0.0;
float input_voltage1 = 0.0;
float temp1=0.0;
float input_voltage2 = 0.0;
float temp2=0.0;
float input_voltage3 = 0.0;
float temp3=0.0;
float r1=90900.0;
float r2=10000.0;


void setup()
{
  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
  lcd.begin(16, 2); //// set up the LCD's number of columns and rows: 
}
void loop()
{
   
//Conversion formula

  int analog_value = analogRead(A0);
  temp = (analog_value * 5.0) / 1024.0; 
  input_voltage = temp / (r2/(r1+r2));
   
  if (input_voltage < 0.1) 
  {
  input_voltage=0.0;
  } 
  Serial.print("v= ");
  Serial.println(input_voltage);
  lcd.setCursor(0,0);
  lcd.print("V1=");
  lcd.print(input_voltage);
  delay(300);
  int analog_value1 = analogRead(A1);
  temp1 = (analog_value1 * 5.0) / 1024.0; 
  input_voltage1 = temp1 / (r2/(r1+r2));
   
  if (input_voltage1 < 0.1) 
  {
  input_voltage1=0.0;
  } 
  Serial.print("v= ");
  Serial.println(input_voltage1);
  lcd.setCursor(0,1);
  lcd.print("V2=");
  lcd.print(input_voltage1);
  delay(300);
  int analog_value2 = analogRead(A2);
  temp2 = (analog_value2 * 5.0) / 1024.0; 
  input_voltage2 = temp2 / (r2/(r1+r2));
   
  if (input_voltage2 < 0.1) 
  {
  input_voltage2=0.0;
  } 
  Serial.print("v= ");
  Serial.println(input_voltage2);
  lcd.setCursor(8,0);
  lcd.print("V3=");
  lcd.print(input_voltage2);
  delay(300);
  int analog_value3 = analogRead(A3);
  temp3 = (analog_value3 * 5.0) / 1024.0; 
  input_voltage3 = temp3 / (r2/(r1+r2));
   
  if (input_voltage3 < 0.1) 
  {
  input_voltage3=0.0;
  } 
  Serial.print("v= ");
  Serial.println(input_voltage3);
  lcd.setCursor(8,1);
  lcd.print("V4=");
  lcd.print(input_voltage3);
  delay(300);
}