Repo of the Day
RobotHacker/ESP32_CAM_WebSocket_Servo_Tests
Published: Nov 23, 2023
Open repository ↗Test/example code for the ESP32-CAM to run servos via a PCA9685 servo driver over I2C
Summary
ESP32_CAM_WebSocket_Servo_Tests is Arduino sketch code that turns an ESP32-CAM board into a web-controlled servo driver. The board serves a browser-based control panel over Wi-Fi and forwards joystick or gamepad input to a PCA9685 board over I2C, which in turn moves up to 16 servos. It is explicitly described by its author as test and example code assembled from several existing open-source sketches.
What it is useful for
The repository is useful as a starting point for prototypes that need a quick web UI to drive hobby servos without writing the network or I2C plumbing yourself. The bundled pages show four different input methods wired to the same servo backend:
- Four on-screen HTML joysticks, each controlling two servos, taken from an existing joystick demo.
- An SVG-based arm view that demonstrates an inverse kinematics approach to positioning a robot arm from a web page.
- A Gamepad API page that reads a physical controller connected to the browser, so a USB or Bluetooth gamepad can drive the servos.
- A websocket transport between the browser and the ESP32, so updates are pushed both ways rather than polled.
Because the PCA9685 driver handles pulse-width modulation in hardware, the ESP32-CAM only needs two I2C pins to address all 16 channels, leaving the rest of the board's GPIO free for other peripherals later.
How engineers can use it
The README documents a clear path from blank laptop to a working rig. Engineers should first gather the listed hardware: an ESP32-CAM, a PCA9685 servo driver board, and a serial board for programming. On the software side, the steps are to install the Arduino IDE, add the ESP32 package through Boards Manager, and install the AutoConnect, WebSocket, and Adafruit PWM Servo Driver libraries. After installing the SPIFFS file uploader plugin, you compile and flash ESP32_CAM_WebSocket_ServoTests.ino and then upload the data directory to the board's SPIFFS filesystem so the HTML UI is served correctly. Once the ESP32-CAM joins a Wi-Fi network through AutoConnect's captive portal, the device's IP address exposes the control page in any browser.
The README's To Do list makes the scope clear. Camera streaming, camera tracking, persistent joystick configuration, and error handling on both the ESP32 and JavaScript sides are all listed as unfinished, so this should be treated as a reference implementation rather than a finished product.