Week 11
Networking and Communications
Contents
Starting Point
This week focuses on networking and communications, a topic that is deeply integrated into our daily lives. From mobile phones and Wi-Fi connections to smart home devices and industrial systems, we are constantly surrounded by technologies that depend on data exchange between devices. Even so, it is easy to take this connectivity for granted without really understanding what happens behind the scenes.
From a personal point of view, and thanks to my professional environment, I have already had some contact with communication systems and network-based technologies. This experience gives me a general idea of how devices can interact, exchange information, and coordinate actions. However, most of the time this has been from a higher-level perspective, using already implemented systems rather than building them myself.
For this week, my goal is to dive deeper into the fundamentals of communication between devices by implementing my own system. I am especially interested in understanding concepts like addressing, communication reliability, and how different protocols can be used depending on the needs.
Finally, I want to connect this learning with my final project, exploring how to integrate communication between nodes so that different parts of the system can work together in a coherent way. This feels like a natural next step after developing individual devices in previous weeks.
As I reviewed my current board design, I realized that I am working with some important connectivity limitations. My PCB already includes two LEDs and two buttons soldered to pins D3, D4 (SDA), D5 (SCL), and D6 (TX). This means that some of the pins normally used for communication protocols such as I2C and part of UART are already occupied, which makes wired communication much less flexible without redesigning the board.
Until now, I have mainly been using the XIAO RP2040, which is a very practical microcontroller for many tasks, but it does not include built-in wireless connectivity. For a week focused on networking and communications, this becomes an important limitation.
One positive aspect of my design is that the PCB allows me to swap the microcontroller, so I can test different options without changing the whole board. I also have a XIAO ESP32-C6, which adds Wi-Fi and BLE connectivity. However, this does not completely solve the problem, because pins D4, D5, and D6 match the same connections used in the RP2040 version, so they are still occupied by the existing components on the PCB.
On top of that, designing and fabricating a new PCB is not an option right now, since the Roland SRM-20 in the Fab Lab is still under repair, as I already mentioned in week 8. Because of that, I have to move forward by adapting to the board I already have and making the most of its current constraints.
Firsts steps for XIAO ESP32 C6
Configuring Arduino IDE for XIAO ESP32-C6
As mentioned before, one of the advantages of my PCB design is that I can swap the XIAO microcontroller, moving from the RP2040, which I have been using so far, to the ESP32-C6, which includes wireless connectivity. This change is essential in order to properly approach this week’s networking assignments.
When starting to work with ESP32 microcontrollers, it is necessary to configure them in the development environment first. In my case, I followed the official Seeed Studio tutorial for the XIAO ESP32-C6 ↗️.
The process starts in the Arduino IDE, by going to Preferences. In the section “Additional Boards Manager URLs”, the following URL must be added:
https://espressif.github.io/arduino-esp32/package_esp32_index.json
This is added alongside the URL that was already configured for the RP2040.
Once the URL is added, the next step is to open the Boards Manager, search for “ESP32”, and install the package “esp32 by Espressif Systems”. After this, the environment is ready to start programming the XIAO ESP32-C6 using Arduino.
XIAO ESP32-C6 overview
For this week, I decided to work with the XIAO ESP32-C6, a compact microcontroller that feels much more suitable for networking tasks than the XIAO RP2040 I had been using before. The main reason is simple: it already includes built-in wireless connectivity, which opens the door to testing real communication between devices in a much more direct way.
According to the official documentation, the XIAO ESP32-C6 is based on a 32-bit RISC-V single-core processor running at up to 160 MHz, and it integrates Wi-Fi 6, Bluetooth Low Energy 5.0, and support for Zigbee, Thread, and IEEE 802.15.4. This makes it especially interesting for IoT applications and for projects where several nodes need to communicate with each other.
Another important point for me is that it keeps the same XIAO form factor, so I can physically use it on my existing PCB without redesigning the board. It also provides the usual communication interfaces such as UART, I2C, and SPI, together with multiple GPIOs and analog pins, which gives enough flexibility for experimentation even within the limitations of my current board design.
Overall, I see the XIAO ESP32-C6 as a very natural step forward for this week. It not only helps me explore wireless communication between nodes, but also connects much better with the direction of my final project, where communication between different parts of the system will likely play an important role.
Main features comparison ESP32-C6 Vs. RP2040
| Feature | XIAO ESP32-C6 | XIAO RP2040 |
|---|---|---|
| Processor | 32-bit RISC-V single-core, up to 160 MHz | Dual Cortex-M0+, up to 133 MHz |
| Wireless connectivity | Wi-Fi 6, BLE 5.0, Zigbee, Thread, IEEE 802.15.4 | No built-in wireless connectivity |
| SRAM | 512 KB | 264 KB |
| Flash memory | 4 MB | 2 MB |
| UART | 1x UART + 1x LP_UART | 1x UART |
| I2C | 1x I2C + 1x LP_I2C | 1x I2C |
| SPI | 1x SPI | 1x SPI |
| GPIO / PWM | 11 GPIO (PWM) | 11 digital pins (all PWM) |
| Analog inputs | 7 ADC | 4 analog pins |
| Form factor | XIAO compact format | XIAO compact format |
| USB connector | USB-C | USB-C |
| Best fit | Wireless communication, IoT, networking | General embedded development without wireless |
Group assignment
We have decided that, as a group effort, each of us will specifically document some of the tests performed on our page.
Send a message between two projects
Communication using Bluetooth Low Energy (BLE)
To fulfill the requirement of sending a message between two projects, I decided to use Bluetooth Low Energy (BLE) as the communication method, connecting a Seeed Studio XIAO ESP32-C6 board to a smartphone.
The idea is to configure the XIAO as a BLE server, allowing the phone to detect it, connect to it, and establish a data exchange channel. To achieve this, I followed the official Seeed Studio documentation, specifically the tutorial on Bluetooth usage with this board.
The first step was to properly configure the environment in the Arduino IDE, selecting the XIAO ESP32-C6 board and the correct port. Then, I worked with the required BLE libraries such as BLEDevice, BLEUtils, and BLEServer, which allow creating and managing the Bluetooth server.
The program uploaded to the microcontroller creates a BLE server that reads the state of the two buttons on my PCB and sends a message depending on which one is pressed. This results in a simple but effective communication between the hardware and an external device.
Arduino code · 01esp32_BTbuttons.ino Show code
On the client side, I used an iPhone with the application nRF Connect for Mobile, which allows scanning and connecting to nearby BLE devices. Once the app is open, I search for a device named "XIAO-ESP32C6-BLE" and connect to it.
After connecting, the available BLE services are displayed. Inside them, I access the characteristic defined in the code using a custom UUID, which in my case is "abcdefab-1234-1234-1234-abcdefabcdef". By enabling data reading and setting the parser to UTF-8, I can visualize the messages sent by the board.
High quality video available on my YouTube channel ↗️.
The result is immediate: every time I press one of the buttons, the corresponding message appears in the app, such as "BUTTON 1" or "BUTTON 2", confirming that the communication works correctly.
Communication using Wi-Fi
After testing communication with Bluetooth Low Energy, the next step was to explore a more direct and visual approach: communication using Wi-Fi.
For this, I developed an Arduino sketch that turns the XIAO ESP32-C6 into a Wi-Fi access point and, at the same time, a web server. This means the board creates its own wireless network, allowing me to connect directly from a smartphone or computer without relying on an external network.
The program reads the state of the two buttons connected to pins D4 and D6 on my PCB. Whenever a button is pressed or released, its state is updated both on a web page and in the serial monitor, giving me two different ways to verify that communication is working correctly.
To make the system cleaner and more efficient, the code does not continuously send data. Instead, it detects state changes and only sends information when an actual event occurs. This avoids unnecessary repeated messages and makes the communication much clearer.