4. Embedded Programming¶
This week’s group assignment was to demonstrate and compare the toolchains and development workflows for available embedded architectures.
Demonstrate and compare toolchains and development workflows¶
We tried out 4 microcontrollers.
Microcontroller: | Espressif ESP32 | AVR AtMega328P | AVR AtMega32U4 | ARM RP2040 |
---|---|---|---|---|
Dev Board: | M5StackCore | Arduino Uno | Arduino Pro Micro | Xiao RP2040 |
CPU: | 240MHz Dual-Core | 16MHz Single-Core | 16MHz Single-Core | 133MHz Dual-Core |
Memory (SRAM/Flash): | 520KB / 16MB | 2K / 32K | 2.5KB/ 32KB | 264KB / 2MB |
Size (mm): | 54 × 54 x 16 | 68.6 × 53.4 | 34 x 18 x 13 | 20.0 x 17.5 x 3.5 |
Price (JPY, Approx.): | 5,500 | 3,300 | ~1,000 | 1,400 |
Setting up the Arduino environment
First we checked the Arduino IDE application in our computer.
If we don’t have it yet, we have to download it from Internet:
All our boards were compatible with Arduino IDE.
Arduino IDE is a free, open-source program that lets you write and upload code to Arduino boards. It includes a text editor, a toolbar, and other tools for working with code. - arduino.cc
Steps:
ESP32 (M5StackCore)¶
Board Characteristics¶
M5StackCore is a modular, stackable, scalable, and portable device which is powered with an ESP-32 core, which makes it open source, low cost, full-function, and easy for developers to handle new product development on all stages including circuit design, PCB design, software, mold design and production - m5stack.com
Component | Spec |
---|---|
Micro controller | ESP32-D0WDQ6-V3(240MHz dual core) |
Memory | 520KB(SRAM), 16Mb(Flash) |
Port | TypeC x 1, GROVE(I2C+I/0+UART) x 1 |
voltage | 5V @ 500mA |
Speaker | 1W-0928 |
Battery | 110mAh @ 3.7V |
Screen | 2 inch, 320x240 Colorful TFT LCD, ILI9342C, max brightness 853nit |
Size | 54 x 54 x 18mm |
Weight | 47.2g |
Other | Wi-fi, Buttons, etc |
M5Stack Datasheet from M5stack.
Toolchains¶
Arduino, MicroPython
Development Workflow¶
We set up the Arduino IDE for M5Stack.
We tested the program worked on M5
1. Plug in
USB C
2. Download and select Boardcore
Select the Board Manager
Enter “esp32” for selecting the manager.
Push Install button for install it.
However Arduino couldn’t find the M5’s port, we need add M5stack Board Manager.
Then M5Stack board manager is appeared.
So it is installed.
3. Select Port
Automatically selected right port.
4. Upload code We found the great program which alumni work to check the M5 and we used it.
#include <M5Stack.h>
void setup() {
M5.begin();
M5.Power.begin();
}
void loop() {
M5.Lcd.fillTriangle(random(M5.Lcd.width() - 1), random(M5.Lcd.height() - 1), random(M5.Lcd.width() - 1), random(M5.Lcd.height() - 1), random(M5.Lcd.width() - 1), random(M5.Lcd.height() - 1), random(0xfffe));
M5.update();
}
Result:
We could successfully download the program to M5 and checked it’s working.
*Don’t forget to connect the cord!
Arduino¶
We tried 2 Arduino boards
Specs | Arduino Uno | Arduino Pro Micro |
---|---|---|
Processor | ATMega328P (AVR CPU at up to 16 MHz) |
ATmega32U4 16MHz |
Memory | 2KB(SRAM), 32KB(Flash), 1KB(EEPROM) | 2.5KB(SRAM), 32KB(Flash), 1KB(EEPROM) |
Port | USB B | Micro USB |
Interface | 14x GPIO 16x Analog input pins 1x USART 1x SPI 1x I2C 1x Analog Comparator (AC) |
20x GPIO 12x Analog input pins 1x UART 1x SPI 1x I2C |
voltage | 2.7-5.5 volts | 7-12V |
Weight | 25 g | 13 g |
Size | 53.4 x 68.6 mm | 18 x 48 mm |
UNO R3 Datasheet from Arduino.
Arduino Uno:
Arduino Pro Micro:
We also tried the same code with Arduino Pro Micro
Toolchains¶
Arduino, MicroPython
Development Workflow¶
We set up aruduino.
1. Plug in
For Arduino UNO, USB Type-B (2.0)
For Arduino Pro Micro, Micro USB Type-B (2.0)
2. Select Boardcore
Go to Board Manager, and if you haven’t installed the RP2040, install it. This time, I already had the one.
After install, board manager, choose the Board from ”Tools” menu.
For Arduino UNO, choose “Arduino UNO”
For Arduino Pro Micro, choose “Arduino Micro”
3. Select Port
Then, Select Port from ”Tools” menu.
*This screenshot is for xiao RP2040, but basically, the flow is same. Please choose the port which is connected with your board.
4. Upload code
We made the code with Arduino.
When the LED turn on, it says “LED is ON…Hooray!!!” in serial monitor.
When the LED turn off, it says “LED is OFF…Booooo!!” in serial monitor.
// Program to blink one led
// by Kamakura group fab academy 2025
int led Pin = 7;
int waitTime = 100;
void setup() {
pinMode(9,OUTPUT); //LED connected as output device to pin 9
Serial.begin(9600); // Turn on serial monitor at 9600 baud rate(communication speed)
}
void loop() {
digitalWrite(9,HIGH); // Turn on LED at pin 9
Serial.println("LED is ON...Hooray!!!");
delay(waitTime); //Wait 1 second
digitalWrite(9,LOW); // Turn off LED at pin 9
Serial.println("LED is OFF...Booooo!!");
delay(waitTime); //Wait 1 second
}
After you finish write the code:
Click “Verify” to Check the code before upload.
Click “Upload” to upload to the board
You can see serial monitor from here, the magnifying glass icon button right side.
It seems it works.
Arduino UNO | Arduino Pro Micro |
---|---|
The message also show up in serial monitor.
RP2040 (Seeed Xiao RP2040)¶
Xiao RP2040 is a tiny thumb-sized, low cost, low-power MCU with powerful powerformance and flexible compatibility. It pairs RP2040 MCU with PMIC (Power Management), USB Type-C.
Board Characteristics¶
Component | Spec |
---|---|
Processor | 32 bit, Dual-core ARM Cortex M0+ |
Memory | 264KB of SRAM, 2MB of onboard Flash memory |
Interface | 11 digital pins, 4 analog pins, 11 PWM Pins,1 I2C interface, 1 UART interface, 1 SPI interface, 1 SWD Bonding pad interface |
Maximum voltage | All the I/O pins are 3.3V |
Other | Reset button, Boot button, programmable RGB LED, Power LED, Status indicator, User specified LED |
Toolchains¶
Supports Arduino, C/C++, Micropython, CircuitPython (A python-based language which is beginner-friendly).
Development Workflow¶
1.Make the circuit
We plugged the Xiao RP2040 on the breadboard and wired the transistor and LED.
2.Plug in
We connected the Xiao RP2040 with the computer via the in-built Type-C USB.
3.Select Boardcore and Port
We had already installed the Boardcore for Xiao RP2040 on Arduino IDE during Bootcamp, so we simply selected the Board and Port.
4.Write and upload code
We used the same code for previous tests, and just changed the pin number.
// Seeed Studio Xiao
// RP2040
// Program to blink one led
// by Kamakura group fabacademy 2025
int ledPin = D9;
int waitTime = 1000;
void setup() {
pinMode(ledPin, OUTPUT); // LED connected as output device to pin9
Serial.begin(9600); // Turn on serial monitor at 9600 and baud rate (comm. speed)
}
void loop() {
digitalWrite(ledPin,HIGH); //Turn on LED at pin 9
Serial.println("LED is on...Hooray!!");
delay(waitTime); //Wait 1 second
digitalWrite(ledPin, LOW); //Turn off LED
Serial.println("LED is off...Booooo!!");
delay(waitTime);
}
And clicked “Upload”
5. Debug
After the upload was completed, the serial monitor was displaying properly, but the LED was not blinking. So we figured that it was something to do with the hardware.
First we tried changing the breadboard, but nothing happened.
Then we changed the pin number to D9, and it worked!
Our Learning:
For Xiao boards, use the pin# starting from D rather than just the number.
Thoughts¶
If any