ESP32 S3 - Measure Voltage

In this guide, you will learn how to measure voltage ranging from 0 V to 16.5 V using a voltage sensor with an ESP32 S3. We will walk through the wiring, the code, and each step in detail so you can follow along even if you are new to the platform.

ESP32 S3 - Measure Voltage

What you'll build:

  1. A circuit connecting a voltage sensor to the ESP32 S3
  2. Code that reads the raw ADC value from the sensor output
  3. A voltage conversion that maps the ADC reading to real volts
  4. Serial Monitor output that displays live voltage readings

Hardware Preparation

1×ESP32 S3 WROOM N16R8
1×Alternatively, ESP32 S3 SuperMini Dev Module
1×Alternatively, ESP32 S3 Uno-form Board
1×Alternatively, ESP32 S3 Camera Board
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×Voltage Sensor
1×Jumper Wires
1×Recommended: Screw Terminal Expansion Board for ESP32 S3
1×Recommended: Breakout Expansion Board for ESP32 S3
1×Recommended: Power Splitter for ESP32 S3

Or you can buy the following kits:

1×DIYables ESP32 S3 Starter Kit (ESP32 S3 included)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of Voltage Sensor

A voltage sensor is a ready-made voltage divider circuit that uses specific resistors to make measuring voltage straightforward. It contains two resistors — 30 kΩ and 7.5 kΩ — that scale down the input voltage to a level your ESP32 S3's ADC can safely read. When the ADC reference voltage is 3.3 V, the sensor can measure voltages from 0 V to 16.5 V DC.

Key Specifications

  • Input voltage range: 0 V to 25 V DC (with 5 V ADC reference) / 0 V to 16.5 V DC (with 3.3 V ADC reference)
  • Resistor divider: 30 kΩ (R1) and 7.5 kΩ (R2)
  • Output voltage: proportional to the input, scaled to fit the ADC range

Pinout

A voltage sensor comes with two groups of pins. The input interface connects to the circuit you want to measure, while the output interface connects to the ESP32 S3.

  1. VCC pin (input): Connect to the positive (higher voltage) measurement point.
  2. GND pin (input): Connect to the negative (lower voltage) measurement point.
  3. Vout / S pin (output): Connect to an ADC-capable GPIO on the ESP32 S3.
  4. NC / + pin (output): Do not connect — this pin is unused.
  5. GND / - pin (output): Connect to the GND on the ESP32 S3.
Voltage Pinout
image source: diyables.io

Wiring Diagram

Connect the voltage sensor to your ESP32 S3 using jumper wires as shown in the diagram below. Make sure the Vout pin of the sensor goes to an ADC-capable GPIO so the ESP32 S3 can read the scaled voltage accurately.

The wiring diagram between ESP32 S3 Voltage Sensor

This image is created using Fritzing. Click to enlarge image

Safety Notes

The voltage sensor output is already scaled for the ESP32 S3's 3.3 V ADC input, so do not exceed 16.5 V on the sensor's input pins. Always double-check your wiring before applying power to avoid sending over-voltage to the ADC pin.

Voltage Sensor PinESP32 S3 Pin
Vout (S)GPIO1 (or any ADC-capable GPIO)
GND (-)GND

ESP32 S3 Code

Reading voltage with the ESP32 S3 involves sampling the ADC, applying the sensor's divider ratio, and printing the result to the Serial Monitor. The following code performs all three steps and outputs a new measurement every second.

/* * This ESP32 S3 code was developed by newbiely.com * * This ESP32 S3 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-s3/esp32-s3-measure-voltage */ /* * This ESP32-S3 code is created by esp32io.com * * This ESP32-S3 code is released in the public domain * * For more detail (instruction and wiring diagram), visit https://esp32io.com/tutorials/esp32-s3-measure-voltage */ #define ANALOG_IN_PIN 3 // ESP32-S3 pin GPIO3 (ADC0) connected to voltage sensor #define REF_VOLTAGE 3.3 #define ADC_RESOLUTION 4096.0 #define R1 30000.0 // resistor values in voltage sensor (in ohms) #define R2 7500.0 // resistor values in voltage sensor (in ohms) void setup() { Serial.begin(9600); // set the ADC attenuation to 11 dB (up to ~3.3V input) analogSetAttenuation(ADC_11db); } void loop() { // read the analog input int adc_value = analogRead(ANALOG_IN_PIN); // determine voltage at adc input float voltage_adc = ((float)adc_value * REF_VOLTAGE) / ADC_RESOLUTION; // calculate voltage at the sensor input float voltage_in = voltage_adc * (R1 + R2) / R2; // print results to serial monitor to 2 decimal places Serial.print("Measured Voltage = "); Serial.println(voltage_in, 2); delay(500); }

Detailed Instructions

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Connect the ESP32 S3 to the voltage sensor as shown in the wiring diagram.
  3. Connect the ESP32 S3 board to your PC via a USB cable.
  4. Open Arduino IDE on your PC.
  5. Select the right ESP32 S3 board and COM port in Arduino IDE.
  6. Copy the above code and paste it into the Arduino IDE.
  7. Press the Upload button in Arduino IDE to compile and upload the code to the ESP32 S3.
Arduino IDE Upload Code
  1. Open the Serial Monitor in Arduino IDE.
How to open serial monitor on Arduino IDE
  1. Test by measuring 5 V and 3.3 V on the ESP32 S3 board.
  2. Observe the readings in the Serial Monitor.
  3. Pro Tip: Compare the displayed value against a known reference voltage (such as the ESP32 S3's 3.3 V rail) to quickly gauge the accuracy of your setup.

Serial Monitor

After uploading, the Serial Monitor will display a new voltage measurement each second. The following readings were captured in 2026 while measuring the ESP32 S3's 5 V and 3.3 V rails:

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32S3 Dev Module' on 'COM15')
New Line
9600 baud
[2026-06-16 10:00:01] Measured Voltage = 4.93 [2026-06-16 10:00:02] Measured Voltage = 4.93 [2026-06-16 10:00:03] Measured Voltage = 3.42 [2026-06-16 10:00:04] Measured Voltage = 3.42
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

※ NOTE THAT:

You might notice that the measurement result is slightly different from the actual value. The code uses the analogRead() function to read values from the ADC connected to the voltage sensor. The ESP32 S3 ADC is suitable for projects that do not require high accuracy. For projects needing precise measurements, note:

  • The ESP32 S3 ADC is not perfectly accurate and may need calibration. Each board can behave slightly differently.
  • Calibration can be challenging for beginners and may not always yield exact results.

For high-precision projects, consider using an external ADC (e.g. ADS1115) with the ESP32 S3. If you still want to calibrate the ADC, refer to ESP32 ADC Calibration Driver.

Applications

Voltage measurement opens the door to a wide range of real-world monitoring and protection tasks with the ESP32 S3. Some practical applications include:

  1. Battery level indicator: Monitor a LiPo or lead-acid battery's state of charge and display it on an OLED or LED bar graph.
  2. Power supply monitoring: Continuously check a DC rail and trigger an alert if the voltage drops below a safe threshold.
  3. Solar panel monitoring: Track the output voltage of a solar panel to log energy generation data over time.
  4. Load testing: Measure the voltage drop across a load to calculate current draw and detect faults.
  5. Automotive diagnostics: Read a 12 V car battery voltage through the sensor's divider and warn when the battery is weak.

Video Tutorial

Watch the step-by-step video walkthrough for this ESP32 S3 project below.

Challenges

Now that you have a working voltage measurement circuit on the ESP32 S3, try extending the project with these exercises to deepen your understanding.

  1. Beginner: Change the GPIO pin used for the voltage sensor signal and update the code accordingly, then verify that the readings still display correctly.
  2. Intermediate: Add a threshold check in the code so that the ESP32 S3 lights up an LED when the measured voltage drops below a user-defined minimum value.
  3. Advanced: Log voltage readings to an SD card or send them over Wi-Fi to a web dashboard, creating a simple remote voltage monitoring system.

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!