Fab Academy 2025

@ Fab Lab Rwanda, Kigali

Embedded Networking and Communications

Embedded Networking and Communications


Week 11 - Getting Two Boards to Talk

What we had to do

This week we needed to send a message between two boards. Sounds simple enough, right?
Well, it took us a few tries to get it working properly, but we figured it out in the end!

What we decided to build

We wanted to make something pretty cool - press a button on one board and have LED light up on an other board. The idea was to use two XIAO RP2040 board and Arduino uno board and make them communicate using serial communication (UART). We thought this would be easier than trying to do wireless stuff, and honestly, we were right!

How we made them talk - UART Serial

Instead of going with WiFi or Bluetooth (which seemed complicated), we decided to use good old UART serial communication. It's basically like having a conversation between two boards using just two wires. Pretty neat actually!

First XIAO board
Board 1 - This one sends the message
Second XIAO board
Board 2 - This one receives

How UART works (in simple terms)

Think of it like walkie-talkies, but with wires:

Building the hardware

We used our custom XIAO RP2040 board from previous weeks and the existing Arduino uno.

How we wired everything

Board 1 Pin Board 2 Pin What it does
TX (Pin 0) RX (Pin 1) Board 1 talks to Board 2
RX (Pin 1) TX (Pin 0) Board 2 talks back to Board 1
GND GND Shared ground (super important!)
LED on 13 LED on 13 LED that light up
Button on D3 Button on D3 Button to press

Writing the code

The programming part was actually pretty straightforward once we figured out the logic. Both boards run almost the same code, just with tiny differences.

The basic setup stuff

void setup() {
  Serial1.begin(9600);
  pinMode(D2, INPUT_PULLUP);
}

void loop() {
  if (digitalRead(D2) == LOW) {
    Serial1.write('a');  // Send trigger signal
    digitalWrite(LED_BUILTIN, HIGH);  // Local LED on
    delay(20);  // Debounce
  } else {
    digitalWrite(LED_BUILTIN, LOW);
  }
}

Setting up the communication

#include 
SoftwareSerial mySerial(10, 11);  // RX on 10

void setup() {
  pinMode(13, OUTPUT);
  mySerial.begin(9600);
}

void loop() {
  if (mySerial.available() && mySerial.read() == 'a') {
    digitalWrite(13, !digitalRead(13));  // Toggle LED
  }
}

Testing (and debugging!)

Let's be honest - it didn't work the first time. We had to debug a few things:

  1. First attempt: forgot to cross the TX/RX wires (oops!)
  2. Second try: had different baud rates on each board
  3. Third time: forgot the common ground connection
  4. Fourth attempt: SUCCESS! The LED lit up when we pressed the button
Our final working setup
Final setup that actually worked
Testing the button press
The moment of truth - pressing the button!

The big demo!

When we finally got it working, it was pretty satisfying. Press one button on the other board, the LED light up which is connected to the other board. The communication was fast and reliable.

Our working demo - the LED responding to one button press on different board!

What we discovered

Things that worked really well:

Important lessons we learned:

Why we chose UART over other options

Communication Method Good stuff Not so good stuff
UART (what we used) Simple, reliable, fast, low power Need wires, short distance only
ESP-NOW No wires, works far apart Way more complicated, need ESP32 boards
I2C Can connect many devices More complex addressing system
SPI Super fast Need more wires, overkill for our project

What we learned

This project taught us a lot about communication between microcontrollers:

Overall, this was a really fun project! We managed to get two boards talking to each other using serial communication. It might not be as fancy as wireless, but it's reliable and easy to understand. Plus, seeing both LEDs light up when you press one button never gets old!

Pro tip: Always check your wiring twice before blaming the code. We learned this the hard way!

Instructor

Contacts

  • Map
  • +250 781 187 555