In my quest to find wireless IoT solutions, I find a lot of interesting and useful products manufactured by Seeed Studio. I posted about a WiFi dev board yesterday: Wio RP2040 Mini Dev Board.
In addition to WiFi, I've been looking for BLE solutions. Seeed has a small form factor (21 x 17.5mm) module, the Xiao, that I've used before: Samd21 Mini Modules. And Adafruit makes a footprint compatible Qt Py module that I tried recently with a RP2040 version: Qt Py RP2040. Seeed recently came out with two Xiao BLE modules that use the nRF52840 as the MCU. Seems like the nRF52840 is showing up everywhere - just like the RP2040. It is used in one of my favorite Arduino boards the Arduino Nano 33 BLE Sense.
After a long postal journey from China, I received a Xiao BLE and a Xiao BLE Sense yesterday.
XIAO BLE nRF52840 $9.90
XIAO BLE Sense nRF52840 $15.99
Here is a spec comparison of the Seeed Xiao boards:
The only way to differentiate the two boards is if the PDM microphone is populated or not in the lower right of the board. The IMU is internal to the shield and the labels are identical .
These boards are supported in the Arduino IDE, so start up is easy.
Finding where it installed confused me for a second as it was with the Arduino Mbed OS boards.
And to find the ArduinoBLE example you had to look under the "INCOMPATIBLE" library examples.
I decided to try a Peripheral example with the with the board connected with my iPhone as the Central to test out the BLE operation.
I'll use the "LightBlue" iOS app from PunchThrough.
LED.ino
/* LED This example creates a BLE peripheral with service that contains a characteristic to control an LED. The circuit: - Arduino MKR WiFi 1010, Arduino Uno WiFi Rev2 board, Arduino Nano 33 IoT, Arduino Nano 33 BLE, or Arduino Nano 33 BLE Sense board. You can use a generic BLE central app, like LightBlue (iOS and Android) or nRF Connect (Android), to interact with the services and characteristics created in this sketch. This example code is in the public domain. */ #include <ArduinoBLE.h> BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE LED Service // BLE LED Switch Characteristic - custom 128-bit UUID, read and writable by central BLEByteCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite); const int ledPin = LED_BUILTIN; // pin to use for the LED void setup() { Serial.begin(9600); while (!Serial); // set LED pin to output mode pinMode(ledPin, OUTPUT); // begin initialization if (!BLE.begin()) { Serial.println("starting BLE failed!"); while (1); } // set advertised local name and service UUID: BLE.setLocalName("LED"); BLE.setAdvertisedService(ledService); // add the characteristic to the service ledService.addCharacteristic(switchCharacteristic); // add service BLE.addService(ledService); // set the initial value for the characeristic: switchCharacteristic.writeValue(0); // start advertising BLE.advertise(); Serial.println("BLE LED Peripheral"); } void loop() { // listen for BLE peripherals to connect: BLEDevice central = BLE.central(); // if a central is connected to peripheral: if (central) { Serial.print("Connected to central: "); // print the central's MAC address: Serial.println(central.address()); // while the central is still connected to peripheral: while (central.connected()) { // if the remote device wrote to the characteristic, // use the value to control the LED: if (switchCharacteristic.written()) { if (switchCharacteristic.value()) { // any value other than 0 Serial.println("LED on"); digitalWrite(ledPin, HIGH); // will turn the LED on } else { // a 0 value Serial.println(F("LED off")); digitalWrite(ledPin, LOW); // will turn the LED off } } } // when the central disconnects, print it out: Serial.print(F("Disconnected from central: ")); Serial.println(central.address()); } }
Compile and upload the program.
Start scanning with LightBlue.
The Peripheral shows up as LED
Locate the LED characteristic
Write values to "1" and "0" (looks like I missed a screenshot, but you get the idea)
The output on the Serial Console
And the response on the board (I did not do a video). Worked as expected except that ("1" was "Off" and "0" was "On").
Off to a good start. I think I'll try some ML with the microphone and IMU using Edge Impulse. I'll post that later.
Top Comments