Wildcard week: development of a line follower system for a robotic platform based on ESP32.

Introduction

As part of the Wildcard Week assignment, a line-following system was designed and adapted to a robotic platform using an ESP32 microcontroller and a set of line-following sensors. The purpose of this activity was to explore and implement technologies related to the autonomous control of robots, in this case, using a line-following system for navigation around the university campus. For this experiment, a robotic platform was used to which the line-following subsystem was adapted to understand the behavior of the sensors, evaluate motion control strategies, and gain practical experience in the integration of electronic hardware and software. During the development process, several experimental tests were conducted to analyze the system's performance and validate the operating principles between motor control and line detection. The results obtained provided valuable information for future implementations and helped strengthen the skills and knowledge necessary to integrate these technologies into the final project.

Materials

The following materials were used to build the prototype:

Development

Code Development

The code 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 an experimental platform integrating the ESP32, the QTR-8RC sensor array, motor controllers, and the robotic chassis. However, the system failed to achieve full functionality due to limitations in data acquisition; the color and reflectivity of the ground prevented the sensors from accurately detecting the change in contrast between the line and the surface. Despite this, the testing process provided valuable insights into the sensor's sensitivity in different environments and the challenges of hardware integration.

Imagen 3

Conclusion

The development of the experimental ESP32-based robot successfully demonstrated the integration of electronics, Embedded Programming, imputs and outputs fulfilling the primary objective of providing hands-on experience in PWM motor control and systems integration. After evaluating the prototype's performance, it was determined that the QTR-8RC sensor array would not be used in the final implementation due to contrast limitations detected in the test environment. Instead, the system will evolve toward a machine vision-based solution. The knowledge gained in this phase will serve as the foundation for the final project's navigation, although the mechanical structure and design of this prototype will be completely redesigned to accommodate the new image capture and processing system.

Download files
← Main Page
```