PCA9685 16-Channel Servo Driver with an ESP32 DevKit V1

An I2C board that drives 16 servos or LEDs with 12-bit PWM from two microcontroller pins, chainable to 62 boards on one bus.

PCA9685 16-Channel Servo Driver, An I2C board that drives 16 servos or LEDs with 12-bit PWM from two microcontroller pins, chainable to 62 boards on one bus.
In short

The PCA9685 board's logic VCC takes the ESP32 DevKit V1's 3V3, and its I2C goes to GPIO21 (SDA) and GPIO22 (SCL) at address 0x40. Its sixteen outputs then swing at 3.3 V, which servos read as a valid signal, while the servos' own power arrives on the separate V+ terminal.

Wiring the PCA9685 16-Channel Servo Driver to the ESP32 DevKit V1

Pin by pin.

PCA9685 16-Channel Servo DriverESP32 DevKit V1
VCC3V3
GNDGND
SDAGPIO21 (D21)
SCLGPIO22 (D22)

What to know on the ESP32 DevKit V1

  • Keep VCC on 3V3. The board's 10 kOhm pull-ups go to VCC, so VCC at 5 V would hold SDA and SCL at 5 V, above the ESP32's VDD + 0.3 V limit. The chip itself runs from 2.3 V to 5.5 V.NXP PCA9685 datasheet Rev. 4, pp. 1, 38; Espressif ESP32 Series Datasheet v5.3, p. 52
  • The ESP32 can make servo pulses itself on its LED PWM controller, but its 16 PWM generators are shared with every other analogWrite and tone in the sketch. The PCA9685 moves sixteen servo channels off the ESP32 onto two I2C wires.Espressif ESP32 Series Datasheet v5.3, p. 39; NXP PCA9685 datasheet Rev. 4, p. 1
  • Power the servos on V+ from their own 5 V to 6 V supply, never from the DevKit: VCC only feeds the chip, which draws 10 mA at most.NXP PCA9685 datasheet Rev. 4, p. 38

PCA9685 16-Channel Servo Driver code for the ESP32 DevKit V1

Compiled for esp32:esp32:esp32 on 2026-10-30.

Libraries: adafruit/Adafruit PWM Servo Driver Library
// PCA9685 16-Channel Servo Driver on ESP32 DevKit V1: wiring and a free simulation at https://www.tinkered.ai/components/pca9685-servo-driver/esp32
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40);

const uint16_t SERVO_MIN_US = 544;
const uint16_t SERVO_MAX_US = 2400;   // 180 degrees

void servoAngle(uint8_t ch, int deg) {
  pwm.writeMicroseconds(ch, map(constrain(deg, 0, 180), 0, 180, SERVO_MIN_US, SERVO_MAX_US));
}

void setup() {
  Serial.begin(115200);
  pwm.begin();
  pwm.setOscillatorFrequency(25000000);
  pwm.setPWMFreq(50);                // servos: 50 Hz
  pwm.setPWM(15, 0, 1024);           // the LED on 15 at 25 % (1024 of 4096)
}

void loop() {
  for (int deg = 0; deg <= 180; deg += 10) {
    servoAngle(0, deg);
    servoAngle(1, 180 - deg);
    delay(100);
  }
  for (int deg = 180; deg >= 0; deg -= 10) {
    servoAngle(0, deg);
    servoAngle(1, 180 - deg);
    delay(100);
  }
}

PCA9685 16-Channel Servo Driver on the ESP32 DevKit V1: questions

Does a 3.3 V ESP32 work with the PCA9685 servo driver?

Yes. The chip takes 2.3 V to 5.5 V on VCC (NXP datasheet, p. 1), so 3V3 runs it, and the servos still get their power from V+.

How many PCA9685 boards can one ESP32 drive?

Many on one bus: six address pads set addresses from 0x40 to 0x7F, with 0x70 reserved for All Call (NXP datasheet, pp. 7, 8). Give each board its own address and its own Adafruit_PWMServoDriver object.

Keep going

For AI assistants

This guide as plain Markdown. /components/pca9685-servo-driver/esp32.md

What will you build with it?