ESP32 S3 UNO - Potentiometer Servo Motor
This ESP32 S3 Uno potentiometer servo motor tutorial shows you how to turn a knob and move a servo to the matching angle. You wire a potentiometer and a servo motor to the ESP32 S3 Uno form board, then write Arduino code that reads the knob and sets the servo position from 0° to 180°.
In this tutorial, you will:
- Wire a potentiometer and a servo motor to the ESP32 S3 Uno
- Read the potentiometer value with analogRead()
- Convert the 0 to 4095 reading into a servo angle with map()
- Control the servo motor with the ESP32Servo library

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Buy Note: For controlling multiple servo motors, use the PCA9685 16 Channel PWM Servo Driver Module to save MCU pins and simplify wiring.
Overview of Servo Motor and Potentiometer
This project joins two parts you may already know. If the servo motor or the potentiometer is new to you, learn each one first. It makes this project much easier to follow.
The servo tutorial explains the servo pins, how the angle is set, and how to power it. The potentiometer tutorial explains how the knob position becomes a voltage and an ADC value.
ESP32 S3 Uno Pinout
The picture below shows the pinout of the ESP32 S3 Uno form board. Use it to find the D9 and A0 headers and their GPIO numbers before you wire the circuit.

Wiring Diagram
You can use a classic three-pin potentiometer or a potentiometer module with a knob. Both wire the same way: the knob output goes to A0, and the servo signal goes to D9.
Wiring with a classic potentiometer

This image is created using Fritzing. Click to enlarge image
Wiring with a potentiometer module

This image is created using Fritzing. Click to enlarge image
| Component Pin | ESP32 S3 Uno Pin |
|---|---|
| Potentiometer VCC | 3.3V |
| Potentiometer GND | GND |
| Potentiometer Output | A0 (GPIO2) |
| Servo VCC (red) | 5V |
| Servo GND (brown or black) | GND |
| Servo Signal (orange or yellow) | D9 (GPIO46) |
WARNING
D9 is GPIO46 on the ESP32 S3 Uno. It is a boot strapping pin, which the chip reads at startup to choose the boot mode. A servo signal wire is usually safe here, but if the board does not boot or upload, unplug the servo signal wire from D9, upload the code, and plug it back in.
WARNING
ESP32 S3 Uno pins are NOT 5V tolerant. Power the potentiometer from 3.3V, not 5V, so its output never goes above 3.3V. The servo can still use 5V for power, because its signal wire only receives the 3.3V signal from the board.
How To Program
The whole program is just three steps that repeat again and again. Read the knob, turn the reading into an angle, then send that angle to the servo.
- Read the potentiometer. The ESP32 S3 Uno ADC is 12-bit, so the value goes from 0 to 4095. The A0 header is GPIO2.
- Scale the reading into an angle between 0 and 180.
- Move the servo to that angle.
ESP32 S3 Uno Code
The sketch below reads the potentiometer on A0 (GPIO2) every 100 ms. It maps the value to an angle, moves the servo on D9 (GPIO46), and prints both numbers to the Serial Monitor.
The code uses ESP32Servo.h instead of Servo.h, because the standard Servo library does not support ESP32 boards. It also calls analogSetAttenuation(ADC_11db) in setup(). By default, the ESP32 S3 Uno ADC can only measure a small voltage. With 11 dB attenuation, the analog pin reads the full range from 0V up to about 3.3V. Without it, the reading hits 4095 too early and the servo reaches 180° before the knob is fully turned.
Detailed Instructions
- New to the ESP32 S3 Uno? Follow ESP32 S3 Uno - Getting Started first.
- Wire it up as shown in the diagram.
- Connect the board to your computer with a USB Type-C cable.
- Open Arduino IDE, choose the ESP32S3 Dev Module board and the correct COM port.
- Install the library. Open the Library Manager, search for ESP32Servo, and install the one by Kevin Harrington.
- Copy the code above and paste it into the Arduino IDE.
- Upload the code. Click the Upload button to send the sketch to the ESP32 S3 Uno.
- Open the Serial Monitor and set the baud rate to 9600.
- Turn the knob of the potentiometer slowly from one end to the other.
- Watch the servo rotate and check the values in the Serial Monitor.
- Tip: If the servo shakes at one position, the reading may be noisy. Add a small capacitor (about 100 nF) between A0 and GND, or average a few readings in the code.
Code Explanation
Each line of the sketch has a comment that tells you what it does. Read the code from top to bottom with the comments, and the flow is easy to follow: set up the servo and the ADC once, then read, map and write in a loop.
Video Tutorial
Watch the video below to see this ESP32 S3 Uno project step by step.
Function References
These pages explain the functions used in this project in more detail. The Servo functions work the same way with the ESP32Servo library.
FAQ
Can I use the normal Servo library with the ESP32 S3 Uno?
No. The standard Servo.h library only works on AVR and some other boards. On the ESP32 S3 Uno, install the ESP32Servo library by Kevin Harrington and include ESP32Servo.h. The functions attach(), write() and read() work the same way.
Should I power the potentiometer from 3.3V or 5V?
Use 3.3V. The ESP32 S3 Uno pins are not 5V tolerant, so a potentiometer on 5V could send up to 5V into A0 and damage the pin. With 3.3V, the full knob range maps to 0 to 4095.
Why does the code call analogSetAttenuation(ADC_11db)?
It sets the ESP32 S3 Uno ADC input range to about 0V to 3.3V, so the full potentiometer signal maps to 0 to 4095. Without it, the range is smaller and the reading reaches 4095 too early. The UNO R4 does not need this line, it is for ESP32 boards only. Keep the potentiometer output at 3.3V or less.
Can I power the servo motor from the ESP32 S3 Uno 5V pin?
A small servo like the SG90 usually works from the 5V pin when the board is powered by USB. Bigger servos, or several servos, draw more current and can reset the board. In that case, use an external 5V supply and connect its GND to the board GND.
Why is the servo on D9, which is a warning pin?
D9 is GPIO46, a boot strapping pin. The wiring keeps the same D9 position as the UNO version of this project. A servo signal input usually does not disturb booting, but if you have upload or boot problems, unplug the signal wire during upload or move the servo to another PWM pin like D7 (GPIO14) and change SERVO_PIN in the code.
What if my project needs more pins than the Uno headers give?
The ESP32 S3 Uno has two extra rows of holes with more GPIOs. GPIO15 and GPIO16 are I/O, PWM and analog. GPIO45 and GPIO35 to GPIO42 are I/O and PWM. GPIO47 and GPIO48 are output only, with PWM. Solder pin headers to use them and write the GPIO number in code. For this project, a second potentiometer fits GPIO15 or GPIO16, and extra servos fit GPIO35 to GPIO42. Be careful with two things. First, GPIO47 and GPIO48 may run at 1.8V instead of 3.3V on some modules (especially ones with "V" in the name, like R8V or R16V), so 3.3V devices can be damaged or act strangely. Second, GPIO0, GPIO3 (D6), GPIO45 and GPIO46 (D9) are boot strapping pins, and a wrong connection can stop the board from booting or uploading code. Use the other extra pins first.
Troubleshooting
| Problem | Possible Cause | Solution |
|---|---|---|
| No COM port in Arduino IDE | Missing USB driver or board not in upload mode | Install the CP210x or CH340 driver, try another cable, or hold BOOT while pressing RESET |
| Upload fails or board does not boot | Servo signal on D9 (GPIO46) affects the boot strapping pin | Unplug the servo signal wire during upload, then plug it back in |
| Compile error about Servo.h | The standard Servo library does not support the ESP32 S3 Uno | Install ESP32Servo by Kevin Harrington and include ESP32Servo.h |
| Servo reaches 180 degrees before the knob is fully turned | ADC attenuation not set or potentiometer on 5V | Keep analogSetAttenuation(ADC_11db) in setup() and power the potentiometer from 3.3V |
| Servo does not move at all | Signal wire on the wrong pin or no common ground | Check the signal wire is on D9 and the servo GND is tied to the board GND |
| Board resets when the servo moves | Servo draws too much current from the board | Use an external 5V supply for the servo and share GND with the board |
| Servo jitters at a fixed knob position | Noisy analog reading | Add a 100 nF capacitor from A0 to GND or average several readings |
| Serial Monitor shows strange characters | Wrong baud rate | Set the Serial Monitor to 9600 baud |