i
  1. Week 1 : Project Management
  2. Week 2 : Computer-aided
  3. Week 3 : Computer Controlled Cutting
  4. Week 4 : Embedded Programming
  5. Week 5 :3D Scanning and Printing
  6. Week 6 : Electronic Design
  7. Week 7 : Computer Controlled Machining
  8. Week 8 : Electronics Production
  9. Week 9 : Input Devices
  10. Week 10 : Output Devices
  11. Week 11 : Networking and Communication
  12. Week 12 : Mechanical Design and Machine Design
  13. Week 14 : Molding and Casting
  14. Week 15 : Interface and Application Programming
  15. Week 16 : System Integeration
  16. Week 17 : Wildcard Week
  17. Week 18 : Applications and Implications, Project Development
  18. Week 19 : Invention, Intellectual property and Income
  19. Week 20 : FInal Project Requirements

Week 11: Networking and Communications

Objectives of the Week

  • Linked to the group assignment page
  • Documented your project and what you have learned from implementing networking and/or communication protocols.
  • Explained the programming process(es) you used.
  • Ensured and documented that your addressing for boards works
  • Outlined problems and how you fixed them.
  • Included design files (or linked to where they are located if you are using a board you have designed and fabricated earlier) and original source code.
  • Included a 'hero shot' of your network and/or communications setup

  • Group Assignment Contribution

    For More about Group Assignment

    Individual Assignment Contribution

    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.

    Programming Process Used

    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.

    Sender Board Programming

    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.

    Receiver Board Programming

    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();
                

    Communication Workflow

    1. The joystick position is read by the sender XIAO ESP32-C3.
    2. The analog values are converted into directional commands.
    3. The command is transmitted wirelessly through Wi-Fi using TCP communication.
    4. The receiver XIAO ESP32-C3 accepts the incoming connection.
    5. The received command is processed by the receiver board.
    6. The OLED display is updated with the received direction.
    7. The corresponding LED is activated to indicate the received command.

    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.

    Program Structure

    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.

    Address Verification

    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.

    OLED Address Verification

    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:

    GPIO Address Verification

    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.

    LED GPIO Addressing

    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:

    Joystick Analog Input Addressing

    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.

    Joystick Analog Input Addressing

    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:

    Problems Faced and Solutions

    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.

    Hero Shot

    Learning Outcomes

    Finally Leaving my files here

    Sender end code

    Reciever end code