Skip to content

Week 4 Group Assignments -

Demonstrate and compare the toolchains and development workflows for available embedded architectures
Document your work to the group work page and reflect on your individual page what you learned

Toolchains and Workflows

We reviewed a couple of different workflows for embedding programming. We explored both Arduino IDE and Circuit Python based pathways for programming both XIAO boards and RP2040 boards.

Arduino IDE with XIAO

The first workflow that we explored was Arduino IDE and XIAO. This was a relatively straightforward pathway as it just required downloading Arduino software and the XIAO board package. The Arduino version used was the older version 1.8.19. We then downloaded the board package and uploaded a blink sketch to the board.

Arduino IDE window for flashing the board.

blink.ino
int led = 10;
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(led, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(200);                       // wait for a second
}
We setup a simple LED circuit on pin 10 of the XIAO Board and after choosing the correct COM port, we flashed the board with the program. The LED blinked as expected based on the simple code instance.

XIAO ESP32-C3 running blink code.

Circuit Python

Before testing Circuit Python, we did some background research. We looked at the XIAO board connection guide and watched Leon Anavi How-To Use CP with XIAO Video. This gave us a good background on how to do it.

The first step was to go to the Circuit Python website and download the .bin file for the XIAO board. For the XIAO ESP32C3 CircuitPython 9.2.4 was the latest stable release and that is what we downloaded and used.

Next we went ahead and downloaded the Thonny Circuit Python editing tool so we could test out writing our own code and communicate with the board. After starting Thonny and plugging in the board, the shell window showed a bunch of errors and would not take any REPL commands as the board did not already have CP running on it.

Before programming the board we had to push the CP .bin file to the board. We plugged the XIAOESP32C3 into the computer and used the Adafruit ESP Tool to upload the .bin file. This just required putting the board into bootmode by holding the reset button and selecting the connect button on the ESP Tool. Then we selected the bin file and pushed upload.

Uploading Circuit Python to the XIAO.

Then we went back to Thonny and the shell window showed that the board was alive and communicating with Thonny. We tested this by running the REPL code:

import board
dir(board)

This queried the board to tell us the pin assigments and it dutifully printed them in the shell window.

Communicating with the XIAO over REPL. Note the pin assignment response in yellow text.

The next step was to flash blink code to the device. We found some sample code on a related Wokwi project. We modified the code to point at D5 on the XIAO and flashed it to the board. On the terminal we could see the serial print messages coming through so we know the code was running. Then we hooked up an LED to pin D5 with a 220 Ohm resistor to ground and confirmed that it was indeed blinking properly on the board.

Thonny window with blink code running. Note the "on/off" messages in the shell window.
blink.py
# CircuitPython Blink Example

import time
import board
import digitalio

led = digitalio.DigitalInOut(board.D5)
led.direction = digitalio.Direction.OUTPUT

while True:
  print("On!")
  led.value = True
  time.sleep(0.5)

  print("Off!")
  led.value = False
  time.sleep(0.5)

And a video showing it all working together.

Circuit Python blinking an LED