Interface Voltage sensor with Arduino Uno | Voltage Measure using Arduino

Hey guys. welcome back to the Techatronic. In this tutorial we are going to interface a very useful and unique sensor which is Voltage sensor. Interface Voltage sensor with Arduino Uno can help us in many projects where we need to monitor the battery voltage and power supply voltage. That’s why we have made this activity tutorial. The voltage sensor is very common sensor and very easy to use. only we need to connect the sensor to the Arduino analog input.

Voltage sensor having a voltage divider circuit to measure the voltage. and we can measure here voltage upto 25 DC Voltage. This sensor is easily connect to the programmer. Also, we are going to display the voltage reading to the OLED display so, the part of the OLED display also have included. we have made many tutorial on how to oled connected to the Arduino.

HTML Image as link
Qries

If you have to write on the OLED display. just learn and apply the method to the project and you will find all the details here. We are using the smallest OLED display here with the Project. All the details about the Voltage we are showing into the Display. We have more tutorial on this OLED display with Arduino.

Voltage Sensor:-

Voltage sensor is a device which is used to measure the voltage. there are two types of voltage sensor first is non contact and the other is contact. We are using the contact base. there we need to attach two wires parallel to the voltage source and there is a signal pin which can give us the output.

Voltage sensors are widely used in power management, industrial automation, electrical safety systems, and electronic devices. we will use this sensor into our vehicle project where we need to measure the voltage of vehicle battery.

Working Principle:- Voltage sensors works on different principles, such as resistive dividers, capacitive coupling, or electromagnetic induction. The sensor detects the voltage, processes it, and converts it into an output signal (analog or digital) that represents the voltage level. But this sensor is working on Voltage Divider circuit in which you can see the two resistor.

So, it is easy to use that’s why we interface the voltage sensor with Arduino.

Applications of Voltage Sensors

  • Power Monitoring – Voltage sensors used in electrical grids to monitor power supply levels.
  • Battery Management Systems – Voltage sensors are using in measuring battery voltage in electric vehicles and backup power systems.
  • Renewable Energy Systems – Monitors voltage levels in solar panels and wind turbines.
  • Industrial Automation – Ensures proper voltage levels in machines and control systems.

Advantages of Voltage Sensors

  • High accuracy in voltage measurement
  • Safety in electrical fault detection
  • Compact and cost-effective
  • Wide range of applications in electronics and electrical engineering

Now, how can we make this Interface Voltage sensor with Arduino , and whats the material required. First of all we required some material , then we need to make a circuit diagram of Voltage sensor with Arduino Uno |and then we need to write a code which can work with the Voltage sensors.

Required Material:-

  • Arduino nano
  • OLED 1306
  • Breadboard
  • Jumper wire
  • Voltage Sensor
Componenets Name Buy Link
Arduino nanoBUY LINK
OLED 1306BUY LINK
BreadboardBUY LINK
Jumper wireBUY LINK
Voltage SensorBUY LINK

Interface Voltage sensor with Arduino Circuit diagram

Interface Voltage sensor with Arduino Circuit diagram

Here is the Circuit diagram given for Voltage sensor with Arduino

Here are some steps fro how to connect the wires.

Connect Volateg sensor Vcc to the Arduino 5v

Connect Voltage sensor Gnd to the Arduino Gnd

Connect Voltage sensor Signal pin to the Arduino A0 pin

Connect Oled Vcc to the Arduino 5v pin

Connect Oled gnd to the Arduio gnd

Connect OLED SDA pin to the Arduino A4 pin

Connect OLED SCL pin to the Arduin A5 pin.

Makew sure the power is switch off during the connections.m

Voltage sensor with Arduino Code

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET    -1
#define SCREEN_ADDRESS 0x3C

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define VOLTAGE_SENSOR_PIN A0
#define REF_VOLTAGE 5.0  // Reference voltage of Arduino (5V or 3.3V)
#define VOLTAGE_DIVIDER_RATIO 5.0 // Adjust based on resistor values used

void setup() {
    Serial.begin(9600);
    if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
        Serial.println(F("SSD1306 allocation failed"));
        for (;;);
    }
    display.clearDisplay();
    display.setTextSize(2);
    display.setTextColor(WHITE);
}

void loop() {
    int sensorValue = analogRead(VOLTAGE_SENSOR_PIN);
    float voltage = (sensorValue * (REF_VOLTAGE / 1023.0)) * VOLTAGE_DIVIDER_RATIO;
    
    Serial.print("Voltage: ");
    Serial.print(voltage);
    Serial.println("V");
    
    display.clearDisplay();
    display.setCursor(10, 20);
    display.print("Voltage:");
    display.setCursor(10, 40);
    display.print(voltage);
    display.print("V");
    display.display();
    
    delay(1000);
}

Here we have shared the code too. First you need to the make the circuit according to the diagram and then upload the code into the arduino with the help of arduino ide.

There is two terminal in the Voltage sensor in the form of port. one is positive and other is negative. you need to connect the wires carefully. These two wires connect the source voltage for that we need to measure the voltage. it can measure upto 25v which enough for most of the electronic DC device. There is a resistor divider circuit inside the voltage sensor which help us to find the voltage at the signal pin in the form of analog data. then we need some manupulation in the data. we discover the formula to calculate the voltage here we given.

sensorValue * (REF_VOLTAGE / 1023.0)) * VOLTAGE_DIVIDER_RATIO

From the above ewquation we can find the voltage of source.

I hope you learn a lot from this article still if you have any doubt you can ask us in the comment section.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top