EZ-ESP32 with Adafruit PCA9685
Hardware: Esp32 DevKit v1
Author: DJ Sures
This firmware converts a Esp32 DevKit v1 into an EZB for ARC to connect to it.
This firmware enables the ESP32 to function as an EZ-B controller for Synthiam ARC, leveraging an Adafruit 16-Channel 12-bit PWM/Servo Driver (PCA9685) for expanded servo and PWM capabilities. The ESP32 handles digital port commands, while all PWM and servo commands are offloaded to the PCA9685 via the I2C interface. This setup provides a robust and scalable solution for robotics and automation projects.
Key Features:
- I2C Integration: Connects the ESP32 to the PCA9685 over I2C, enabling control of up to 16 servos or PWM devices.
- EZ-B Functionality: Converts the ESP32 into an EZ-B controller, fully compatible with Synthiam ARC for digital, PWM, and servo commands.
- Expanded I/O: Overcomes the ESP32’s limited I/O capabilities by offloading servo and PWM tasks to the PCA9685.
How It Works:
- Digital Port Commands: Digital commands issued in ARC are processed and executed directly by the ESP32’s onboard GPIO.
- Servo and PWM Commands: ARC commands for servo positions and PWM signals are sent to the PCA9685 via I2C, allowing up to 16 channels of high-resolution control.
- Efficient Resource Allocation: By delegating servo and PWM tasks to the PCA9685, the ESP32’s GPIOs remain available for other functions.
Hardware Setup:
To connect the ESP32 to the PCA9685, use the following wiring:
| ESP32 Pin | PCA9685 Pin | |---------------------|--------------------------| | SDA (e.g., GPIO21) | SDA | | SCL (e.g., GPIO22) | SCL | | GND | GND | | VIN (3.3V or 5V) | VCC |
Prerequisites:
Arduino IDE Setup:
- Install the ESP32 board package from Espressif Systems:
https://dl.espressif.com/dl/package_esp32_index.json
- Add the necessary libraries:
- Adafruit PWM servo Driver Library (for PCA9685 control)
- Wire Library (for I2C communication)
- Install the ESP32 board package from Espressif Systems:
Hardware Configuration:
- Ensure the PCA9685 is powered correctly. For servos, connect an appropriate external power source to the PCA9685’s V+ terminal.
- Adjust the PCA9685’s I2C address if using multiple boards or to resolve address conflicts.
Firmware Features:
- Digital Commands:
- All digital commands from ARC, such as setting GPIOs high/low or reading inputs, use the ESP32's GPIO pins.
- Servo and PWM Commands:
- The PCA9685 handles all servo and PWM operations, providing:
- 12-bit resolution for precise control
- 16 independent channels for servos or PWM devices
- The PCA9685 handles all servo and PWM operations, providing:
Benefits:
- Expanded I/O: Increases the number of available PWM and servo ports without burdening the ESP32’s limited GPIOs.
- Scalable Design: Additional PCA9685 boards can be daisy-chained for even more channels.
- ARC Compatibility: Fully integrates with Synthiam ARC, allowing seamless control of digital and servo devices.
Applications:
This firmware is ideal for projects requiring precise control of multiple servos or PWM devices, such as:
- Robotic arms and manipulators
- Animatronics with synchronized servo movement
- LED lighting or motor control via PWM
Example Use Case:
With this setup, you could:
- Use the ESP32’s GPIO for sensors or switches.
- Connect up to 16 servos for controlling robotic limbs or grippers.
- Send commands from Synthiam ARC for real-time adjustments and complex behaviors.
I am using the Esp32 DevKit V.1 like stated about. What pins on the Esp32 do the Scl & Sda from the Pca9685 connect to? The picture above is not correct. I have run through the Esp32 code and still can not find it.
Thanks in advance!
Figured it out.