Code and Life

Programming, electronics and other cool tech stuff

Supported by

Supported by Picotech

Seeed Studio XIAO nRF52840 (Sense) test drive on Arduino

Seeed Studio XIAO nRF52840

I have to confess I have a thing for small prototyping boards, especially ones with Bluetooth or WLAN connectivity. So when I was offered the opportunity to get a couple of Seeed Studio's tiny Bluetooth devboards with Nordic's nRF52840 in them to try out, I jumped at the opportunity. So full disclosure, I did not buy these myself, but neither did I get any compensation, so what follows will be rather unbiased first impressions! I will cover:

  1. The basic specifications of the two units
  2. How to (re)program the device with Arduino
  3. Help to troubleshoot upload.tool.serial errors on Arduino
  4. Tips and notes on using the USB mass storage mode
  5. Initial summary

I'm interested in trying out the PDM microphone, accelerometer and BLE functionality later on, so check back for updates!

Basic specifications of the Seeed XIAO BLE nrf52840

The Seeed XIAO BLE units come in two varieties, both sharing quite beefy specs:

  • Bluetooth 5.0 with an onboard antenna
  • Nordic nRF52840, ARM Cortex-M4 32-bit processor with FPU, 64 MHz
  • Low power consumption and battery charging chip for untethered IoT use cases
  • Onboard 2 MB flash

Additionally, the Sense variant contains a PDM microphone and a 6-axis accelerometer. The units arrived from China quite quickly and came in sweet little Seeed plastic packages, pin headers included (not soldered in):

Seeed Studio XIAO nRF52840 and Sense

You can get both directly from Seeed, with very reasonable $9.90 and $15.99 price points. Nordic's chips are quite hard to source from AliExpress cheaply (yes I have looked :), so I'd consider both pretty much a bargain.

Board quality seems very good, pads are shiny and components well placed. The USB port is of modern USB-C variety, and the form factor is really small, just 20 x 17.5 mm or the size of a nickel x dime. and the thickness of a half dollar or so (U.S. readers, you're welcome!). The PCB is one-sided which makes it easy to embed in various configurations.

Outside differences of the basic model and Sense variant is one additional chip that contains the PDM microphone. I think the accelerometer is hidden inside the (seemingly FCC and CE compliant) shielding.

Seeed Studio XIAO nRF52840

There is also an absurdly tiny reset button on the opposite corner to the microphone pad (top left above) that is a bit tricky to press. I'd prefer a slightly larger one, but it beats shorting pins any day.

Classic blink test with Arduino

You can follow the instructions on Seeed Studio wiki to install the necessary development tools to build firmware for the device. Short version:

  1. Get Arduino
  2. In File > Preferences, add https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json to Additional Boards Manager URLs
  3. Go to Tools > Board > Boards Manager, search for "seeed nrf52" and install the two libraries.
  4. Now you can select your board and port.

Below you can see a screenshot with relevant Board selected and how the COM port looks on my machine. I'm using the standard Arduino Blink example.

Arduino Seeed XIAO nRF52840

NOTE: once you flash the firmware, at least on my Windows 10 the COM port disappears. To return the device to a flashable state, double press on the reset (RST) button, and the device enters USB mass storage mode and reactivates the COM port as well.

Possible caveat with Arduino:

When I first installed the Seeed nRF52 Boards support, I got the following error message while trying to flash:

"Property 'upload.tool.serial' not defined".

It was possibly due to rather new Arduino 2.0 beta version I had just installed that seems to have changed the boards.txt format for some settings. Locating that file in C:\Users\username\AppData\Local\Arduino15\packages\Seeeduino\hardware\nrf52\1.0.0 and adding the following lines to the top of the file fixed the problem:

xiaonRF52840.upload.tool.default=nrfutil
xiaonRF52840.upload.tool.serial=nrfutil

If you use the mbed library, the location should be C:\Users\username\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.7.2 or similar. Just go to your AppData\Local\Arduino\packages folder, and you should locate the files quite easily under Seeeduino\hardware subfolder. Note that if you select the (Sense) variant, the setting additions would be:

xiaonRF52840Sense.upload.tool.default=nrfutil
xiaonRF52840Sense.upload.tool.serial=nrfutil

Note: After updating to Arduino 2.0.2 I did not seem to encounter this problem anymore. That update (or just rebooting the machine several times) may have fixed the issue.

USB mass storage mode

As noted above, double click on the reset button will enter a mode where the device shows up as a USB drive. Here's how it looks on my machine:

Arduino Seeed XIAO nRF52840

If you have a .UF2 while you've compiled (I'm sure one can get such a file out of Arduino), you can just drag the file there. This enables also other nice features:

  • You can just drag the CURRENT.UF2 to your computer to make a backup of currently flashed code.
  • If you have several XIAO devices, you can program the same firmware just by double-clicking reset and dragging the .UF2 file to drive that pops up
  • You can easily distribute ready-to-run software to your friends having the same device, or anyone in the internet. Really good for DIY projects (I don't remember how many questions I've gotten regarding "I cannot your project to compile/flash")

The name of the firmware does not seem to matter, so while writing this, I made several versions of the Blink example on my hard drive, named them 1SEC.UF2, FAST.UF2 etc. and I could just drag the file I wanted, and it would essentially overwrite the previous firmware. This indicates that the USB driver probably just detects .UF2 extension and flashes that on the device and reboots.

Note1: Other files you drag to the drive don't seem to persist over resets, so storing a secret password or the like does not work. Email me if you know that this can be done some other way.

Note2: You should be EXTREMELY CAUTIOUS when downloading a firmware file from the Internet for a USB capable device and installing it. Malicious people can easily make a firmware that looks like it is doing it what it should, but after a random delay or every Nth time you plug it in, it also becomes a keyboard, installs keyloggers on your machine and completely pawns you.

As seen from the folder screenshot, the mass storage mode also shows INFO_UF2.TXT which tells a bit more about the bootloader in question. Here are the contents of that:

UF2 Bootloader 0.6.2-12-g459adc9-dirty lib/nrfx (v2.0.0) lib/tinyusb (0.10.1-293-gaf8e5a90) lib/uf2 (remotes/origin/configupdate-9-gadbb8c7)
Model: Seeed XIAO nRF52840
Board-ID: Seeed_XIAO_nRF52840_Sense
Date: Nov 30 2021
SoftDevice: S140 7.3.0

If you have a JLINK debugger device, you can reprogram the bootloader. Seeed have provided instructions for this as well (haven't tried yet):

https://wiki.seeedstudio.com/XIAO_BLE/#access-the-swd-pins-for-debugging-and-reflashing-bootloader

Initial summary

Based on the initial test spin, I'm giving these units 4.5 stars out of 5. It would be an excellent platform for my Bluetooth pedal project, as it would fit inside the pedal!

Pros

  • Very tiny footprint
  • Excellent board quality
  • Inexpensive price for a Nordic BLE chip
  • Great CPU/feature/power specs for a range of projects
  • Easy Arduino compatibility
  • USB mass storage support in bootloader
  • Nice extra features in Sense model (to be tested still)

Cons

  • Higher price and smaller community than XIAO ESP32 and RP2040 counterparts
  • Super tiny reset a bit awkward
  • Initial hiccups with Arduino 2.0.0 (seem to be fixed now)
  • One could always hope for WLAN as well... :D

If you encounter nice projects for the XIAO BLE, throw me (at) codeandlife.com an email. :)