Wildcard Week: Development of an ESP32-Based Platform for PWM Control and Line Sensor Integration
Introduction
As part of the Wildcard Week assignment, a line-following robot was designed, fabricated, and programmed using an ESP32 microcontroller and a line-tracking sensor array. The purpose of this activity was to explore and implement technologies related to PWM motor control, sensor integration, and embedded programming, which will later be applied in the development of the final project. Although the prototype built for this assignment was a functional line-following robot intended for experimentation and learning purposes, it does not represent the mechanical structure or final design of the final project. Instead, it was used as a testing platform to understand sensor behavior, evaluate motion control strategies, and gain practical experience in the integration of electronic hardware and software. During the development process, several experimental tests were carried out to analyze the system's performance and validate the operating principles of motor control and line detection. The results obtained provided valuable insights for future implementations and helped strengthen the skills and knowledge required to integrate these technologies into the final project.
Materials
The following materials were used to build the prototype:
- ESP32 Development Board
- QTR-8RC Line Sensor Array
- Mobile Robot Chassis
- DC Motors
- Motor Driver
- Wheels
- Jumper Wires
- Power Supply
- Computer for Programming and Serial Monitoring
Development
- The project began with the integration of the ESP32 and the QTR-8RC line sensor array into the robot chassis. The ESP32 was configured as the primary controller responsible for processing sensor inputs and generating the control signals required to drive the robot.
- The sensor array was connected directly to the ESP32, allowing the microcontroller to acquire data from the track surface and determine the robot's position relative to the line. } Once the electronic assembly was completed, the firmware development phase was initiated.
Software Development
The firmware was developed using the Arduino IDE and uploaded to the ESP32 development board. The program was designed to establish serial communication, process incoming commands, and monitor system behavior during testing. Through the serial interface, the robot could receive control instructions and provide debugging information, facilitating the evaluation of sensor responses and overall system performance.
The following code was used during the implementation and testing phase of the project:
// =====================================================
// ESP32 - Robot Control and Serial Communication
// =====================================================
#define RXD2 16
#define TXD2 17
String inputString = "";
// Test wheel speeds
float w1 = 0.0;
float w2 = 0.0;
float w3 = 0.0;
float w4 = 0.0;
void setup() {
Serial.begin(115200);
Serial2.begin(19200, SERIAL_8N1, RXD2, TXD2);
delay(1000);
Serial.println("==================================");
Serial.println("ESP32 Ready");
Serial.println("Available Commands:");
Serial.println("");
Serial.println("1) Send wheel velocities:");
Serial.println("I5B5C5D5F");
Serial.println("");
Serial.println("2) Send PID values:");
Serial.println("P1A1.0B0.0C0.0F");
Serial.println("P2A1.0B0.0C0.0F");
Serial.println("P3A1.0B0.0C0.0F");
Serial.println("P4A1.0B0.0C0.0F");
Serial.println("");
Serial.println("3) Request measured velocities:");
Serial.println("G");
Serial.println("==================================");
}
void loop() {
while (Serial.available()) {
char c = Serial.read();
if (c == '\n' || c == '\r') {
if (inputString.length() > 0) {
sendCommand(inputString);
inputString = "";
}
} else {
inputString += c;
}
}
while (Serial2.available()) {
char c = Serial2.read();
Serial.write(c);
}
}
void sendCommand(String command) {
Serial2.print(command);
Serial.print("Sent: ");
Serial.println(command);
}
- The firmware was successfully uploaded to the ESP32 and used during the experimental phase to monitor communication and evaluate the overall behavior of the system.
- After completing the assembly process, a series of tests were carried out on a track containing a reference line.The intended behavior was for the robot to detect the line and continuously adjust its trajectory to remain centered on the path. However, during testing, the robot consistently moved forward without performing the necessary steering corrections. Although the sensor was able to detect surface variations, the control system was unable to maintain effective line tracking.
- Following multiple test iterations and adjustments, several possible causes were identified. These included variations in ambient lighting conditions, electrical noise affecting sensor readings, insufficient sensor calibration, and sensitivity-related issues.Due to the limitations encountered, the results were documented and analyzed to support future development and optimization efforts.
Results
The project resulted in a functional experimental platform that successfully integrated the ESP32, the QTR-8RC sensor array, motor drivers, and a mobile robotic chassis. The developed system enabled the evaluation of PWM motor control strategies, sensor data acquisition, and communication between hardware and software components. Through the testing process, valuable information was collected regarding sensor behavior, motor response, and overall system integration.
Conclusion
The development of the ESP32-based line-following robot successfully demonstrated the integration of electronics, embedded programming, and digital fabrication. Beyond the performance achieved during the line-following tests, the main objective of this activity was accomplished by providing practical experience in PWM motor control, sensor data acquisition, and hardware-software integration. The experiments carried out during the testing phase helped identify challenges related to sensor calibration and control parameter adjustment, generating valuable information for future improvements. The knowledge gained through this activity will serve as a foundation for implementing control and navigation systems in the final project, although the mechanical structure and overall design used in this prototype do not correspond to the final project that will be developed later.