π Project Overview
This project demonstrates how to build and control a 6 Degree of Freedom (6DOF) robotic arm using:
- ESP8266/ESP32 microcontroller (for Wi-Fi connectivity).
- PCA9685 16-channel PWM driver (to control multiple servo motors).
- Servo motors (6 total) to provide motion for the robotic arm.
The robotic arm is controlled wirelessly using a web interface, which allows the user to change servo angles from any device connected to the same Wi-Fi network.
π― Learning Objectives
- Understand how to control multiple servo motors with PCA9685.
- Learn how to create a web server using ESP8266/ESP32.
- Explore Wi-Fi based control of robotic systems.
- Implement basic Human-Machine Interaction (HMI) using a browser.
π§ Hardware Requirements
- ESP8266 (NodeMCU / Wemos D1 Mini) or ESP32 board
- PCA9685 16-channel Servo Driver Module
- 6 Γ Servo Motors (SG90/MG996R or similar)
- 5V External Power Supply for servos (β οΈ Do NOT power servos directly from ESP8266/ESP32 5V pin)
- Breadboard, jumper wires, and robotic arm frame
Degrees of Freedom (DOF)
- A robotic arm with 6DOF can perform movements similar to a human arm:
- Base rotation
- Shoulder movement
- Elbow movement
- Wrist pitch
- Wrist roll
- Gripper control
π Circuit Connections
ESP8266/ESP32 to PCA9685
- SDA β D2 (GPIO4 on ESP8266, or GPIO21 on ESP32)
- SCL β D1 (GPIO5 on ESP8266, or GPIO22 on ESP32)
- VCC β 3.3V / 5V (depending on board)
- GND β GND
PCA9685 to Servo Motors
- Connect each servo motorβs signal pin to PCA9685 channels 0β5.
- Provide external 5V and GND to servo power pins.
π Arduino Code
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
#include <ESP8266WiFi.h>
// ====== Wi-Fi Credentials ======
const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";
// ====== Web Server ======
WiFiServer server(80);
// ====== PCA9685 Setup ======
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40);
#define SERVOMIN 150
#define SERVOMAX 600
int servoAngles[6] = {90, 90, 90, 90, 90, 90};
int angleToPulse(int ang) {
return map(ang, 0, 180, SERVOMIN, SERVOMAX);
}
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nConnected! IP: " + WiFi.localIP().toString());
server.begin();
pwm.begin();
pwm.setPWMFreq(60);
for (int i = 0; i < 6; i++) {
pwm.setPWM(i, 0, angleToPulse(servoAngles[i]));
}
}
void loop() {
WiFiClient client = server.available();
if (!client) return;
String request = client.readStringUntil('\r');
client.flush();
if (request.indexOf("/servo") != -1) {
int chIndex = request.indexOf("ch=");
int angIndex = request.indexOf("ang=");
if (chIndex != -1 && angIndex != -1) {
int ch = request.substring(chIndex + 3, request.indexOf("&", chIndex)).toInt();
int ang = request.substring(angIndex + 4).toInt();
if (ch >= 0 && ch < 6 && ang >= 0 && ang <= 180) {
servoAngles[ch] = ang;
pwm.setPWM(ch, 0, angleToPulse(ang));
}
}
}
String html = "<!DOCTYPE html><html><head><title>6DOF Arm</title></head><body>";
html += "<h2>WiFi Controlled 6DOF Robotic Arm</h2>";
for (int i = 0; i < 6; i++) {
html += "Servo " + String(i) + ": ";
html += "<a href='/servo?ch=" + String(i) + "&ang=" + String(servoAngles[i] - 10) + "'>-</a> ";
html += String(servoAngles[i]);
html += " <a href='/servo?ch=" + String(i) + "&ang=" + String(servoAngles[i] + 10) + "'>+</a><br>";
}
html += "</body></html>";
client.print("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n");
client.print(html);
}π Working Principle
Power Supply and Initialization
- When the system is powered ON, the ESP8266/ESP32 initializes and establishes a connection to the configured Wi-Fi network.
- The PCA9685 module is initialized via the IΒ²C protocol, and all servos are moved to their neutral position (90Β°).
Web Server Operation
- The ESP8266/ESP32 runs a lightweight web server on port 80.
- The assigned IP address (shown in the Serial Monitor) acts as the access point for the robotic armβs control page.
- Any device (laptop, smartphone, or tablet) connected to the same Wi-Fi can access the interface using a browser.
User Interaction
- The web page provides + / β buttons for each of the six servo motors.
- When a button is pressed, the browser sends an HTTP request (e.g.,
/servo?ch=2&ang=120) to the ESP8266/ESP32.
Command Processing
- The ESP8266/ESP32 extracts the channel number (
ch) and target angle (ang) from the HTTP request. - The angle is converted into a corresponding PWM pulse width using the function
angleToPulse(). - The PCA9685 generates precise PWM signals, and the specified servo motor rotates to the commanded position.
- The ESP8266/ESP32 extracts the channel number (
Robotic Arm Movement
- Each servo corresponds to one joint of the robotic arm (base, shoulder, elbow, wrist, and gripper).
- Coordinated control of all six servos allows the arm to perform complex movements such as lifting, rotating, and gripping objects.
π Conclusion
This project demonstrates a practical integration of IoT and robotics by using an ESP8266/ESP32 microcontroller with a PCA9685 servo driver to control a 6DOF robotic arm wirelessly.
The working principle shows how user commands given through a web browser interface are translated into servo motor movements via PWM signals. This enables real-time control of the robotic arm without the need for wired connections.
The project highlights key engineering concepts:
- Embedded system programming
- Wi-Fi based IoT communication
- PWM signal generation and servo control
- Human-Machine Interaction through a browser
Overall, the system provides a cost-effective and flexible platform for robotics education and experimentation. With further improvements such as sliders, inverse kinematics, or AI-based automation, this design can evolve into a powerful tool for research and industrial applications.