Introduction: How to Control the Serial Servo Motor Using the OpenCV and ESP32 Microcontroller
YouTube Video:
https://youtube.com/shorts/yfd6txKc3kE
Step 1:
GET YOUR ESP32:
Here i am using an ESP32-Wroom board as microcontroller that Serial Data from the Computer and send that data to the Servo motor to move through the Servo driver Below,
Step 2:
This is the main linker that help the servo to work and helping sending the signal to correct servo motor based on its unique #ID by default the ID of all servos are set to #ID 1 so if you want to control the multiple servo motors then please assign different #IDs to them.
this code here will help you change the ID of the servos easily here :
PINS Connection:
Tx of servo driver ---------> RX2 of Esp32 or GPIO 16
RX of servo Driver ---------> TX2 of Esp32 or GPIO 17
VCC of servo driver ---------> VCC of Esp32
GND of servo driver --------> GND of Esp32
here in ESP32 there are two serial pins so be careful to connect the RX and TX to serial1 or GPIO 16 (RX) and GPIO 17 (TX) are used for connection of the servo driver not the primary ones.
once done:
Step 3:
UPLOAD THIS CODE:
Step 4:
Upload these Code here:
Then Copy Past This Python Code here and Run it in any Code Editors you wanna use :
also Download these Dependencies here:
📦 Python Libraries (Install using pip)
1. OpenCV
For webcam access & image processing
2. Mediapipe
For face mesh tracking
3. NumPy
For mathematical calculations
4. PySerial
For sending servo data to ESP32 over USB
before that select the correct serial port and and exact baud rate you have selected for esp32 to communicate it with.
and thats it when your web cam starts you will see you servos responding accordingly based on your head yaw and roll..
if you like this project please left and heart here ..
its my first post so i am very open for suggestions and typos
i am vikas
i Love Robotics... ; )
byee....


