Week 11 Assignments - Embedded Networking and Communications
Board-to-Board Pushbutton LED Control using Arduino Bluetooth® Low Energy (BLE) Networking and Communication
Group Assignment
The group assignment for this week was to:
- Send a message between two projects
- Document your work to the group work page and reflect on your individual page what you learned
Outcomes
Link to Group Site
The group assignment page for this week is on the 2025 Charlotte Super Fab Lab group site for Week 11 - Embedded Networking and Communications.
What Was Learned
In the group assignment, we considered embedded communications using the I2C protocol using different combinations of development boards. This included I2C communication between a XIAO SAMD21 and XIAO ESP32C3, each with the same development board footprint, as well as between 2 XIAO ESP32C3 boards with different development board footprints.
We were able to (1) send messages between the boards and (2) use messaging to connect inputs and outputs across the boards. This provided us experience on:
- Configuration and setup of I2C communication with unique board identities
- Using I2C for communication between boards
- Using I2C established communication channels for messaging to drive cross-platform input / output interactions
Individual Assignment
The individual assignment for this week was to:
- Design, build and connect wired or wireless node(s) with network or bus addresses and a local input and/or output devices
Ardiuno Bluetooth® Low Energy
For the individual assignment, I considered the Ardunio Bluetooth® Low Energy (BLE) wireless communication protocol. The BLE protocol is designed for low power usage operation at low data rates.
The BLE protocol considers participating devices to act in a client-server model. "Peripheral devices" act as servers / data providers, such as providing sensor data. "Central devices" act as clients / data readers, retrieving information from peripheral devices.
A peripheral device may provide different types / categories of data, organized into "Services." For example, a sensor device might provide a weather service (including data on temperature and hummidity) and a separate battery service (including data on battery life for the device).
Each service provides individual data items, each referred to as a "Characteristic." For example, a weather service may provide a current temperature characteristic.
Arduino Bluetooth® Low Energy (BLE) Model1
For data communication in BLE, there are 3 identifiers used to uniquely address information. These include:
- Device Address - each BLE device / board has a unique 48-bit "Bluetooth MAC" address
- Service ID - each BLE service is identified by a "universally unique identifier" (UUID). It is a 16-bit UUID for standard services and a 128-bit UUID for custom services
- Characteristic ID - each BLE characteristic may also be identified by a UUID, in the same format at the ID for the service it is a part of
Outcomes
To explore BLE wireless communication, I created a BLE connection between 2 development boards. The first board is the XIAO ESP32C3 microcontroller board that I developed previously in Week 8 - Electronics Production. The XIAO includes support for BLE protocols and has an external antenna. The second board is an Arduino UNO R4 WiFi that includes support for BLE protocols and has an internal antenna.
My XIAO development board has an onboard pushbutton, and the the Arduino UNO R4 WiFi has an onboard LED. In order to test inter-board communication using BLE, I planned to use the pushbutton on the XIAO board to control the onboard LED on the Arduino UNO R4 WiFi.
Programming Process / Environment Setup
For the programming process, I used the Arduino programming ecosystem with C++ code and utilized the Arduino IDE as the development environment.
- In order to get started with BLE programming, I first had to install the ArduinoBLE library. This was done using the Arduino IDE
Tools > Manage Libraries...
, searching for "bluetooth", and installing the ArduinoBLE library by Arduino.
Coding BLE Server / Peripheral
I first worked on setting up the Arduino Uno R4 WiFi to be the BLE Server / Peripherial device. The device would maintain a byte
variable (BLE characteristic) for the status of the onboard LED (0 for off, 1 for on). The peripheral would reference this value in order to set the status of the onboard LED. Client / central devices connected using BLE could access the LED service / characteristic and read or update the value (checking or changing the status of the LED).
Overall, the server should:
- Start BLE operation
- Set up the LED service with UUID
- Set up the LED switch characteristic with UUID
- Set up event handlers to respond to BLE events:
- Messaging on device connect
- Messaging on device disconnect
- Messaging on switch value update
- Set onboard LED in response to switch value update
- Start advertising the service for connection
The Arduino IDE includes example programs for BLE communication. I adopted the Arduino BLE LED Peripheral example as the basis to drive the Arduino UNO R4 WiFi LED peripheral. The examples include both a basic version and version that uses events / callbacks. I explored the event-driven callback version.
The LEDCallback service and the swtich characteristic are identified by custom UUIDS:
- LED Service UUID:
19B10000-E8F2-537E-4F6C-D104768A1214
- LED Switch Characteristic UUID:
19B10001-E8F2-537E-4F6C-D104768A1214
In order to test whether the LED Peripheral setup was working properly, I used a general-purpose BLE utility - Blutility. Bluetility provides a basic UI to browse available devices, browse peripheral services and characteristics, and viewing / updating characteristic values.
I checked the basic operation using the Arduino IDE Serial Monitor output, as well as the LED operation.
Connected event, central: ac:c9:06:0b:26:44
Characteristic event, written: LED on
Characteristic event, written: LED off
Characteristic event, written: LED on
Characteristic event, written: LED off
Characteristic event, written: LED on
Characteristic event, written: LED off
The video demonstration shows the LED Peripheral program running on the Arduino UNO R4 WiFi. Blutility is refreshed to detect BLE devices. The device named LEDCallback is selected, and that shows the avalable Services. Selecting the designated service shows the available characteristics. Selecting the available characteristic allows the value to be updated. Update of the LED switch characteristic triggers the value-written event handler. In the handler, setting the LED switch characteristic to a non-zero value turns the LED on. Setting the LED switch characteristic to a zero value turns the LED off.
Testing with Bluetility showed that the LED peripheral device setup seemed to be working properly.
Using Blutility to Connect via BLE with Arduino UNO R4 WiFi and Test Setting LED Switch Characteristic
Coding BLE Server / Peripheral
I next worked to set up my XIAO ESP32C3 development board to be the BLE Client / Central device. Overall, the client should:
- Start BLE operation
- Scan for available BLE devices - specifically for a device that is advertising the specific service UUID:
19b10000-e8f2-537e-4f6c-d104768a1214
- Connect to the device
- Access the LED Service / Switch Characteristic
- Use BLE communication to set the LED switch status to correspond with the current status of the onboard pushbutton
The Arduino IDE includes example programs for BLE communication. I adopted the Arduino BLE LED Central control example as the basis to drive the Arduino UNO R4 WiFi LED peripheral.
Arduino BLE LED Central Control | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
With the code for the central control loaded on to the XIAO ESP32C3, I I checked the basic operation using the Arduino IDE Serial Monitor output for both boards, as well as the LED operation.
Bluetooth® Low Energy Central - LED control
Found f4:12:fa:63:5d:41 'LEDCallback' 19b10000-e8f2-537e-4f6c-d104768a1214
Connecting ...
Connected
Discovering attributes ...
Attributes discovered
button pressed
button released
button pressed
button released
button pressed
button released
Connected event, central: 24:ec:4a:c9:9d:c6
Characteristic event, written: LED on
Characteristic event, written: LED off
Characteristic event, written: LED on
Characteristic event, written: LED off
Characteristic event, written: LED on
Characteristic event, written: LED off
LED Pushbutton Remote Control Over BLE