Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » Interfacing 0-25V DC Voltage Sensor with Arduino
Arduino Projects

Interfacing 0-25V DC Voltage Sensor with Arduino

Mamtaz AlamBy Mamtaz AlamUpdated:January 24, 20251 Comment5 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
Interfacing Voltage Sensor Arduino
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview

In this tutorial, we will learn interfacing of 0-25V DC Voltage Sensor with Arduino to measure DC Voltages. Earlier, we made 0-50V DC Voltmeter to measure the output voltages & also learned about the DC−to−DC converters.

The voltage sensor module is a 0-25 DC voltage sensing device that is based on a resistive voltage divider circuit. It reduces the input voltage signal by the factor of 5 and generates a corresponding analog output voltage. This is the reason why you can measure the voltage up to 25V using the 5V analog pin of any microcontroller.

In this project we will first interface the voltage sensor module with Arduino and measure the different Battery voltages. We will then use a small 0.96″ I2C OLED Display to observe the output voltage. This voltage measurement circuit is small & portable and you can use it to detect under or over-voltage faults in electrical circuits.


Bill of Materials

The list of materials required for this project are as follows. You can purchase all the components from Amazon.

S.N.ComponentsQuantityPurchase Links
1Arduino Nano Board1Amazon | AliExpress
20-25V Voltage Sensor Module1Amazon | AliExpress
30.96" I2C OLED Display1Amazon | AliExpress
4Jumper Wires20Amazon | AliExpress
5Breadboard1Amazon | AliExpress




0-25V Voltage Sensor Module

Voltage Sensor Module

The Voltage Sensor Module is a simple but very useful module that uses a potential divider to reduce an input voltage by a factor of 5. The 0-25V Voltage Sensor Module allows you to use the analog input of a microcontroller to monitor voltages much higher than it is capable of sensing.


Features & Specifications

1. Output Type: Analog
2. Input Voltage (V): 0 to 25
3. Voltage Detection Range (V): 0.02445 to 25
4. Analog Voltage Resolution (V): 0.00489
5. Dimensions: 4 × 3 × 2 cm


Voltage Sensor Module Pinout

The voltage sensor module has 5 pins, 2 on the front side and 3 on the backside.

  1. VCC: Positive terminal of the External voltage source (0-25V)
  2. GND: Negative terminal of the External voltage source
  3. S: Analog pin connected to Analog pin of the microcontroller
  4. +: Not Connected
  5. -: Ground Pin connected to GND of microcontroller


Voltage Sensor Module Design & Construction

The Voltage Sensor is basically a Voltage Divider consisting of two resistors with resistances of 30KΩ and 7.5KΩ i.e. a 5 to 1 voltage divider. Hence the output voltage is reduced by a factor of 5 for any input voltage . The internal circuit diagram of the Voltage Sensor Module is given below.

The Arduino analog input pin accepts voltages up to 5V. Hence you can use this module easily with Arduino. If the controller has 3.3V systems, the input voltage should not be greater than 3.3Vx5=16.5V.

Arduino AVR chips have 10-bit AD, so this module simulates a resolution of 0.00489V (5V/1023), so the minimum voltage of the input voltage detection module is 0.00489Vx5=0.02445V.


Interfacing 0-25V DC Voltage Sensor Module with Arduino

Let us learn interfacing of Voltage Sensor Module with Arduino. The circuit diagram is given below.

Voltage Sensor Module Arduino

The connection is very simple. Connect the Signal (S) and Negative (-) pin of Voltage Sensor to Arduino A0 & GND pin respectively.



Source Code/Program

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Define analog input
#define ANALOG_IN_PIN A0
// Floats for ADC voltage & Input voltage
float adc_voltage = 0.0;
float in_voltage = 0.0;
// Floats for resistor values in divider (in ohms)
float R1 = 30000.0;
float R2 = 7500.0;
// Float for Reference Voltage
float ref_voltage = 5.0;
// Integer for ADC value
int adc_value = 0;
void setup()
{
   // Setup Serial Monitor
   Serial.begin(9600);
   Serial.println("DC Voltage Test");
}
void loop(){
   // Read the Analog Input
   adc_value = analogRead(ANALOG_IN_PIN);
  
   // Determine voltage at ADC input
   adc_voltage  = (adc_value * ref_voltage) / 1024.0;
  
   // Calculate voltage at divider input
   in_voltage = adc_voltage / (R2/(R1+R2)) ;
  
   // Print results to Serial Monitor to 2 decimal places
  Serial.print("Input Voltage = ");
  Serial.println(in_voltage, 2);
  
  // Short delay
  delay(500);
}

To test the working of the sensor, I used 3 different types of batteries and observed the voltage on the Serial Monitor.

Initially the sensor was tested with a 3.7V common Lithium-Ion Battery.

The Serial Monitor showed the correct reading as per the voltage of the Battery.

Similarly testing the sensor with 9V Battery also worked fined.

The voltage sensor detected the reading around 5V when tested with Discharged 3S Lithium-Ion Battery.


Making Portable Voltage Detector with OLED Display

Now let us make a portable DC Voltmeter that can measure the voltage from 0V to 25V. Earlier we made 0-50V DC Voltmeter with 7 segment LED Display. But now we will use 0.96″ OLED Display.

The following is the connection diagram for Interfacing Voltage Sensor Module & OLED Display with Arduino Board.

Voltage Sensor Module Arduino OLED Display

The connection is fairly simple. The voltage sensor module has the connection with Arduino same as earlier. But OLED Display requires 4 connections. Connect the VCC & GND Pin of OLED to Arduino 3.3V & GND pin. Similarly connect the SDA & SCL Pin of OLED to Arduino SDA & SCL Pin, i.e A4 & A5.



Source Code/Program

The code requires two libraries for OLED Display. Donwload the libraries from the following link and add it to the Library Folder of the Arduino.

1. Adafruit GFX Library: https://github.com/adafruit/Adafruit-GFX-Library
2. Adafruit SSD1306 Library: https://github.com/adafruit/Adafruit_SSD1306

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
 
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
 
// Define analog input
#define ANALOG_IN_PIN A0
 
// Floats for ADC voltage & Input voltage
float adc_voltage = 0.0;
float in_voltage = 0.0;
 
// Floats for resistor values in divider (in ohms)
float R1 = 30000.0;
float R2 = 7500.0;
 
// Float for Reference Voltage
float ref_voltage = 5.0;
 
// Integer for ADC value
int adc_value = 0;
 
void setup()
{
  // Setup Serial Monitor
  Serial.begin(9600);
  Serial.println("DC Voltage Test");
  if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS))
  {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;); // Don't proceed, loop forever
  }
  display.clearDisplay();
}
 
void loop() {
  // Read the Analog Input
  adc_value = analogRead(ANALOG_IN_PIN);
 
  // Determine voltage at ADC input
  adc_voltage  = (adc_value * ref_voltage) / 1024.0;
 
  // Calculate voltage at divider input
  in_voltage = adc_voltage / (R2 / (R1 + R2)) ;
 
  // Print results to Serial Monitor to 2 decimal places
  Serial.print("Input Voltage = ");
  Serial.println(in_voltage, 2);
 
  display.setCursor(20, 10); //oled display
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.println("Battery Voltage");
 
 
  display.setCursor(25, 30); //oled display
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.print(in_voltage, 2);
  display.println(" V");
  display.display();
  delay(500);
  display.clearDisplay();
 
}

When no Voltage source is connected to the input terminal of voltage, the OLED will display 0V output.

Similarly connecting the voltage sensor to 3 different voltage sources gives 3 different results as shown in the image below.

So this is how you can use 0-25V DC Voltage Sensor with Arduino & make your own DC Voltmeter.


Conclusion

In conclusion, the project successfully demonstrated how to interface a 0-25V DC voltage sensor module with an Arduino to measure various battery voltages. The utility of the resistive voltage divider circuit, in reducing input voltage signal by a factor of 5, was underscored. This mechanism enables accurate measurements up to 25V using a 5V analog pin.

The inclusion of a compact 0.96″ I2C OLED display for output voltage visualization enhanced usability. The circuit’s small size and portability, coupled with its ability to detect voltage faults, affirms its value in maintaining electrical circuit efficiency and safety.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticlePlayStation 5 vs Xbox Series X Compared
Next Article 12-Bit DAC Usage Guide in Arduino UNO R4 Minima

Related Posts

DC Energy Meter using Arduino

Build a DC Energy Meter using Arduino – 32V/5A

Updated:August 26, 20252K
Interfacing ADXL375 Accelerometer with Arduino

Interfacing ADXL375 Accelerometer with Arduino (±200g)

Updated:June 28, 2025
PZEM-004T Arduino Energy Meter

DIY AC Energy Meter using PZEM-004T & Arduino

Updated:March 6, 20258K
Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Updated:February 2, 20259K
Password Based Door Lock Security System Using Arduino & Keypad

Password Based Door Lock Security System Using Arduino & Keypad

Updated:February 2, 20252436K
Earthquake Detector Alarm with with Accelerometer & Arduino

Earthquake Detector Alarm with Accelerometer & Arduino

Updated:February 2, 2025661K
View 1 Comment

1 Comment

  1. Rupesh Rathod on December 21, 2022 6:04 AM

    can we use this voltage sensor for inverter battery capacity? lithium battery pack of 0-30v range ?

    Reply

CommentsCancel reply

Latest Posts
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

May 31, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

February 1, 2026
Top Posts & Pages
  • How to use INA226 DC Current Sensor with Arduino
    How to use INA226 DC Current Sensor with Arduino
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • How to use INA219 DC Current Sensor Module with Arduino
    How to use INA219 DC Current Sensor Module with Arduino
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
    ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (204)
    • ESP32 MicroPython (7)
    • ESP32 Projects (81)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.