Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32 and 16-Channel PWM Servo Driver for Multi-Servo Control

View and Edit Project In Cirkit DesignerImage of ESP32 and 16-Channel PWM Servo Driver for Multi-Servo Control

Circuit Documentation

Summary

This circuit is designed to control multiple servos using an ESP32 microcontroller and a 16-Channel PWM Servo Driver. The ESP32 communicates with the PWM driver via I2C to control the position of the servos. Power is supplied through a 2.1mm Barrel Jack with Terminal Block.

Component List

  1. ESP32 (30 pin)

    • Description: A powerful microcontroller with built-in Wi-Fi and Bluetooth capabilities.
    • Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, Vin, D23, D22, TX0, RX0, D21, D19, D18, D5, TX2, RX2, D4, D2, D15, 3V3
  2. 16-Channel PWM Servo Driver

    • Description: A driver board that can control up to 16 servos using PWM signals.
    • Pins: V+, VCC, SDA, SCL, OE, GND, Vin+, Vin-, PWM1, PWM2, PWM3, PWM4, PWM5, PWM6, PWM7, PWM8, PWM9, PWM10, PWM11, PWM12, PWM13, PWM14, PWM15, PWM16
  3. 2.1mm Barrel Jack with Terminal Block

    • Description: A power input jack for connecting an external power supply.
    • Pins: POS, NEG
  4. Servo (Wokwi Compatible)

    • Description: A standard servo motor compatible with Wokwi simulation.
    • Pins: GND, V+, PWM

Wiring Details

ESP32 (30 pin)

16-Channel PWM Servo Driver

2.1mm Barrel Jack with Terminal Block

Servo (Wokwi Compatible)

Documented Code

ESP32 Code

/*
 * This Arduino Sketch is for controlling multiple servos using an ESP32 and a
 * 16-Channel PWM Servo Driver. The ESP32 communicates with the PWM driver via
 * I2C to control the position of the servos.
 */

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

void setup() {
  Serial.begin(115200);
  Serial.println("Initializing PWM Servo Driver...");
  Wire.begin(21, 22); // SDA, SCL pins
  pwm.begin();
  pwm.setPWMFreq(60); // Analog servos run at ~60 Hz updates
}

void loop() {
  // Example: Sweep servos connected to PWM channels 0, 1, and 2
  for (uint16_t pulselen = 150; pulselen < 600; pulselen++) {
    pwm.setPWM(0, 0, pulselen);
    pwm.setPWM(1, 0, pulselen);
    pwm.setPWM(2, 0, pulselen);
    delay(10);
  }
  for (uint16_t pulselen = 600; pulselen > 150; pulselen--) {
    pwm.setPWM(0, 0, pulselen);
    pwm.setPWM(1, 0, pulselen);
    pwm.setPWM(2, 0, pulselen);
    delay(10);
  }
}

16-Channel PWM Servo Driver Code

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

This documentation provides a comprehensive overview of the circuit, including a summary, component list, wiring details, and the code used for the microcontrollers.