Week 3: Embedded Programming¶
Group Assignment Requirements¶
- Demonstrate and compare the toolchains and development workflows for available embedded architectures
- Document work to the group work page and reflect on your individual page what you learned
During this week we started by learning about the electronic basic concepts , primarly focusing on microprocessers and microcontrollers
Architecture Comparison¶
| Feature | ESP32‑C3 | ESP8266 | ATtiny48 | XIAO RP2040 | Arduino Uno |
|---|---|---|---|---|---|
| Core / Arch. | RISC‑V 32‑bit | Tensilica L106 32‑bit | AVR 8‑bit | Dual ARM Cortex‑M0+ 32‑bit | AVR 8‑bit |
| Max Clock | 160 MHz | 80/160 MHz | 12 MHz | 133 MHz | 16 MHz |
| Flash | 4 MB | 4 MB typical | 4 KB | 2 MB | 32 KB |
| SRAM | 400 KB | 160 KB | 256 B | 264 KB | 2 KB |
| Digital I/O | ~22 | 16 | 24 | 26 | 14 |
| Analog Inputs | 6+ | 1 | 6–8 | 3 | 6 |
| PWM | Yes | Yes | Yes | Yes | Yes |
| Voltage | 3.3 V | 3.3 V | 1.8–5.5 V | 3.3 V | 5 V |
| Connectivity | Wi‑Fi / BLE | Wi‑Fi | I²C / SPI | USB / UART / SPI / I²C | UART / SPI / I²C |
Our Instructor Naim Haj-Ali explained the key concepts of
- Differentiating Microprocesser from a microcontroller
- Soldering Techinques
- Arduino IDE interface
- Datasheet exploration
- Debugging and Troubleshooting examples
Important Abbreviations and Definitions¶
| Abbreviation | Meaning |
|---|---|
| MHz | Megahertz – CPU clock speed (millions of cycles per second). |
| KB / MB | Kilobyte / Megabyte – memory size (1 KB = 1024 bytes). |
| SRAM | Static Random-Access Memory – fast, volatile memory used for program execution. |
| PWM | Pulse Width Modulation – method to simulate analog output using digital signals. |
| GPIO | General Purpose Input/Output – pins that can be programmed as input or output. |
Connectivity Definitions¶
-
Wi‑Fi – Wireless networking standard for connecting devices to the internet or local networks.
-
BLE (Bluetooth Low Energy) – Low-power wireless communication for IoT and peripheral devices.
-
UART (Universal Asynchronous Receiver/Transmitter) – Serial communication protocol for simple device-to-device data exchange.
-
SPI (Serial Peripheral Interface) – High-speed synchronous communication protocol for sensors, memory, and other peripherals.
-
I²C (Inter-Integrated Circuit) – Two-wire communication protocol for connecting multiple devices on the same bus.
- USB (Universal Serial Bus) – Standard wired connection for data transfer and device programming.¶
Toolchains introdution¶
Arduino IDE – A beginner-friendly, cross-platform environment to program boards like Arduino Uno, ESP32, and XIAO RP2040 using C/C++. It handles compilation, libraries, and flashing to the MCU.
MicroPython / CircuitPython – Lightweight Python interpreters for microcontrollers. Allow programming directly in Python, ideal for rapid prototyping on boards like ESP32, XIAO RP2040, and¶
Tests¶
A speed test to compare RP2040 vs ESP32 vs Arduino Uno¶
We did a speed test to compare the performance of the RP2040, ESP32, and Arduino Uno microcontrollers. The test involved running a program that figured out the binary numbers from 0 to 5000 and measured the time taken by each microcontroller to complete the task. The results showed that the RP2040 was the fastest, followed by the ESP32, and then the Arduino Uno.
void setup() {
Serial.begin(115200);
while (!Serial); // Wait for Serial to open
delay(2000);
Serial.println("--- Speed Test Start ---");
long startTime = micros();
// Benchmark: Find primes up to 5000
int count = 0;
for (int i = 2; i < 5000; i++) {
bool isPrime = true;
for (int j = 2; j <= sqrt(i); j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) count++;
}
long endTime = micros();
Serial.print("Primes found: ");
Serial.println(count);
Serial.print("Time taken (us): ");
Serial.println(endTime - startTime);
Serial.println("--- Test Complete ---");
}
void loop() {}
Here are the results we got from the test: | Microcontroller | Time Taken (µs) | |-----------------|------------------| | Arduino Uno | 1148340 | | ESP32-c3 | 374423 | | RP2040 | - |
If you want to run this test on your own microcontroller make sure to : 1. Select the correct board and port in the Arduino IDE before uploading the code. 2. Open the Serial Monitor and make sure to choose the correct baud rate (115200 baud) to view the output results.