Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Arduino
80 min
Share

Measure dc voltage with arduino

If you want to measure the voltage between two points in a circuit or measure the voltage of a battery, you must use the voltage sensor module, which can measure voltage from 0 to 25 volts.

Project Video

Overview

In this tutorial, we will learn to interface the 0-25V DC voltage sensor module with Arduino and program it for voltage measurement and we will display the voltage on your computer.

Getting the Items

Arduino Uno R3 (Voltaat Version)
Get Item
Voltage Detection Module
Get Item
Energizer MAX 9V1 Battery
Get Item
9V battery adapter
Get Item
Jumper Wires – Male to Female (40 Pack)
Get Item

Steps

Wiring it Up

Connect the wires between the voltage sensor module and the Arduino, as shown in the image below.


Connections from the voltage sensor module to arduino :

• + (vcc)  → Arduino 5V pin

• - (GND) →  Arduino GND pin

• S (signal) →  Arduino pin A0

Coding


/*
Voltaat learn (http://learn.voltaat.com)
Link for full tutorial: put the link of the tutorial here

Tutorial: measure dc voltage with arduino!

The function of this sketch is to obtain the value of voltage from the voltage sensor module and display it on your computer.


Connections from the voltage sensor module to arduino :

• + (vcc)  → Arduino 5V pin

• - (GND) →  Arduino GND pin

• S (signal) →  Arduino pin A0

*/
int offset =20;// set the correction offset value

void setup() {
 Serial.begin(9600);
}

void loop() {

 int volt = analogRead(A0);// read the input
 double voltage = map(volt,0,1023, 0, 2500) + offset;// map 0-1023 to 0-2500 and add correction offset
 
 voltage /=100;// divide by 100 to get the decimal values
 Serial.print("Voltage: ");
 Serial.print(voltage);//print the voltge
 Serial.println("V");

delay(500);
 
 
}


   

Testing it Out

know when your plant needs watering

Now access the serial monitor on your Arduino IDE by clicking on the magnifying glass icon at the top right corner.

know when your plant needs watering

Now, as shown in the image below, the serial monitor displays voltage of the battery.

know when your plant needs watering

Resources

No items found.