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:

Development

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);
}
    
Imagen 1
Imagen 2

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.

Imagen 3

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.

```