Skip to content

Week 11: Networking and Communications

Assignment:

  • Group: send a message between two projects.
  • Individual: design, build and connect wired or wireless node(s) with network or bus addresses and a local input and/or output device.

Group assignment

Our group work for this week is documented on the RIIDL Fab Lab group page: Week 11: Networking and Communications.

My part: the group task was to send a message between two projects. I did not complete a board-to-board communication test as part of the group work this week, so I am not claiming it here.

I wired the XIAO RP2040 board I designed and milled (Week 6, Week 8) to an ESP32 DevKit with jumper wires, so that the two boards could exchange text messages over a serial (UART) link.

My milled XIAO RP2040 board wired to an ESP32 DevKit on a breadboard

UART is a two-wire serial link. Each board's TX (transmit) pin goes to the other board's RX (receive) pin, so the wires cross over. Both boards must also share GND, so they agree on what 0 V is. There is no clock wire, so both sides must use the same speed, here 9600 baud. Both boards use 3.3 V logic, so no level shifting is needed.

XIAO RP2040 (my board) ESP32 DevKit
D6 (TX, GPIO0) GPIO16 (RX2)
D7 (RX, GPIO1) GPIO17 (TX2)
GND GND

On the ESP32 the link uses its second hardware UART (UART2), so the first UART stays free for the USB serial monitor. Messages are short text lines ending in a newline:

  • Anything typed in one board's serial monitor is sent to the other board.
  • The ESP32's BOOT button sends S. My board answers by turning its servo (D4) between 90° and 0°.
  • Touching my board's D1 to GND sends T. The ESP32 answers by toggling its on-board LED (GPIO2).

A UART link connects exactly two devices, so it needs no addresses. Addressing between nodes is covered in the ESP-NOW section below, where each ESP32 is identified by its MAC address.

What I recorded

Both boards were plugged into the laptop over USB, and a two-window serial app showed both: the XIAO on COM12 and the ESP32 on COM10.

Two serial windows: the XIAO on COM12 and the ESP32 on COM10

Time My board (XIAO, COM12) ESP32 (COM10)
23:07:13 ESP32 UART2 ready @ 9600 (RX2=GPIO16, TX2=GPIO17)
23:07:24 sent hello RX2 (GPIO16) <- hello
23:08:21 RX from ESP32: hi TX2 (GPIO17) -> hi
23:08:26 sent print RX2 (GPIO16) <- print

What this test does and does not prove

Looking back at the recording, I can't claim that these messages travelled over the jumper wires:

  • Both boards were connected to the same laptop, and the messages were shown by one laptop app. From the recording alone, the app could have carried a message from one USB port to the other without it going over the UART wires.
  • The GND wire from my board is loose in the photo and the video. A UART link needs a shared ground, so the link probably wasn't working over the wires at that moment.

So what I have shown is the wiring, the ESP32's UART2 starting up at 9600 baud, and the message format, but not a verified message over the wires.

How I would confirm it: plug in the GND wire, send hello, then pull out one TX/RX wire and send it again. If the message stops arriving when the wire is pulled, and arrives again when it is plugged back, it is really travelling over the UART link. This experiment showed me that a test only proves something if it can also fail. Here, nothing in the setup could show the difference between the wires working and not working.

Code

AI assistance: I used Claude (Anthropic's AI assistant) to help write both programs. I chose the boards and the pins and did the wiring and testing.

My networking work is a wireless link between two ESP32 WROOM boards using ESP-NOW, a peer-to-peer protocol that lets ESP32s talk to each other directly, without a Wi-Fi router. The link controls the drive robot built with my group in Week 12: Machine Design.

The two nodes

Node Role Local I/O
Transmitter (remote) Reads the user's input and sends commands Joystick / buttons (input), direction LEDs (output)
Receiver (robot) Receives commands and drives the motors L298N motor driver and DC motors (output)

alt text

How the messages are addressed

  1. The transmitter reads the joystick and button inputs.
  2. It packs the command (forward, backward, left, right) into a data structure.
  3. It sends that structure to the receiver using the receiver's MAC address, which acts as its network address.
  4. The receiver decodes the message and switches the motor driver pins (IN1–IN4) to drive the motors in the right direction.

This gives real-time, low-latency control with no router in between.

The remote controller

alt text

The controller brings together a battery holder, the joystick module, the ESP32, a power switch, and four LEDs that show the direction being sent (forward, backward, left, right).

alt text alt text

The controller circuit was designed in EasyEDA and milled as a custom PCB, replacing loose breadboard wiring with a cleaner and more reliable board.

Testing

alt text

The receiver side was tested on the bench with a regulated DC supply (~12 V) to the motor driver, while the ESP32 handled the logic signals. This confirmed the wiring and the motor response before the full robot was assembled.

The complete robot and its final result are documented in Week 12.

ESP-NOW transmitter test

Compile error from the wrongly formatted MAC address

My first attempt failed to compile because I typed the receiver's MAC address in the wrong format (MAC: EC:FA:…). In C it has to be written as a byte array: {0xEC, 0xFA, 0xBC, 0x1D, 0xBC, 0x07}.

Installing the ESP-NOW library

Serial monitor showing repeated "Delivery success"

After fixing the address, the transmitter (a NodeMCU ESP8266) sent a message every 2 seconds, and the serial monitor showed "Last Packet Send Status: Delivery success" for every packet, confirming the receiver was acknowledging the data.

Code

  • f1.ino: ESP-NOW transmitter test (ESP8266) that sends a data structure to a receiver's MAC address every 2 seconds. It is based on the lab's ESP-NOW one-way communication example, with my receiver's MAC address.