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 embedded programming.

As a starting point for exploring toolchains and workflows, we considered two different potential microcontrollers as the context. The first is the ESP32 microcontroller family by Espressif, specifically the ESP32-C3 series (ESP32-C3 Datasheet). The ESP32-C3 is a low-power microcontroller unit with a 32-bit RISC-V single-core processor, and it also supports wireless communication with WiFi and Bluetooth. We have the ESP32-C3 available in a development board package from Seeed Studio - the XIAO ESP32C3 board.

The second is the RP2040 microcontroller family by Raspberry Pi Ltd. - (RP2040 Datasheet). The RP2040 is a microcontroller unit with a 32-bit dual-core Arm Cortex-M0+ processor. We have the RP2040 available in a development board package from Seeed Studio - the XIAO RP2040 board.

Both the ESP32 and RP2040 are popular microcontroller options. Primary considerations are that the ESP32 has somewhat better potential for performance and also has wireless connectivity capabilities.

Based on the microcontroller options, we explored the associated workflows and toolchains. We found that both microcontroller / development board options had two primary options available for setup and programming:

  • Arduino IDE / Ecosystem - C/C++ programming and libraries
  • Thonny IDE / Ecosystem - Python programming and libraries

We explored both Arduino/C++ and Thonny/Circuit Python workflows and toolchains. Since both microcontrollers have the same programming environments availble, we worked through both environments using the XIAO ESP32-C3 board to gain experience with the workflows and toolchains.

Arduino IDE with XIAO

The first workflow that we explored was Arduino IDE and XIAO ESP32C3. 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