ESP32 C3 Super Mini - Servo Motor

Learn how to control a servo motor with ESP32 C3 Super Mini using PWM signals. This beginner-friendly tutorial shows you how to make a servo motor rotate between 0° and 180° with simple Arduino code.

In this tutorial, you'll learn:

ESP32 C3 Super Mini - Servo Motor

Hardware Preparation

1×ESP32 C3 Super Mini
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×Servo Motor
1×Breadboard
1×Jumper Wires
1×Optionally, DC Power Jack

Or you can buy the following kits:

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 .

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

A servo motor is a rotary actuator that allows precise control of angular position between 0° and 180°.

Key Features:

  • Standard rotation range: 0° to 180°
  • Controlled via PWM (Pulse Width Modulation) signals
  • Built-in feedback system for accurate positioning
  • Commonly used in robotics, RC vehicles, and automation projects
  • Easy to control with ESP32 C3 Super Mini

Why Servo Motors are Great for Beginners:

  • Simple three-wire connection
  • No complex motor driver required
  • Precise position control
  • Perfect for learning robotics basics

Servo Motor Pinout

The servo motor has three pins for easy connection:

  • GND pin: (brown or black) connects to GND (0V)
  • VCC pin: (red) connects to VCC (5V)
  • Signal pin: (yellow or orange) receives PWM control signal from ESP32 pin
Servo Motor Pinout

How Servo Motor Works

See How servo motor works

Wiring Diagram between Servo Motor and ESP32 C3 Super Mini

Here's how to connect your servo motor to the ESP32 C3 Super Mini board:

When powering via USB port:

The wiring diagram between ESP32 C3 Super Mini Servo Motor

This image is created using Fritzing. Click to enlarge image

Servo Motor Pin ESP32 C3 Super Mini Pin
GND (Brown/Black) GND
VCC (Red) 5V
Signal (Yellow/Orange) D10

When powering via Vin pin with external power supply:

The wiring diagram between ESP32 C3 Super Mini servo motor external power supply

This image is created using Fritzing. Click to enlarge image

※ NOTE THAT:

IMPORTANT SAFETY WARNING: When powering the ESP32 C3 Super Mini board via USB port, do NOT power the servo motor via Vin pin or VBUS pin. This can cause excessive current draw and may permanently damage your board. Use an external power supply for the servo motor if you need more power.

ESP32 C3 Super Mini Code

The following code makes the servo motor sweep from 0° to 180° and back continuously:

What the code does:

  • Initializes the ESP32Servo library
  • Attaches the servo to pin D10
  • Rotates servo from 0° to 180° in 1° increments
  • Rotates servo back from 180° to 0°
  • Repeats the sweeping motion continuously
/* * This ESP32 C3 Super Mini code was developed by newbiely.com * * This ESP32 C3 Super Mini code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-c3/esp32-c3-super-mini-servo-motor */ #include <ESP32Servo.h> #define SERVO_PIN D10 // The ESP32 C3 SuperMini pin connected to servo motor Servo servoMotor; void setup() { servoMotor.attach(SERVO_PIN); // attaches the servo on ESP32 pin } void loop() { // rotates from 0 degrees to 180 degrees for (int pos = 0; pos <= 180; pos += 1) { // in steps of 1 degree servoMotor.write(pos); delay(15); // waits 15ms to reach the position } // rotates from 180 degrees to 0 degrees for (int pos = 180; pos >= 0; pos -= 1) { servoMotor.write(pos); delay(15); // waits 15ms to reach the position } }

Detailed Instructions

  • New to ESP32 C3 Mini? Complete our Getting Started with ESP32 C3 Mini tutorial first to set up your development environment.
  • Set up Arduino IDE: If you are new to ESP32 C3 Super Mini, refer to the tutorial on how to set up the environment for ESP32 C3 Super Mini in the Arduino IDE.
  • Wire the components: Connect the servo motor to ESP32 C3 Super Mini according to the wiring diagram above.
  • Connect USB cable: Connect the ESP32 C3 Super Mini board to your computer using a USB Type-C cable.
  • Open Arduino IDE: Launch the Arduino IDE on your computer.
  • Select board and port: Choose ESP32 C3 Super Mini board and its corresponding COM port.
  • Open Library Manager: Click the Libraries icon on the left bar of the Arduino IDE.
  • Search for library: Type "ESP32Servo" in the search box.
  • Install library: Look for the servo library by Kevin Harrington and John K. Bennett, then click Install.
  • Search for ESP32Servo created by Kevin Harrington,John K. Bennett and click the Install button.
Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32C3 Dev Module
Library Manager
Type:
All
Topic:
All
ESP32Servo by Kevin Harrington,John K. Bennett
This library provides advanced PWM control for ESP32 boards using LEDC hardware, with enhanced MCPWM support on ESP32S3.
ESP32S3: 20 PWM channels (8 LEDC + 12 MCPWM) with intelligent allocation
All ESP32 variants: LEDC-based PWM with variable-frequency support
Supports variable-frequency PWM and fixed-frequency servo control
Automatic hardware fallback ensures maximum channel availability
More info
3.2.0
INSTALL
Newbiely.ino
···
1 void setup() {
Output
Serial Monitor
Ln 1, Col 1
ESP32C3 Dev Module on COM15
1
  • Copy the code: Copy the above servo motor code and paste it into Arduino IDE.
  • Upload the code: Click the Upload button to compile and upload code to ESP32 C3 Super Mini.
How to upload ESP32 C3 Super Mini code on Arduino IDE
  • Observe the result: Watch the servo motor rotate slowly 180° clockwise, then counter-clockwise repeatedly.
  • Pro Tip: Start with slow movements when testing servo motors to prevent mechanical stress and ensure smooth operation.

Line-by-line Code Explanation

The above ESP32 C3 Super Mini code contains line-by-line explanation. Please read the comments in the code!

How to Control Speed of Servo Motor

See How to Control Speed of Servo Motor

Applications and Project Ideas

Use your ESP32 C3 Super Mini servo motor setup in these practical projects:

  • Build a robotic arm with multiple servo motors for pick-and-place operations
  • Create an automatic pet feeder with timed servo-controlled dispensing
  • Design a smart door lock system controlled via WiFi
  • Make a solar panel tracker that follows the sun's position
  • Build a camera pan-tilt mechanism for surveillance or photography
  • Create an automated plant watering system with servo-controlled valves

Watch the video below for a visual walkthrough of controlling a servo motor with ESP32 C3 Super Mini.

The instruction and source code for the above video available at how to control servo motor via web tutorial

Challenge Yourself

Take your ESP32 C3 Super Mini servo motor skills to the next level:

  • Easy: Modify the code to sweep the servo between 45° and 135° instead of 0° to 180°
  • Easy: Change the delay time to make the servo move faster or slower
  • Medium: Add a button to control when the servo moves instead of continuous sweeping
  • Medium: Control multiple servo motors simultaneously from one ESP32 C3 Super Mini
  • Advanced: Create a web interface to control servo position remotely via WiFi
  • Advanced: Build a joystick-controlled servo system using analog input

Learn More

※ 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!