Xiao 3.3V

32-bit SAMD21

The smallest Arduino board

From the left: Seeeduino Xiao Sparkfun Pro Mini Pro Micro clone Nano clone

I'm always looking for small and unexpensive Arduino boards that I can permanently integrate into my projects. The Seeeduino Xiao is extremly small which possibly makes it perfect for small projects and wearables. At the same time, it contains a more powerful chip than the original Arduino AVR chips. The SAMD21 is a low-power, high-performance ARM Cortex-M0+ based microcontroller.

Specs: 32-bit, 48 MHz, 256 kB flash memory and 32 kB SRAM, native USB built into the chip, USB-C connector

This looks like it could be the perfect replacement for the older Pro Micro. While the Pro Micro is still a great choice for simple projects, the small RAM/ROM size is often very limiting. The Xiao sells for $4.90 at Digikey, which is (almost) cheaper than a Pro Micro clone.

(Actually, I wanted to buy a Adafruit QT Py, which cost $6.00 at Digikey but they were out of stock. They have a reset button which the Xiao lacks).

Pinout

One limitation of the Xiao is the very low current limits: you can easily burn up a GPIO or even destroy the MCU completely if the source or sink current is larger than 2.5mA (sink) or 2mA (source) even if this happens only for a very short amount of time.

Another negative point is that there is not at least a reset pin. There are very small reset pads that are difficult reach with a wire or similar.

On the positive side, there is a detailed Xiao wiki page.

The maximum input voltage to connect to the VIN or 5V pins is 6V. In addition to the approx. 25 mA that the Xiao consumes, not more than max. 120 mA should be sourced to power sensors etc.

Getting started with PlatformIO

You have to install the correct Core in PlatformIO. There is an official core from Atmel:

In PlatformIO, this core is called Atmel SAM. Launch PlatformIO, go to PlatformIO home and click on Platforms. Search and install Atmel SAM.

Now, create a new project. Go to platformio projects -> create new project. Search for the board Seeeduino XIAO. Choose Framework: Arduino and save the project.

The platformio.ini file for the project should look like this:

[env:seeed_xiao]

platform = atmelsam

board = seeed_xiao

framework = arduino

A simple Hello World program:

#include <Arduino.h>


void setup() {

// put your setup code here, to run once:

}


void loop() {

// put your main code here, to run repeatedly:

Serial.println("Hello Xiao!!");

delay(2000);

}

In my case, the program compiled and uploaded without problems. Program execution started immediately after, opening the serial port. The blue LED blinks during serial communication. The Xiao shows up as a USB serial device in the device manager:

Similar to the Pro Micro, in order to communicate serially, the Xiao emulates a virtual serial port. Actually, it emulates two different serial ports: one for the bootloader, and one for the sketch. Since the bootloader and sketch run individually, only one of these serial ports is visible at any one time.

To see the bootloader port, you have to reset twice, which is a pain as the Xiao has no reset button, just some pads that you have to shorten with a wire. A different serial port opens. Now, the yellow LED pulses slowly and the Xiao registers as a removable disc that is visible in the file manager:

The info_UF2 file reads:

UF2 Bootloader v3.7.0-33-g90ff611-dirty SFHWRO

Model: Seeeduino XIAO

Board-ID: SAMD21G18A-XIAO-v0

The UF2 bootloader file contains extra information to help the bootloader know where the data goes. The format is called UF2 (USB Flashing Format). Microsoft MakeCode generates UF2s for flashing. A CircuitPython .UF2 file is available on circuitpython.org.

For reprogramming the board, no reset is however needed. Changing a line in the program and recompiling worked without problems. Platformio opened the upload port automatically:

RAM: [= ] 7.3% (used 2408 bytes from 32768 bytes)

Flash: [ ] 4.1% (used 10872 bytes from 262144 bytes)

Configuring upload protocol...

AVAILABLE: atmel-ice, blackmagic, jlink, sam-ba

CURRENT: upload_protocol = sam-ba

Looking for upload port...

Auto-detected: COM3

Forcing reset using 1200bps open/close on port COM3

Waiting for the new upload port...

Uploading .pio\build\seeed_xiao\firmware.bin

Atmel SMART device 0x10010005 found

Erase flash

done in 0.830 seconds


Write 10872 bytes to flash (170 pages)


[=========== ] 37% (64/170 pages)

[====================== ] 75% (128/170 pages)

[==============================] 100% (170/170 pages)

done in 0.091 seconds


Verify 10872 bytes of flash with checksum.

Verify successful

done in 0.017 seconds

CPU reset.

Conclusion

This seems to be an almost perfect board for small projects. It is cheap enough to be permanently soldered into the project. It is also very small and flat on the back-side. The chip is more powerful and has more memory than the original AVR chips, which makes it easy to drive a small display. The board gets minus points for not having reset button or pin. Actually, I still want to test the Adafruit QT Py, which cost a little bit more ($6.00 at Digikey) but has a reset button. Apart from that, the very low current limits of the SAMD21 GPIO pins can be a limitation for some projects.

© 2021 notthemarsian