ESP32 SG90 Mini Servo
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.
Quick Links
SG90 Price
About SG90 Mini Servo
The SG90 is a micro servo motor commonly used in small-scale robotics, RC models, and DIY electronics projects. It operates on an input voltage range of 4.8V to 6V and provides a torque of approximately 1.8 kg·cm at 4.8V. The servo supports an angular range of 0° to 180° and is controlled via PWM signals, where a pulse width of 1ms corresponds to 0°, 1.5ms to 90°, and 2ms to 180°. Compact and lightweight, the SG90 weighs around 9 grams and has dimensions of 22.8mm x 12.2mm x 28.5mm. It features nylon gears, ensuring reliability and smooth operation for lightweight tasks. The SG90 is ideal for applications requiring precise movement with minimal load.
SG90 Sensor Technical Specifications
Below you can see the SG90 Mini Servo Technical Specifications. The sensor is compatible with the ESP32, operating within a voltage range suitable for microcontrollers. For precise details about its features, specifications, and usage, refer to the sensor’s datasheet.
- Protocol: PWM
- Operating Voltage: 4.8V to 6V
- Torque: 1.8 kg·cm at 4.8V
- Operating Angle: 0° to 180°
- Pulse Width Control: 1ms (0°) to 2ms (180°)
- Dimensions: 22.8mm x 12.2mm x 28.5mm
- Weight: 9 grams
- Gear Material: Nylon
- Control Signal: PWM (50Hz)
SG90 Sensor Pinout
Below you can see the pinout for the SG90 Mini Servo. 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.
SG90 Wiring with ESP32
Below you can see the wiring for the SG90 Mini Servo with the ESP32. Connect the VCC pin of the sensor to the 3.3V pin on the ESP32 or external power supply for power and the GND pin of the sensor to the GND pin of the ESP32. Depending on the communication protocol of the sensor (e.g., I2C, SPI, UART, or analog), connect the appropriate data and clock or signal pins to compatible GPIO pins on the ESP32, as shown below in the wiring diagram.
- Connect the servo's signal wire (orange) to a PWM-capable GPIO pin on the ESP32 (e.g.,
GPIO 13
). - Connect the power wire (red) to the
5V
pin on the ESP32 or an external power source. - Connect the ground wire (brown) to the ESP32's
GND
pin and ensure it's shared with the external power source if used.
Code Examples
Below you can find code examples of SG90 Mini Servo with ESP32 in several frameworks:
ESP32 SG90 Arduino IDE Code Example
You can find the ESP32 SG90 Arduino IDE code in General Servo sensor page.
ESP32 SG90 ESP-IDF Code ExampleExample in Espressif IoT Framework (ESP-IDF)
You can find the ESP32 SG90 ESP-IDF code in General Servo sensor page.
ESP32 SG90 ESPHome Code Example
You can find the ESP32 SG90 ESPHome code in General Servo sensor page.
ESP32 SG90 PlatformIO Code Example
You can find the ESP32 SG90 PlatformIO code in General Servo sensor page.
ESP32 SG90 MicroPython Code Example
You can find the ESP32 SG90 MicroPython code in General Servo sensor page.
Conclusion
We went through technical specifications of SG90 Mini Servo, its pinout, connection with ESP32 and SG90 Mini Servo code examples with Arduino IDE, ESP-IDF, ESPHome and PlatformIO.