At the heart of the Cool Wave project will be using the Seeeduino XIAO microcontroller module (Seeed Studio XIAO SAMD21) as the main controller. This is not a device I have used before, but as a device that can run MicroPython or CircuitPython, and is smaller than 20mmx18mm, it has been on my “to play with” list, and this is a great opportunity to do just that.
For this project I intend to use MicroPython as I am experienced in using it for embedded projects, and it is familiar to many others wanting to use my code. As often happens with progress, the once great installation instructions become outdated and no longer work, and that is the case for the Seeeduino XIAO MicroPython installation instructions. As a result I had spent a while working through the issues and am documenting this how to for anyone else wanting to install MicroPython and the Thonny IDE.
- First download the latest MicroPython firmware. For the Seeeduino XIAO this can be downloaded from https://micropython.org/download/SEEED_XIAO_SAMD21/ . At the time of writing the latest release is v1.20.0 (2023-04-26) and this seems to work well. Download the DF2 file and have it ready for later.
- Next plug the Seeeduino XIAO and wait while your computer does it’s thing and install any drivers. Technically we do not need these drivers yet, but they will be needed eventually, and interrupting now can cause delays in the next step. Just chill for a half a minute and everything will be fine.
- When the device is plugged in and everything has settled down we first need to put the Seeeduino XIAO into DFU bootloader mode. Using a small length of wire we short out the two test pins next to the module’s USB connector twice. These are on the top and the opposite side of the connector to the LEDs. We just need to tap them a first time, and then quickly tap them again. If successful the green and orange LEDs will light and a new drive will appear on your computer. If not then just double tap again. I have made a video showing the process.
- By magic a new drive should have appeared on your computer. Now copy the UF2 file to this new drive. After it has copied the Seeeduino XIAO will automatically reboot and install the firmware. This will take seconds and then the hardware is ready to use.
- I now recommend installing Thonny from https://thonny.org/. Other development IDEs are available, but this is a simple and well supported front end that will get you going. You can always migrate to something more substantial in the future. After installation select “Options…” form the “Tools” menu, and then select the “Interpreter” tab. Select “MicrPython (generic) for the interpreter and “<try to detect port automatically>” for the port.
- Now let's run some test code. Select “New” from the “File” menu, and copy this example code from the Seeed wiki).
from machine import Pin, Timer led = Pin(18, Pin.OUT) Counter = 0 Fun_Num = 0 def fun(tim): global Counter Counter = Counter + 1 print(Counter) led.value(Counter%2) tim = Timer(-1) tim.init(period=500, mode=Timer.PERIODIC, callback=fun)
Then select “Save as…” from the “File” menu and press the “MicroPython Device” button. You now need to enter a filename. “blink.py” would be a good choice. Once saved click the green play button and the blue LED should start flashing.
So, well done, you have a flashing LED. More importantly you have a working MicroPython environment that you can copy code into, or create your own.