Embedded Networking and Communications

Week 11: Embedded Networking and Communications

🔗 Link to Group Assignment

See the Group Assignment Page for Embedded Networking and Communications.

Introduction to Communications

Communication is the foundation for interaction between devices in embedded systems. It allows multiple boards to send and receive data, synchronize actions, and share information. In this context, networking protocols define how this data is transferred and how devices understand one another. Understanding and implementing communication protocols is essential in the field of digital fabrication and robotics.

There are two major types of communications in electronics:

  • Parallel Communication: Multiple data bits are sent simultaneously over multiple wires. It is fast but requires more I/O pins and wiring complexity.
  • Serial Communication: Data is sent one bit at a time over a single wire. It is slower than parallel communication but more efficient for long distances and limited pin availability.

Within serial communication, there are several protocols:

  • UART (Universal Asynchronous Receiver-Transmitter): Uses TX and RX lines for bidirectional communication. It’s simple, requires no clock line, and is common in microcontrollers.
  • I2C (Inter-Integrated Circuit): Uses two wires (SDA for data and SCL for clock). Allows multiple devices with unique addresses to communicate on the same bus.
  • SPI (Serial Peripheral Interface): A faster protocol using four wires (MISO, MOSI, SCK, and SS). It is commonly used for sensors and displays.
  • CAN (Controller Area Network): Used in automotive and industrial environments, allows robust communication between many nodes with fault tolerance.
  • Wireless Protocols: Such as Wi-Fi, Bluetooth, LoRa, and Zigbee, used for remote communication without physical connections.

What is UART?

UART (Universal Asynchronous Receiver-Transmitter) is a hardware communication protocol used for asynchronous serial communication. It works by transmitting data serially, bit by bit, using just two wires: TX (transmit) and RX (receive). UART does not require a clock signal; instead, both devices must agree on a baud rate (bits per second) to synchronize data exchange.

It is widely used because of its simplicity, and is especially useful when two devices need to communicate directly, like in this week’s assignment.

Objective of the Week

The objective was to establish communication between two boards using the UART protocol. One board (Xiao RP2040) sends a command via UART when buttons are pressed, and the other board (Xiao ESP32S3) receives the command and controls servomotors accordingly. All programming was done using the Arduino IDE.

Download Arduino IDE

  • Xiao RP2040 Pinout: Used to connect the push buttons to pins D10, D9, and D8.
  • Xiao ESP32S3 Pinout: Used to connect RX to GPIO16 and servos to D2, D3, and D4.
  • These diagrams were essential for ensuring proper communication and motor control connections.

    Addressing and Wiring

    TX from the RP2040 is connected to GPIO16 (RX) of the ESP32S3. GND is shared between both boards to ensure a common reference voltage.

    Communication Protocol

    I used UART, a basic and reliable protocol that only requires a TX pin, RX pin, and a shared ground (GND). Both boards communicated at 9600 baud. Commands were sent as single ASCII characters:

    • L → Move servos left (180°)
    • R → Move servos right (0°)
    • S → Move servos to center (90°)

    Xiao RP2040 – Sender

    What it does:


    I used the Xiao RP2040 to read the state of three buttons. Depending on which button is pressed, it sends a single character via Serial.write() through its TX pin.

    Wiring:

    Button RP2040 Pin
    Right D10
    Left D9
    Center D8

    Code



    Xiao ESP32S3 – Receiver and Servo Control

    What it does:

    I used the Xiao ESP32S3 to receive UART commands via Serial1 on GPIO44 (RX). The board listens for characters and moves three servos connected to D2, D3, and D4. I also enabled USB Serial to print the received commands for debugging.

    Button RP2040 Pin
    Right D10
    Left D9
    Center D8

    Why I built it this way:

    I decided to split the system into input (RP2040) and output (ESP32S3) boards to keep the logic modular and clean. Sending simple one-letter commands makes the communication efficient and easy to debug. I chose GPIO44 for RX because it’s compatible with Serial1, and I kept USB serial free for monitoring. The ESP32Servo library lets me control servos with precise PWM using a range from 500 to 2500 µs, ensuring good accuracy and smooth motion.

    Code



    Result

    I successfully achieved UART communication between the two boards. Button presses on the RP2040 were correctly interpreted by the ESP32S3, and all three servos responded instantly. The system was stable and easy to debug thanks to the USB serial output showing received commands in real time.

    Problems and Fixes

    • Initially, the servos didn't move: this was due to incorrect wiring and baud mismatch.
    • The RX pin on the ESP32S3 was not correctly set: fixed by specifying GPIO16.
    • Buttons gave wrong readings: resolved using INPUT_PULLUP and checking for LOW when pressed.

    Learning Outcome

    By completing this week’s assignment, I was able to successfully establish UART communication between two embedded boards. I learned how to properly wire and configure pins for UART, send and receive serial commands, and control servomotors based on these commands. I also practiced splitting system functionality across two microcontrollers for modularity and used