Fab Academy 2026 - Week 04

Embedded
Programming

Studying the RP2040 microcontroller, comparing embedded programming environments, preparing hardware, and testing input/output workflows using MicroPython, MicroBlocks, and Arduino IDE.

01 / Individual Assignment

Assignment Overview

The individual assignment focused on reading the microcontroller datasheet, preparing the board, setting up programming environments, and programming a microcontroller board to interact with input and output devices.

Main Requirements

  • Browse and study a microcontroller datasheet
  • Program a microcontroller development board
  • Test input and output behavior
  • Document the programming and debugging workflow

My Focus

  • Seeed Studio XIAO RP2040
  • Arduino IDE, Thonny, and MicroBlocks
  • OLED display output using I2C
  • Touch input with NeoPixel and OLED feedback
02 / Board Used: xiao-rp2040

Seeed Studio XIAO RP2040

For this assignment, the main microcontroller platform used was the Seeed Studio XIAO RP2040. The board is based on the Raspberry Pi RP2040 dual-core ARM Cortex-M0+ microcontroller operating at up to 133 MHz. Despite its extremely compact size, the board provides multiple digital GPIO pins, analog inputs, PWM support, UART, SPI, and I2C communication interfaces, making it highly suitable for embedded systems prototyping and rapid hardware experimentation.

One of the key reasons for selecting this board was its compact form factor, integrated USB-C programming interface, and compatibility with multiple development environments including:

  • Arduino IDE
  • MicroPython
  • C/C++ SDK
  • Zephyr RTOS

During this assignment, the XIAO RP2040 was interfaced with an SSD1306 OLED display over the I2C communication bus. Additionally, the onboard RGB NeoPixel LED and external capacitive touch pads available on the fabricated PCB were used to demonstrate both input and output interaction within the embedded system.

Seeed Studio XIAO RP2040
FIG. 01 - Seeed Studio XIAO RP2040 microcontroller board used during this assignment
XIAO RP2040 Pinout Diagram
FIG. 02 - Pinout diagram of the XIAO RP2040 showing GPIO, SPI, UART, PWM, analog and I2C interfaces

The RP2040 provides two programmable I2C interfaces. In this assignment, GPIO6 (SDA) and GPIO7 (SCL) were configured for communication with the OLED display. The fabricated board also routed several GPIO pins to large copper touch pads, enabling simple capacitive-touch interaction experiments.

The onboard RGB LED available on the XIAO RP2040 was later utilized to create a simplified traffic-light demonstration system. Different LED colors were triggered based on touch-pad interaction, while the OLED display simultaneously provided visual feedback and system status information.

Technical Note:
The RP2040 microcontroller contains a dual-core Cortex-M0+ architecture, programmable I/O (PIO) subsystem, hardware timers, watchdog timer, DMA controller, and multiple communication peripherals. These features make the device highly attractive for real-time embedded systems, low-level hardware interfacing, and educational prototyping applications.

Additional hardware documentation and Zephyr RTOS support information for the XIAO RP2040 can be found here:

Zephyr Documentation – Seeed Studio XIAO RP2040

03 / Datasheet Exploration

RP2040 Datasheet Exploration

I explored the RP2040 datasheet to understand the architecture and hardware capabilities of the board. The datasheet includes information about GPIO, timers, communication protocols, memory organization, power management, and embedded peripherals.

  • Dual-core ARM Cortex-M0+ processor
  • Programmable GPIO pins
  • ADC and PWM functionality
  • UART, SPI, and I2C communication support
  • USB interface for programming and communication
  • Watchdog timer for reliability and fault recovery

Watchdog Timer Case Study

I found the watchdog timer interesting because it shows how embedded systems can recover automatically from software failures. If a program crashes or becomes unresponsive, the watchdog can reset the microcontroller and restore operation.

A well-known example is the Mars Pathfinder mission in 1997. The spacecraft experienced system resets due to a priority inversion problem. The watchdog timer detected that a critical task was not running correctly and reset the system. Although the resets interrupted operations, they prevented the system from becoming permanently unresponsive.

Note: Additional information about the Mars Pathfinder incident: Read the article

04 / Hardware Preparation

Soldering and Board Assembly

Before programming, I practiced soldering and prepared the hardware setup. This was important because embedded programming depends not only on code, but also on reliable electrical connections and properly assembled boards.

Soldering Workstation

Activating soldering workstation
FIG. 03 - Activating the soldering workstation
Configuring soldering temperature
FIG. 04 - Configuring soldering temperature
Lead-free solder wire
FIG. 05 - Lead-free solder wire
Flux pen
FIG. 06 - Flux pen used during soldering

PCB Soldering Practice

I soldered small components onto a pre-fabricated PCB to understand component placement, solder joint formation, and surface-mount handling.

PCB prepared for soldering
FIG. 07 - PCB prepared for soldering practice
Two resistors soldered
FIG. 08 - Resistors soldered onto the PCB

XIAO RP2040 Assembly

After soldering practice, I assembled the XIAO RP2040 module onto the demonstration PCB using header pins. The board was visually inspected after soldering to check alignment and solder joint quality.

XIAO board and header pins
FIG. 09 - XIAO RP2040 and header pins before assembly
Final assembled board
FIG. 10 - Final assembled demonstration board
05 / Development Environment

Programming Environment Setup

Arduino IDE Setup

I used Arduino IDE as the main programming environment. After installing Arduino IDE, I added the RP2040 board support package using the Additional Boards Manager URL.

https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
Board manager URL setup
FIG. 11 - Adding RP2040 board manager URL
Board selection
FIG. 12 - Selecting Seeed XIAO RP2040
COM port selection
FIG. 13 - Selecting the correct COM port

Thonny and MicroPython

I also explored Thonny IDE with MicroPython. Thonny provides direct access to the MicroPython shell and is useful for quick testing.

Thonny firmware setup
FIG. 14 - Installing MicroPython firmware
MicroPython shell
FIG. 15 - MicroPython shell in Thonny

MicroBlocks

MicroBlocks was tested as a visual programming environment. It allowed quick testing of the XIAO RP2040 board and NeoPixel output.

XIAO RP2040 board selection in MicroBlocks
FIG. 16 - XIAO RP2040 board selection
MicroBlocks NeoPixel program
FIG. 17 - MicroBlocks NeoPixel program
06 / Basic Programming Tests

Basic Output Tests

The first experiment was a simple LED blink program. This verified the programming environment, USB communication, firmware upload process, and basic GPIO control.

#define PIN_RED 17
#define PIN_GREEN 16
#define PIN_BLUE 25

void setup() {
  pinMode(PIN_RED, OUTPUT);
  pinMode(PIN_GREEN, OUTPUT);
  pinMode(PIN_BLUE, OUTPUT);

  digitalWrite(PIN_RED, HIGH);
  digitalWrite(PIN_GREEN, HIGH);
  digitalWrite(PIN_BLUE, HIGH);
}

void loop() {
  digitalWrite(PIN_GREEN, LOW);
  delay(500);
  digitalWrite(PIN_GREEN, HIGH);
  delay(500);
}
Arduino blink program
FIG. 18 - Blink program in Arduino IDE
Testing onboard LED blinking
FIG. 19 - Testing LED blinking output

MicroPython GPIO Test

from machine import Pin
import time

led = Pin(25, Pin.OUT)

while True:
    led.on()
    time.sleep(1)
    led.off()
    time.sleep(1)
07 / OLED Programming

OLED Programming and Debugging

After assembling the XIAO RP2040 board and OLED display module, I tested communication between the microcontroller and the SSD1306 OLED display using I2C. The SDA and SCL lines were connected to GPIO6 and GPIO7.

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

#define SDA_PIN 6
#define SCL_PIN 7

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
  Serial.begin(115200);

  Wire.setSDA(SDA_PIN);
  Wire.setSCL(SCL_PIN);
  Wire.begin();

  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println("SSD1306 allocation failed");
    while (true);
  }

  display.clearDisplay();
  display.display();
  Serial.println("OLED Initialized Successfully");
}

void loop() {
  for (int y = -24; y < 64; y++) {
    display.clearDisplay();
    display.setTextSize(1);
    display.setTextColor(SSD1306_WHITE);

    display.setCursor(0, y);
    display.println("FabAcademy2026!");

    display.setCursor(0, y + 10);
    display.println("FabLab Oulu!");

    display.setCursor(0, y + 20);
    display.println("DINESH");

    display.display();
    delay(50);
  }
}

During compilation, I encountered missing library errors for Adafruit_GFX.h and Adafruit_SSD1306.h. I fixed this by installing Adafruit SSD1306, Adafruit GFX Library, and Adafruit BusIO from the Arduino Library Manager.

Missing SSD1306 library error
FIG. 20 - Missing SSD1306 library error
Installing SSD1306 library
FIG. 21 - Installing Adafruit SSD1306
Installing GFX dependency
FIG. 22 - Installing Adafruit GFX dependency

Successfully established I2C communication between the XIAO RP2040 and SSD1306 OLED display using Arduino IDE.

08 / Input and Output Demo

Touch Input and OLED Output Demonstration

As the final part of the individual assignment, I developed a simple interactive system using the XIAO RP2040, touch pads, onboard NeoPixel RGB LEDs, and an SSD1306 OLED display.

  • Read input from capacitive touch pads
  • Display status on the OLED screen
  • Provide visual feedback using the RGB LED
  • Monitor values through the Arduino Serial Monitor

Initial Challenges

The touch pads produced unstable analog values. Without touching the pad, readings were around 130-190. When touched, readings moved toward extreme values near 0 or 1023. Because of this behavior, the display and RGB LED initially switched states too quickly.

Normal touch values
FIG. 23 - Serial Monitor values without touch
Touch values
FIG. 24 - Extreme analog values when touched
Waiting state
FIG. 25 - OLED waiting state
Touched state
FIG. 26 - OLED touched state

Final Working Logic

  • WAITING: OLED displays WAITING and NeoPixel turns red.
  • TOUCHED: OLED displays TOUCHED and NeoPixel turns green.

Observation: This experiment showed the importance of practical debugging. The initial logic looked correct theoretically, but real hardware behavior required Serial Monitor analysis and threshold tuning.

09 / Challenges

Challenges Faced

  • Installing and configuring RP2040 board support
  • Selecting the correct COM port during upload
  • Understanding I2C pin mapping for the OLED display
  • Fixing missing Arduino library dependencies
  • Debugging unstable touch pad analog readings
  • Understanding datasheet terminology and hardware behavior
10 / Reflection

Reflection

This week helped me understand the relationship between hardware, firmware, programming environments, and debugging tools. I learned that embedded programming is not only about uploading code, but also about checking wiring, board configuration, libraries, communication protocols, and real sensor behavior.

Successfully programmed and tested the Seeed Studio XIAO RP2040 using Arduino IDE, MicroPython, and MicroBlocks, including LED output, OLED display output, touch input, NeoPixel feedback, and Serial Monitor debugging.

01 / Group Assignment

Group Assignment Overview

The group assignment focused on comparing different embedded programming workflows, microcontroller architectures, toolchains, and communication methods. This helped us understand how different boards and environments behave before completing the individual programming task.

The external group assignment page is kept as a backup and for template consistency: Embedded Programming Group Assignment

02 / Microcontroller Architectures

Microcontroller Architecture Comparison

As a group, we compared different microcontroller platforms and discussed how architecture affects programming workflow, pin configuration, memory, speed, and peripheral support.

Board / Chip Key Features
RP2040 Dual-core ARM Cortex-M0+, flexible GPIO, USB support, I2C, SPI, UART, PWM, ADC
AVR / Arduino-style boards Simple programming workflow, mature ecosystem, useful for basic embedded experiments
ESP32 family Integrated wireless communication, higher processing capability, useful for connected devices
03 / Toolchains

Programming Toolchain Comparison

We compared different development environments to understand the advantages and limitations of each workflow.

Environment Use Observation
Arduino IDE C/C++ embedded programming Good for compiling, uploading, and using existing libraries
Thonny / MicroPython Interactive Python-style programming Useful for quick testing and direct board interaction
MicroBlocks Visual block-based programming Helpful for rapid testing and learning basic input/output logic
CircuitPython Python-style embedded workflow Convenient for supported boards and beginner-friendly experimentation
04 / Programming Workflow

Programming and Upload Workflow

The general embedded programming workflow involved selecting the correct board, selecting the correct port, writing or opening a program, compiling it, uploading it to the board, and checking the result through hardware output or serial communication.

  1. Connect the board using USB
  2. Select the correct board type
  3. Select the correct COM port
  4. Write or load a test program
  5. Compile and upload the program
  6. Observe output behavior
  7. Use Serial Monitor for debugging when needed
05 / Communication

Serial Communication and Debugging

Serial communication was an important part of the group discussion because it allows the microcontroller to send debugging information to the computer. This is useful when checking sensor values, board state, program flow, and unexpected hardware behavior.

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println("Debug message from microcontroller");
  delay(1000);
}
06 / Group Summary

Group Assignment Summary

The group assignment helped clarify how different boards and programming environments compare. It also made the individual assignment easier because I had a better understanding of board selection, toolchain setup, uploading, and serial debugging before working on my own XIAO RP2040 experiments.

Completed group exploration of embedded programming workflows, toolchains, microcontroller architectures, and communication methods.