ESP32-C3 ADC Potentiometer Meter: Wiring, Code and Simulator
To build this ESP32-C3 ADC Potentiometer Meter project you need an ESP32-C3 DevKitM-1 and a potentiometer, three 220 Ω resistors, a green LED, a yellow LED and a red LED. The ESP32-C3 ADC reads a potentiometer on IO1 (raw and eFuse-calibrated millivolts) and lights a three-LED level meter. Make the 12 connections in the wiring table, upload the MicroPython code, and turn the knob while it runs: read_u16() is the raw reading, read_uv() the calibrated voltage in microvolts.
Open this circuit in the free ESP32-C3 DevKitM-1 simulator
Parts list
| Qty | Part | What it does |
|---|---|---|
| 1 | ESP32-C3 DevKitM-1 | the microcontroller board |
| 1 | Potentiometer | VCC to 5V, GND to GND, SIG to an analog pin. Drag the knob; analogRead gives 0–1023. |
| 3 | 220 Ω resistor | Limits current. 220 Ω in series with an LED; 10 kΩ as a pull-up or pull-down. |
| 1 | green LED | Lights when A (anode, the bent leg) is high and C (cathode) is low. Use a resistor. |
| 1 | yellow LED | Lights when A (anode, the bent leg) is high and C (cathode) is low. Use a resistor. |
| 1 | red LED | Lights when A (anode, the bent leg) is high and C (cathode) is low. Use a resistor. |
Wiring
| # | From | To |
|---|---|---|
| 1 | ESP32-C3 DevKitM-1 3V3 | Potentiometer VCC |
| 2 | ESP32-C3 DevKitM-1 GND | Potentiometer GND |
| 3 | ESP32-C3 DevKitM-1 IO1 | Potentiometer SIG |
| 4 | ESP32-C3 DevKitM-1 IO2 | 220 Ω resistor (r1) leg 1 |
| 5 | 220 Ω resistor (r1) leg 2 | green LED anode (A, long leg) |
| 6 | ESP32-C3 DevKitM-1 GND | green LED cathode (C, short leg) |
| 7 | ESP32-C3 DevKitM-1 IO3 | 220 Ω resistor (r2) leg 1 |
| 8 | 220 Ω resistor (r2) leg 2 | yellow LED anode (A, long leg) |
| 9 | ESP32-C3 DevKitM-1 GND | yellow LED cathode (C, short leg) |
| 10 | ESP32-C3 DevKitM-1 IO5 | 220 Ω resistor (r3) leg 1 |
| 11 | 220 Ω resistor (r3) leg 2 | red LED anode (A, long leg) |
| 12 | ESP32-C3 DevKitM-1 GND | red LED cathode (C, short leg) |
Step by step
- Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the ESP32-C3 DevKitM-1. No install or account is needed.
- Add the parts. Add a potentiometer, three 220 Ω resistors, a green LED, a yellow LED and a red LED from the parts palette.
- Wire 1. Connect ESP32-C3 DevKitM-1 3V3 to Potentiometer VCC.
- Wire 2. Connect ESP32-C3 DevKitM-1 GND to Potentiometer GND.
- Wire 3. Connect ESP32-C3 DevKitM-1 IO1 to Potentiometer SIG.
- Wire 4. Connect ESP32-C3 DevKitM-1 IO2 to 220 Ω resistor (r1) leg 1.
- Wire 5. Connect 220 Ω resistor (r1) leg 2 to green LED anode (A, long leg).
- Wire 6. Connect ESP32-C3 DevKitM-1 GND to green LED cathode (C, short leg).
- Wire 7. Connect ESP32-C3 DevKitM-1 IO3 to 220 Ω resistor (r2) leg 1.
- Wire 8. Connect 220 Ω resistor (r2) leg 2 to yellow LED anode (A, long leg).
- Wire 9. Connect ESP32-C3 DevKitM-1 GND to yellow LED cathode (C, short leg).
- Wire 10. Connect ESP32-C3 DevKitM-1 IO5 to 220 Ω resistor (r3) leg 1.
- Wire 11. Connect 220 Ω resistor (r3) leg 2 to red LED anode (A, long leg).
- Wire 12. Connect ESP32-C3 DevKitM-1 GND to red LED cathode (C, short leg).
- Paste the MicroPython code. Paste the MicroPython code below into the code editor.
- Run it. Press Run. Turn the knob while it runs: read_u16() is the raw reading, read_uv() the calibrated voltage in microvolts.
MicroPython code
# ESP32-C3 (real chip emulation): read a potentiometer with the ADC.
# ADC1 is on IO0-IO4; this knob is on IO1. With 11 dB attenuation the input
# range is about 0-3.1 V. The LEDs on IO2, IO3 and IO5 show a 3-step level meter.
from machine import Pin, ADC
import time
knob = ADC(Pin(1), atten=ADC.ATTN_11DB)
leds = [Pin(n, Pin.OUT) for n in (2, 3, 5)]
while True:
raw = knob.read_u16() # 0..65535
mv = knob.read_uv() // 1000 # calibrated millivolts, from the chip's eFuse calibration
level = raw * 4 // 65536 # 0..3
for i, led in enumerate(leds):
led.value(i < level)
print("raw", raw, "mV", mv, "level", level)
time.sleep_ms(300)
What to try
Turn the knob while it runs: read_u16() is the raw reading, read_uv() the calibrated voltage in microvolts.
Frequently asked questions
How do I wire the ADC Potentiometer Meter project on an ESP32-C3 DevKitM-1?
Make 12 connections: ESP32-C3 DevKitM-1 3V3 to Potentiometer VCC; ESP32-C3 DevKitM-1 GND to Potentiometer GND; ESP32-C3 DevKitM-1 IO1 to Potentiometer SIG; ESP32-C3 DevKitM-1 IO2 to 220 Ω resistor (r1) leg 1; 220 Ω resistor (r1) leg 2 to green LED anode (A, long leg); ESP32-C3 DevKitM-1 GND to green LED cathode (C, short leg); ESP32-C3 DevKitM-1 IO3 to 220 Ω resistor (r2) leg 1; 220 Ω resistor (r2) leg 2 to yellow LED anode (A, long leg); ESP32-C3 DevKitM-1 GND to yellow LED cathode (C, short leg); ESP32-C3 DevKitM-1 IO5 to 220 Ω resistor (r3) leg 1; 220 Ω resistor (r3) leg 2 to red LED anode (A, long leg); ESP32-C3 DevKitM-1 GND to red LED cathode (C, short leg).
What parts do I need for this ESP32-C3 project?
An ESP32-C3 DevKitM-1 and a potentiometer, three 220 Ω resistors, a green LED, a yellow LED and a red LED.
Can I simulate this ESP32-C3 project online for free?
Yes. The BitForBytes Embedded Lab runs this exact circuit and MicroPython code in your browser for free, with no install and no hardware. The ESP32-C3 is emulated instruction by instruction on a RISC-V core running the official MicroPython firmware.
What does the code do?
The ESP32-C3 ADC reads a potentiometer on IO1 (raw and eFuse-calibrated millivolts) and lights a three-LED level meter.
More ESP32-C3 DevKitM-1 projects
- ESP32-C3 Button Interrupt + Blink: Wiring, Code and Simulator
- ESP32-C3 PWM, NeoPixel & I2C LCD: Wiring, Code and Simulator
- ESP32-C3 Wi-Fi Weather on an LCD: Wiring, Code and Simulator
- ESP32-C3 Bluetooth LE Sensor: Wiring, Code and Simulator
- ESP32-C3 SPI MAX7219 LED Matrix: Wiring, Code and Simulator