• Pooja Velavan

Building a Digital Voltmeter using Arduino UNO.

Digital Voltmeter is a testing instrument that is used to measure the electrical potential difference between two points in a circuit and displays the measured voltage values in the discrete numeric form.


Now, in this article let us attempt to design the Digital voltmeter using Arduino UNO in the TinkerCAD simulation software.


Simulation software is an interactive tool generally used in experimenting with the circuit design before establishing it in the hardware/PCB board. It helps to analyze the design schematic, to check the integrity of its functions and makes sure of the efficiency of the design before establishing it in the circuit board.


Let's first start with the requirements that we will need to design the circuit with TinkerCAD Software.


Hardware Requirements:


These components are required for manual circuit development, for #simulation purposes TinkerCAD software is sufficient. To build the circuit manually, click on the links given below to buy the components required.


1. Breadboard


Breadboard
Breadboard

A breadboard is an essential component that is in a rectangular shape with small holes in it that are used to insert the components to test the circuits. The connections are not fixed and can be varied. In a breadboard, the holes in one horizontal line are in series connection with each other. Breadboards are made from plastic or wood and come in all shapes, sizes, and even different colors, the most commonly used sizes for designing the circuits are "full-size," "half-size," and "mini" breadboards.


Buy Breadboard from here.


2. Arduino UNO

Develop a stronger concept in Arduino through this article:- What is Arduino?

Arduino UNO
Arduino UNO

#Arduino board is a microcontroller that accepts inputs from sensors connected and provides an output action on the desired device connected to it. The sensor inputs can be from light-detecting sensors, motion sensors (Ultrasonic or IR), temperature sensors, etc. The output from this device can be received through devices such as LED, Buzzer, Serial monitor, etc.


Buy Arduino UNO from here.


3. 16*2 LCD Display


16*2 LCD Display
16*2 LCD Display

16*2 #LCD Display is a basic electronic display module in various devices and circuits. It has 16 pins that include a ground pin, supply pin, contrast control, register select, read/write, enable, Data pin 0 to 7, LED+5V and, LED-Ground.


Buy 16*2 LCD Display from here.


4. DC Power Supply


DC Power Supply
DC Power Supply

The power supply is essential, electronic devices that are used to convert AC power to DC power output. It constantly supplies the DC voltage to its load.


Buy DC Power Supply from here.


5. Resistor

Resistor
Resistor

Resistors are passive devices that restrict the flow of current or divide the voltage through the circuit. The input power passes through these resistors and then to the sensors to avoid damage. Here in this project, 220 ohm, 1M ohm, and 10K resistors are used.


Buy Resistors from here.


6. Jumper Wires


Jumper Wires
Jumper Wires

These are the main components that are used to establish the connections between different devices of the circuit. There are three types male to female, female to female, and male to male.


Buy Jumper Wires from here.


7. USB Cable


USB Cable
USB Cable

This cable is used to connect the development boards to the power supply. It also helps in the transmission of data.


Buy USB Cable from here.


Software Requirements:


1. TinkerCAD Software:


TinkerCAD Software LOGO
TinkerCAD Software LOGO

It is an easy-to-use online simulation #software used for circuit design. It has all the essential electrical components required to built and analyze the circuit.


Visit the TinkerCad website.


Circuit Connection:


Circuit Connection
Circuit Connection

The circuit connection involves the following steps:

  • First, we will start with the connection of LCD, Connect the Data PIN 4,5,6, and 7 to the 5,4,3,2 Digital pins of the Arduino board.

  • The supply pin (VCC) is connected to the positive terminal of the breadboard.

  • Connect the RS and Enable pins of the LCD to the 11th and 12th pins of the Arduino Board respectively.

  • Then, connect the GND pin, Vo pin, RW pin, and one LED pin of the LCD to the negative terminals of the breadboard.

  • Connect another LED pin to one terminal of the 220-ohm resistor and the other terminal is grounded.

  • Two resistors R1= 1M ohm and R2= 10K ohm resistors are used to build a voltage divider circuit to maximize the voltage readings range.

  • Connect the positive end of the power supply terminal to the one end of the 1M ohm resistor and the other end to the 10K ohm resistor. And another end of the 10K ohm resistor is grounded.

  • The negative end of the power supply terminal is connected to the negative terminal of the breadboard.

  • From the junction of two resistors, a terminal is connected to the analog PIN A0 of the Arduino board.

  • Finally, the GND pin of the Arduino pin is connected to the negative terminal of the breadboard to establish a common ground connection. Then, the VCC- 5 volts of the Arduino is also connected to the positive terminal of the breadboard respectively.


Code Explanation:


Let us learn the code to measure the voltage reading for numeric output.

#include "LiquidCrystal.h"

Include the Liquid Crystal library in the code as we use the LCD display.

LiquidCrystallcd( 12,11,5,4,3,2);

Initialize the pins of the LCD to which it is connected to the Arduino board.

float input_voltage = 0.0;
float temp=0.0;
float r1=1000000.0;//1Mohm
float r2=1000.0;//10Kohm

The variables are declared using the "float" data type. Initialize the input value and temperature value to 0.0. And declare the values of the resistors in the r1 and r2 variables.

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: 
lcd.print("DIGITAL VOLTMETER");
}

In the setup ( ) function, declare the baud rate if you need the output is to be displayed in the serial monitor. The lcd.begin is used to set up the number of columns and rows in the LCD to display the output. And lcd. print function to print the line in the LCD screen.

void loop()
{
//Conversion formula for voltage

 float analog_value = analogRead(A0);
 temp = (analog_value * 5.0) / 1024.0;
input_voltage=temp/(r2/(r2+r1));

In the loop function, the analog_value is declared using the float datatype. Then analogRead function is used to read the values of the voltage from the Analog pin A0 of the Arduino board. The temp variable is declared to calculate the input voltage value. It is calculated by multiplying the analog_value with the supply voltage (5V) and dividing it by 1024 for displaying the output in discrete analog levels. Finally, the input voltage is calculated by dividing the calculated "temp" value with the resistors by the voltage divider rule.

if (input_voltage< 0.1) 
 {
input_voltage=0.0;
 } 
Serial.print("v= ");
Serial.println(input_voltage);
lcd.setCursor(0, 1);
lcd.print("Voltage= ");
lcd.print(input_voltage);
 delay(1000);
}

Use "if condition" to check the voltage value. If the measured voltage reading is less than 0.1V then the output is printed as 0.0. Print the value of the voltage that is equal or above 0.1 and the input voltage in the serial monitor by using the Serial.print function. The lcd.setcursor function determines the column or row from which the output is to be printed. Then print the statements that are to be printed on the LCD screen and with the delay of 1000 millisecond the loop operation is repeated.


Complete Code:


#include "LiquidCrystal.h"
LiquidCrystallcd( 12,11,5,4,3,2);
float input_voltage = 0.0;
float temp=0.0;
float r1=1000000.0;//1Mohm
float r2=1000.0;//10Kohm
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: 
lcd.print("DIGITAL VOLTMETER");
}
void loop()
{
//Conversion formula for voltage

 float analog_value = analogRead(A0);
 temp = (analog_value * 5.0) / 1024.0;
input_voltage=temp/(r2/(r2+r1));
 if (input_voltage< 0.1) 
 {
input_voltage=0.0;
 } 
Serial.print("v= ");
Serial.println(input_voltage);
lcd.setCursor(0, 1);
lcd.print("Voltage= ");
lcd.print(input_voltage);
 delay(1000);
}

For the complete code for this program, download the following document.

Arduino digital voltmeter
.docx
DOCX • 13KB

NOTE: The default code present in the TinkerCAD window needs to be removed and the program code needs to be written. Download the document and copy-paste the code in #TinkerCAD to simulate the circuit.


Working:


Let us first learn how to work with TinkerCAD #simulation software. Once entered on the TinkerCAD page, select circuits, and search for the components required for the connection. The required components are to be dragged and brought to the circuiting screen. The connection needs to be made by selecting the jumper wires. Different colors of wire can be selected to distinguish between each connection.


Learn more about TinkerCad in detail.


Upload the code and start the simulation to see the output in the LCD display. The below image shows the working of the circuit after proper connection and compiling of the coding.


Working of Circuit
Working of Circuit

The Voltage reading in the numeric form is displayed on the LCD screen. The input voltage can be changed accordingly for the desired output.


Watch the working video for the practical explanation of designing the circuit and to know more about how the simulation software works.


Video By - Sri Harshita.

Simulation software plays a major role in the building of large circuits as they help to analyze the working of the circuit before it can be built practically. It helps us create a virtual design of the circuit we want to build and avoid damages to the circuit if in case we don't know, beforehand about the correct circuit connections.


For more projects through TinkerCad click here.


By using this TinkerCad open-source software design your own circuit, run the code in the software, and validate your project ideas.


See Also:

  1. Interfacing Temperature Sensor with Arduino using TinkerCAD

  2. Smart Street Light Project using Arduino UNO, LDR, and LED

  3. Light Intensity Measurement using LDR sensor and Arduino on TinkerCAD