i
For More about Group Assignment
For this week's Networking and Communications assignment, I developed a communication system using two XIAO ESP32-C3 boards. The objective was to establish reliable communication between the boards while integrating a joystick as an input device and an OLED display with LEDs as output devices. The project demonstrates how data generated by one microcontroller can be transmitted and interpreted by another microcontroller in real time.
The joystick connected to the sender board was used to generate directional commands. These commands were transmitted to the receiver board, where the received data was displayed on the OLED screen and corresponding LEDs were activated. Through this implementation, I gained practical experience in embedded communication, addressing, peripheral interfacing, and debugging communication protocols.
By integrating multiple components into a unified setup, I improved my understanding of embedded systems design and the synergy between input devices, microcontrollers, and output interfaces.
The software for this project was developed using the Arduino IDE and consists of two separate programs: a sender program and a receiver program. Both programs were uploaded to XIAO ESP32-C3 development boards to establish wireless communication over Wi-Fi.
The sender board is connected to a joystick module and continuously monitors the X-axis, Y-axis, and push-button state. The analog values are read using the ESP32-C3 ADC channels and converted into directional commands such as LEFT, RIGHT, UP, DOWN, and PRESSED.
int xVal = analogRead(JOY_X);
int yVal = analogRead(JOY_Y);
if (xVal < 1000) msg = "LEFT";
else if (xVal > 3000) msg = "RIGHT";
else if (yVal < 1000) msg = "UP";
else if (yVal > 3000) msg = "DOWN";
else if (sw) msg = "PRESSED";
After determining the joystick direction, the sender board establishes a TCP connection with the receiver board through Wi-Fi and transmits the generated command as a text message. The ESP32-C3 acts as a Wi-Fi client and continuously sends updated joystick information to the receiver board.
WiFiClient client;
if (client.connect(host, port)) {
client.println(msg);
client.stop();
}
The communication takes place through a dedicated Wi-Fi network created by the receiver board. This allows wireless transmission of directional commands without requiring any additional networking hardware.
The receiver board operates as a Wi-Fi Access Point (AP) and hosts a TCP server on port 8080. The sender board connects to this access point and sends directional commands whenever joystick movement is detected.
WiFi.softAP("ESP_JOY_AP", "12345678");
WiFiServer server(8080);
server.begin();
The receiver continuously listens for incoming connections and reads the transmitted data. Once a valid command is received, it updates the OLED display and activates the corresponding directional LED.
if (data == "UP")
digitalWrite(UP_LED, HIGH);
else if (data == "DOWN")
digitalWrite(DOWN_LED, HIGH);
else if (data == "LEFT")
digitalWrite(LEFT_LED, HIGH);
else if (data == "RIGHT")
digitalWrite(RIGHT_LED, HIGH);
The received command is also displayed on the SSD1306 OLED display, providing visual confirmation that communication between the two boards has been successfully established.
display.clearDisplay();
display.setCursor(0,0);
display.println(data);
display.display();
This implementation successfully demonstrated wireless networking and communication between two XIAO ESP32-C3 boards while integrating input devices, display interfaces, and output indicators into a single embedded system. The project provided practical experience in Wi-Fi communication, TCP networking, peripheral interfacing, and real-time embedded system development.
The software was developed in a modular manner to simplify debugging and maintenance. Separate functions were used for joystick reading, communication handling, OLED updates, and LED control. This structure improved code readability and made future modifications easier.
Through this implementation, I gained practical experience in embedded programming, peripheral interfacing, communication protocols, and real-time data exchange between microcontrollers.
A critical part of this project was ensuring proper hardware addressing and communication between connected peripherals. The system consists of a XIAO ESP32-C3, an SSD1306 OLED display, a joystick module, and multiple LEDs. Verifying the addressing and pin assignments was essential to ensure reliable operation of the complete system.
The OLED display communicates using the I2C protocol and therefore requires a valid device address. Before integrating the display into the final project, an I2C scanner was used to identify the address of the connected OLED module. The scanner successfully detected the display at address 0x3C, confirming proper communication between the microcontroller and the display.
The OLED was connected using the default I2C pins of the XIAO ESP32-C3:
All GPIO pins used for LEDs and joystick inputs were individually tested before integrating the complete application. Simple test programs were used to verify that each pin responded correctly and that no pin conflicts existed within the system.
| Device | Pin |
|---|---|
| Joystick X-Axis | A0 |
| Joystick Y-Axis | A1 |
| OLED SDA | D5 |
| OLED SCL | D4 |
| UP LED | D0 |
| DOWN LED | D2 |
| LEFT LED | D3 |
| RIGHT LED | D9 |
After verifying the OLED address, GPIO assignments, and communication connections, the system operated reliably without address conflicts or communication errors.
The LEDs were assigned to digital GPIO pins on the microcontroller. The following assignments were used:
| Direction | Function | Pin Label | GPIO Number |
|---|---|---|---|
| UP | UP_LED | D0 | GPIO0 |
| DOWN | DOWN_LED | D2 | GPIO2 |
| LEFT | LEFT_LED | D3 | GPIO3 |
| RIGHT | RIGHT_LED | D9 | GPIO9 |
To avoid any hardware confusion:
The joystick's X and Y axes were connected to analog pins:
These inputs were confirmed using `analogRead()` and `Serial.print()` to verify the response to physical joystick movement. I also ensured the analog resolution matched the ESP32's default 12-bit ADC range (0 to 4095).
By verifying the I2C address using an I2C scanner, confirming GPIO pin mappings via official documentation, and testing each peripheral in isolation, I ensured the full addressing scheme worked correctly. This step was crucial to avoid overlapping resources and debugging conflicts. Proper addressing is foundational in embedded systems, especially when multiple input/output devices share the same communication bus or pin bank.
Every embedded project introduces a set of technical challenges, and this joystick-OLED-LED interface was no exception. Through iterative testing and debugging, I encountered several problems related to communication, flickering displays, unstable readings, and wiring misconfigurations. Here is a breakdown of the major problems and how they were fixed:
During the development of the networking and communication system, several challenges were encountered related to hardware connections, display communication, and input signal stability. These issues were identified through systematic testing and resolved through debugging and hardware verification.
| Problem | Cause | Solution |
|---|---|---|
| OLED Display Not Responding | Incorrect I2C wiring and address verification. | Verified SDA and SCL connections and confirmed the OLED address using an I2C scanner. |
| OLED Display Flickering | Display was being refreshed continuously inside the main loop. | Updated the display only when a direction change was detected. |
| Unstable Joystick Readings | Analog noise around the center position. | Implemented a dead-zone threshold to filter unwanted fluctuations. |
| Incorrect LED Response | GPIO pin assignments were initially mismatched. | Verified the XIAO ESP32-C3 pinout and corrected the wiring connections. |
| Communication Testing Issues | Incorrect data formatting during initial transmission testing. | Standardized the transmitted commands and verified successful reception on the receiver board. |
Resolving these issues improved the stability of the system and provided valuable experience in debugging embedded hardware, communication interfaces, and real-time input processing.