How to wire a potentiometer to an ESP32-S3
To wire a potentiometer to an ESP32-S3, connect 1 to 3V3, 2 to GPIO 1 and 3 to G. Run the pot from 3.3 V, never from the 5 V pin, so the wiper can never put more than 3.3 V on an analog input. The sketch below uses no library beyond what the board includes. It reads the wiper and prints the raw reading and a percentage.
- 3.3 V logic
- Library: none
- 3 wires
Potentiometer to ESP32-S3 wiring table
Every wire in the circuit above, with the part’s pin names and the board’s own labels. The wire colors are the ones the circuit uses; on a real bench any colors work.
| Potentiometer pin | ESP32-S3 pin | Wire color | Why |
|---|---|---|---|
| Pin 1 (one end) | 3V3 | red | The top of the ADC’s range is 3.3 V, so the pot spans 0 to 3.3 V. |
| Pin 2 (wiper) | GPIO 1 | amber | The middle leg: a voltage between the two ends, set by the shaft. |
| Pin 3 (other end) | G | blue | The bottom of the range. |
Power and logic levels for potentiometer and ESP32-S3
Logic level
The ESP32-S3’s GPIO pins are 3.3 V logic and are not 5 V tolerant. Nothing wired to a pin may go above 3.3 V.
Supply
The potentiometer takes 3.3 V from 3V3. That pin is the ESP32-S3’s own regulated 3.3 V output.
This pair
Run the pot from 3V3, never from 5V: turned to the top, the wiper would put 5 V on an analog input rated for 3.3 V. ADC1 is GPIO 1 to 10: twelve bits, 0 to 4095, with a full scale near 2.9 V at the default attenuation.
Pins to leave alone
GPIO 19 and 20 are the USB port’s data lines, GPIO 35 to 37 belong to the PSRAM on octal-PSRAM boards such as the N8R8, and GPIO 0, 3, 45 and 46 are strapping pins.
The working code for the ESP32-S3
Library: none, the sketch reads the wiper with analogRead(). This is the sketch the circuit above runs.
const int POT_PIN = 1; // the wiper, GPIO 1
void setup() {
Serial.begin(115200);
}
void loop() {
int raw = analogRead(POT_PIN); // 0 to 4095
int percent = map(raw, 0, 4095, 0, 100);
Serial.print("Raw: ");
Serial.print(raw);
Serial.print(" Percent: ");
Serial.println(percent);
delay(200);
}
What you should see
Open the serial monitor at 115200 baud and turn the knob: each line shows the raw reading and a percentage that follow it. ADC1 is GPIO 1 to 10: twelve bits, 0 to 4095, with a full scale near 2.9 V at the default attenuation.
A reading that jumps around or stays at zero means the wiper is not on the analog pin, or the outer legs are not on power and ground.
The serial monitor prints this, recorded from the circuit above with the knob at its middle:
Raw: 2218 Percent: 54Common mistakes wiring a potentiometer to an ESP32-S3
Using a pin without an ADC
Only GPIO 1 to 10 reach ADC1 on the ESP32-S3. analogRead() on any other pin returns 0, which looks like a broken pot.
Wiring the wiper to an end
The middle leg is the wiper. With an end leg on the analog pin the reading never moves, or jumps from 0 to the top at one end of the travel.
Running the pot from 5V
At the top of the travel the pin would see 5 V, above the ESP32-S3 (Xtensa LX7)’s rating. The pot belongs on 3V3.
Build your own potentiometer project
Open this circuit in the editor, change the wiring or the code, and keep your version in a free account.