ESP32 SG90 Mini Servo
Overview
The SG90 is a compact micro servo motor ideal for robotics and DIY projects. Operating on 4.8V to 6V, it delivers 1.8 kg·cm torque, with a 0° to 180° range controlled via PWM signals. Weighing 9g, its nylon gears and dimensions (22.8mm x 12.2mm x 28.5mm) make it perfect for lightweight, precise applications.
About SG90 Mini Servo
The SG90 is a popular micro servo motor widely used in robotics, RC models, and DIY electronics. It offers precise angular control via PWM signals, making it ideal for small-scale projects that require lightweight and reliable actuation.
⚡ Key Features
- Torque – 1.8 kg·cm at 4.8V, suitable for light-duty tasks.
- Operating Voltage – 4.8V to 6V, making it compatible with ESP32 and other microcontrollers.
- Angular Range – 0° to 180°, controlled via PWM signals.
- Compact & Lightweight – Weighs 9g with dimensions 22.8mm × 12.2mm × 28.5mm.
- Nylon Gears – Ensures smooth operation and durability for lightweight applications.
Looking for an ESP32-compatible servo motor project? Check out our ESP32 Servo Motor Guide!
Where to Buy
Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.
Technical Specifications
Pinout Configuration
The VCC
pin is used to supply power to the sensor, and it typically requires 3.3V or 5V (refer to the datasheet for specific voltage requirements). The GND
pin is the ground connection and must be connected to the ground of your ESP32.
- The servo's
GND
wire (brown) is used to complete the electrical circuit and must be connected to the ground of the ESP32 and/or the external power source. - The servo's
+5V
wire (red) supplies power to the servo motor and must receive 5 volts from the ESP32 or an external power source. - The servo's
DATA
wire (orange) carries the PWM signal to control the servo's position and should be connected to a PWM-capable GPIO pin on the ESP32.
Wiring with ESP32
Troubleshooting Guide
Common Issues
❌ Servo Not Responding or Moving Erratically
Issue: The SG90 servo does not move as expected or exhibits erratic behavior.
Possible causes include insufficient power supply, incorrect wiring, or improper PWM signal configuration.
Solution: Ensure the servo is powered by an adequate external power source, as the Arduino's 5V pin may not supply sufficient current. Verify that the control signal is connected to the correct PWM-capable pin on the microcontroller. Confirm that the PWM signal parameters match the servo's specifications, typically a 50Hz frequency with pulse widths between 1ms and 2ms corresponding to 0° to 180° positions.
🔄 Continuous Rotation Instead of Positional Movement
Issue: The SG90 servo rotates continuously instead of moving to a specified position.
Possible causes include the use of a continuous rotation servo variant or incorrect pulse width parameters.
Solution: Determine whether the servo is a standard positional servo or a continuous rotation model. For standard servos, ensure that the control pulses correspond to the correct positional commands. If using the Servo.attach()
function in Arduino, specify appropriate minimum and maximum pulse widths to match the servo's requirements.
⚡ Servo Jittering or Twitching
Issue: The SG90 servo jitters or twitches when holding a position.
Possible causes include electrical noise, unstable power supply, or interference from other components.
Solution: Use a stable and adequately rated external power supply for the servo. Implement proper grounding and consider adding decoupling capacitors to filter out electrical noise. Ensure that the control signal is clean and free from interference, and avoid running servo wires parallel to high-power lines to minimize electromagnetic interference.
🔥 Servo Overheating
Issue: The SG90 servo becomes excessively hot during operation.
Possible causes include overloading the servo, continuous operation under high torque, or mechanical binding.
Solution: Check for any mechanical obstructions or excessive loads that may cause the servo to work harder than intended. Ensure that the servo is operating within its specified torque range and duty cycle. If the application requires continuous rotation under load, consider using a servo designed for such purposes or a geared motor with appropriate specifications.
Debugging Tips
🔍 Serial Monitor
Use the Serial Monitor to check for error messages and verify the sensor's output. Add debug prints in your code to track the sensor's state.
⚡ Voltage Checks
Use a multimeter to verify voltage levels and check for continuity in your connections. Ensure the power supply is stable and within the sensor's requirements.
Additional Resources
Code Examples
Arduino Example
ESP-IDF Example
ESPHome Example
PlatformIO Example
MicroPython Example
Conclusion
The ESP32 SG90 Mini Servo is a powerful servo sensor that offers excellent performance and reliability. With support for multiple development platforms including Arduino, ESP-IDF, ESPHome, PlatformIO, and MicroPython, it's a versatile choice for your IoT projects.
For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.
Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.