Introduction

In this week of Fab Academy, we learned the basics of Embedded Programming and Embedded Systems. We studied the difference between Embedded Programming and Embedded Systems, along with the concepts of Microcontrollers and Microprocessors, their types, and the differences between them. We also learned about Thonny IDE, including its installation process for programming microcontrollers. Finally, we completed both the group assignment and the individual assignment, where we applied the concepts learned during the week through practical activities.

Embedded Programming

Embedded programming is the process of writing software for embedded systems. It involves creating programs that control the hardware and enable a device to perform a specific task. Embedded programming is commonly done using languages such as C and C++. It is used in devices like home appliances, automobiles, medical equipment, and industrial machines. The goal is to ensure the device operates efficiently, reliably, and in real time.


Embedded System

An embedded system is a small computer built into a larger device to perform a specific task. It consists of both hardware and software that work together to control the device’s functions. Unlike a general-purpose computer, an embedded system is designed for one dedicated purpose. Embedded systems are commonly found in appliances, cars, medical devices, and industrial machines. They help these devices operate efficiently and reliably.

Difference between Embedded Programming and System

Embedded SystemEmbedded Programming
An embedded system is a computer built into a device to perform a specific task.Embedded programming is the process of writing software for an embedded system.
It includes both hardware and software.It focuses only on developing the software.
It is the complete device or system.It is the method used to create the program that controls the system.
Examples: Washing machine controller, car ECU, microwave oven.Examples: Writing C/C++ code for an Arduino, ESP32, or STM32 microcontroller.
It is the product.It is the process of creating the software for the product.

Microcontroller

A microcontroller is a small computer on a single chip that is used to control electronic devices. It contains a CPU, memory, and input/output ports. It takes input, processes the data, and gives the required output. Microcontrollers are commonly used in home appliances, robots, cars, and many smart devices.

Microprocessor

A microprocessor is the main processing unit of a computer and is often called the brain of the computer. It is a small electronic chip that performs calculations, processes data, and controls the working of the system. Unlike a microcontroller, a microprocessor needs external memory and input/output devices to work. It is commonly used in computers, laptops, tablets, and other devices that require high processing power.

Types of Microprocessor

Differences Between Microcontroller and Microprocessor

MicrocontrollerMicroprocessor
A microcontroller is a small computer on a single chip.A microprocessor is the CPU (brain) of a computer.
It has a CPU, memory, and I/O ports on one chip.It mainly contains only the CPU and needs external memory and I/O devices.
It is used for specific control tasks.It is used for general-purpose computing.
It consumes less power.It consumes more power.
It is used in home appliances, robots, and embedded systems.It is used in computers, laptops, and servers.
Example: ATmega328P, PIC16F877A, 8051.Example: Intel Core i5, Intel Core i7, AMD Ryzen.

Individual Assignment

For the Individual Assignment, we needed to browse and study the datasheets of different microcontroller boards to understand their specifications, features, pin configurations, and technical details before selecting the appropriate board for the project.

Group Assignment

For the Group Assignment, we needed to compare five different microcontroller boards by studying their specifications, features, pin configurations, memory, communication options, and performance to understand their differences and choose the most suitable board for different applications.

Here’s a comparison with 15 comparison points between the five microcontroller boards in a simple table format suitable for your report.
Here is a 20-point comparison between the five microcontroller boards in a simple format suitable for your report.

Comparison PointArduino UnoXIAO ESP32-C3XIAO RP2040Raspberry Pi Pico (2020)ESP32 Development Board
1. MicrocontrollerATmega328PESP32-C3RP2040RP2040ESP32
2. Processor Architecture8-bit AVR32-bit RISC-V32-bit ARM Cortex-M0+32-bit ARM Cortex-M0+32-bit Xtensa LX6
3. CPU Cores11222
4. Clock Speed16 MHz160 MHz133 MHz133 MHzUp to 240 MHz
5. Flash Memory32 KB4 MB2 MB2 MB4 MB (typical)
6. SRAM / RAM2 KB400 KB264 KB264 KB520 KB
7. Operating Voltage5 V3.3 V3.3 V3.3 V3.3 V
8. Digital GPIO Pins14111126About 30
9. Analog Input Pins6443Up to 18
10. PWM SupportYesYesYesYesYes
11. ADC Resolution10-bit12-bit12-bit12-bit12-bit
12. DAC SupportNoNoNoNoYes (on some ESP32 variants)
13. Wi-FiNoYes (2.4 GHz)NoNoYes (2.4 GHz)
14. BluetoothNoBluetooth 5.0 LENoNoBluetooth 4.2 + BLE
15. USB ConnectorUSB Type-BUSB Type-CUSB Type-CMicro USBMicro USB / USB Type-C (depends on board)
16. Programming LanguagesArduino (C/C++)Arduino, MicroPython, C/C++Arduino, MicroPython, C/C++MicroPython, C/C++, ArduinoArduino, MicroPython, C/C++
17. Power ConsumptionModerateLowLowLowModerate
18. Built-in Wireless CommunicationNoWi-Fi + BluetoothNoNoWi-Fi + Bluetooth
19. Best ApplicationsLearning, basic electronicsIoT, wearable devices, wireless sensorsRobotics, automation, embedded projectsEducation, robotics, embedded systemsIoT, smart home, automation, industrial projects
20. Main AdvantageEasy for beginners and widely supportedSmall size with built-in Wi-Fi & BluetoothPowerful dual-core processor in a compact sizeLow-cost and highly flexibleHigh performance with fast processor and wireless connectivity

Arduino IDE Workflow

  1. Open the Arduino IDE and write your program (code).
  2. Select the correct Arduino board and COM port.
  3. Click Verify to check if the code has any errors.
  4. Click Upload to send the code to the microcontroller using a USB cable.
  5. After uploading, the microcontroller starts running the program automatically.

MicroPython Workflow

  1. Install the MicroPython firmware on the supported microcontroller board.
  2. Open Thonny IDE and connect the board using a USB cable.
  3. Write your program in Python.
  4. Save or upload the program to the microcontroller.
  5. The program starts running immediately, and you can see the output in the Thonny Shell.

Development Workflow – Comparison Summary

  • Arduino Uno is mainly programmed using C/C++ with the Arduino IDE.
  • ESP32 and Seeed Studio XIAO ESP32-C3 support both C/C++ and MicroPython, providing more programming flexibility.
  • The Arduino IDE is used to write, compile, and upload C/C++ programs to the microcontroller.
  • Thonny IDE is commonly used to write and run MicroPython programs.
  • In the Arduino workflow, the code is compiled before it is uploaded to the board.
  • In the MicroPython workflow, the code runs directly without a separate compilation step.
  • MicroPython is simple to learn and is ideal for beginners and quick testing.
  • C/C++ provides faster execution, better performance, and greater control over the hardware, making it suitable for advanced embedded applications.
  • Both workflows allow developers to create and upload programs easily, but the choice depends on the project requirements and the supported board.
  • Arduino IDE is preferred for performance-focused projects, while MicroPython with Thonny is preferred for rapid development and learning.

Microcontrollers and their datasheet overview

1. Ardunio UNO

Arduino is a small electronic board that works like the brain of a project. It can read inputs from sensors, buttons, and switches, and control outputs like LEDs, motors, and buzzers. We write simple programs using the Arduino IDE and upload them to the board. Arduino is easy to learn and is widely used by students, beginners, and makers to build electronics and automation projects.

Material Used

  • Ardunio UNO
  • Breadboard
  • Resistor
  • LED
  • Cable
  • Jumper wires

I connected the Led and Resistor to the Breadboard using Jumperwires and Connected it to Ardunio UNO board. Then connected the board to the CPU and through Ardunio IDE uploaded it.

// Simple LED Blinking Program

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);   // Set the built-in LED as output
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH); // Turn LED ON
  delay(1000);                     // Wait for 1 second

  digitalWrite(LED_BUILTIN, LOW);  // Turn LED OFF
  delay(1000);                     // Wait for 1 second
}

Ardunio UNO Data Sheet

ParameterSpecification
Board NameArduino Uno R3
MicrocontrollerATmega328P
Operating Voltage5 V
Recommended Input Voltage7–12 V
Input Voltage Limits6–20 V
Digital I/O Pins14
PWM Digital Pins6 (Pins 3, 5, 6, 9, 10, 11)
Analog Input Pins6 (A0–A5)
DC Current per I/O Pin20 mA
DC Current for 3.3 V Pin50 mA
Flash Memory32 KB (0.5 KB used by bootloader)
SRAM2 KB
EEPROM1 KB
Clock Speed16 MHz
USB InterfaceUSB Type-B
Communication ProtocolsUART, I²C, SPI
Power SupplyUSB, DC Barrel Jack, VIN Pin
Length68.6 mm
Width53.4 mm
WeightApproximately 25 g


Embedded programming with Arduino

2. ESP-32

ESP32 is a small and powerful microcontroller used to control electronic devices and IoT (Internet of Things) projects. It has built-in Wi-Fi and Bluetooth, so it can connect to the internet and communicate with other devices. It is commonly used in smart home systems, robots, sensors, and automation projects.

ESP-32 WROOM-32 Data Sheet

ParameterSpecification
ManufacturerEspressif Systems
Module NameESP32-WROOM-32
MicrocontrollerESP32
ProcessorDual-core 32-bit Xtensa® LX6
Clock SpeedUp to 240 MHz
Operating Voltage3.0 V – 3.6 V (3.3 V typical)
Flash Memory4 MB SPI Flash (typical)
SRAM520 KB
ROM448 KB
Wi-FiIEEE 802.11 b/g/n (2.4 GHz)
BluetoothBluetooth v4.2 BR/EDR + BLE
GPIO PinsUp to 32 GPIO pins
ADC18-channel, 12-bit ADC
DAC2-channel, 8-bit DAC
PWMSupported on most GPIO pins
Communication InterfacesUART, SPI, I²C, I²S, CAN (TWAI), SD/SDIO
USB InterfaceExternal USB-to-Serial converter required
Operating Temperature-40°C to +85°C
Power ModesActive, Light Sleep, Deep Sleep
Programming SupportArduino IDE, ESP-IDF, PlatformIO, MicroPython
Typical ApplicationsIoT, Smart Home, Robotics, Automation, Wearable Devices, Wireless Sensor Networks
Package Size18 mm × 25.5 mm × 3.1 mm
AntennaBuilt-in PCB Antenna
Security FeaturesSecure Boot, Flash Encryption, Cryptographic Hardware Acceleration

Thonny

Thonny is a simple and easy-to-use Python Integrated Development Environment (IDE) designed especially for beginners. It allows users to write, run, and debug Python programs easily. Thonny is also used for programming microcontrollers such as the Raspberry Pi Pico, making it a popular tool for learning Python and embedded systems.

Installation of Thonny

Step 1

Step 2

Step 3

Step 4

Step 5

Step 6

Step 7

Step 8

External and Onboard LED woring with ESP-3

On board

I used the simple LED blinking program shown above. After writing the code in Thonny IDE, I clicked the Run button to upload and run the program on the ESP32 board. The onboard LED started blinking, which showed that the program was uploaded successfully and was working correctly.

ESP-32 External LED Blinking

The external LED is connected to GPIO13 and GND of the ESP32 using jumper wires on a breadboard. When the program runs, the ESP32 sends a signal through GPIO13, causing the LED to blink.

Code used for the blinking

from machine import Pin
from time import sleep

led = Pin(13, Pin.OUT)

while True:
    led.on()      # LED ON
    sleep(1)

    led.off()     # LED OFF
    sleep(1)

3. XIAO RP2040

The Seeed Studio XIAO RP2040 is a small and powerful microcontroller board based on the Raspberry Pi RP2040 chip. It is used for embedded systems, robotics, IoT, and electronics projects. The board has a dual-core ARM Cortex-M0+ processor running at 133 MHz, along with 2 MB of flash memory and 264 KB of SRAM. It supports programming with Arduino IDE, MicroPython, and CircuitPython, making it suitable for both beginners and advanced users. Its compact size and multiple GPIO pins make it easy to connect sensors, LEDs, and other electronic components.

Data sheet of XIAO RP2040

ParameterSpecification
ManufacturerSeeed Studio
Board NameXIAO RP2040
MicrocontrollerRaspberry Pi RP2040
ProcessorDual-core ARM Cortex-M0+
Clock SpeedUp to 133 MHz
Flash Memory2 MB
SRAM264 KB
Operating Voltage3.3 V
Input Voltage5 V via USB Type-C
GPIO Pins11 GPIO Pins
Analog Inputs (ADC)4 Channels (12-bit ADC)
PWMSupported on all GPIO pins
Communication InterfacesUART, I²C, SPI
USB InterfaceUSB Type-C
On-board RGB LEDYes (WS2812 RGB LED)
User LEDYes
Reset ButtonYes
Boot ButtonYes
Programming SupportArduino IDE, MicroPython, CircuitPython
Operating Temperature-20°C to +70°C (Typical)
Board Size20 mm × 17.5 mm
ApplicationsEmbedded Systems, IoT, Robotics, Wearable Devices, Automation, DIY Electronics

On Board LED Blinking

I connected the cable to CPU and XIAO RP2040 to Breadboard

Code used for the Blinking

#include <Adafruit_NeoPixel.h>

#define LED_POWER 11      // Enable power to the RGB LED
#define LED_PIN   12      // Data pin for the WS2812 RGB LED
#define NUMPIXELS 1

Adafruit_NeoPixel rgb(NUMPIXELS, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  pinMode(LED_POWER, OUTPUT);
  digitalWrite(LED_POWER, HIGH);   // Turn ON power to RGB LED

  rgb.begin();
  rgb.clear();
  rgb.show();

  Serial.begin(115200);

  while (!Serial);

  Serial.println("===== XIAO RP2040 RGB Control =====");
  Serial.println("Commands:");
  Serial.println("red");
  Serial.println("green");
  Serial.println("blue");
  Serial.println("yellow");
  Serial.println("cyan");
  Serial.println("purple");
  Serial.println("white");
  Serial.println("off");
}

void loop() {

  if (Serial.available()) {

    String cmd = Serial.readStringUntil('\n');
    cmd.trim();

    if (cmd == "red")
      rgb.setPixelColor(0, rgb.Color(255, 0, 0));

    else if (cmd == "green")
      rgb.setPixelColor(0, rgb.Color(0, 255, 0));

    else if (cmd == "blue")
      rgb.setPixelColor(0, rgb.Color(0, 0, 255));

    else if (cmd == "yellow")
      rgb.setPixelColor(0, rgb.Color(255, 255, 0));

    else if (cmd == "cyan")
      rgb.setPixelColor(0, rgb.Color(0, 255, 255));

    else if (cmd == "purple")
      rgb.setPixelColor(0, rgb.Color(255, 0, 255));

    else if (cmd == "white")
      rgb.setPixelColor(0, rgb.Color(255, 255, 255));

    else if (cmd == "off")
      rgb.setPixelColor(0, rgb.Color(0, 0, 0));

    rgb.show();
  }
}

4. XIAO ESP32C3

The Seeed Studio XIAO ESP32-C3 is a compact and powerful microcontroller board based on the ESP32-C3 chip from Espressif. It is designed for IoT, embedded systems, robotics, and smart electronics projects. The board has a 32-bit RISC-V processor running at 160 MHz, along with built-in Wi-Fi and Bluetooth Low Energy (BLE) for wireless communication. It supports programming using the Arduino IDE, MicroPython, and ESP-IDF, making it suitable for both beginners and advanced users. Its small size, low power consumption, and built-in wireless connectivity make it ideal for portable and connected devices.

Data sheet of XIAO ESP32C3

ParameterSpecification
ManufacturerSeeed Studio
Board NameXIAO ESP32-C3
MicrocontrollerESP32-C3
ProcessorSingle-core 32-bit RISC-V
Clock SpeedUp to 160 MHz
Flash Memory4 MB
SRAM400 KB
Operating Voltage3.3 V
Input Voltage5 V via USB Type-C
GPIO Pins11 GPIO Pins
Analog Inputs (ADC)4 Channels (12-bit ADC)
PWMSupported
Communication InterfacesUART, I²C, SPI
Wi-FiIEEE 802.11 b/g/n (2.4 GHz)
BluetoothBluetooth 5.0 Low Energy (BLE)
USB InterfaceUSB Type-C
On-board RGB LEDYes (WS2812 RGB LED)
Reset ButtonYes
Boot ButtonYes
Programming SupportArduino IDE, ESP-IDF, MicroPython
Operating Temperature-40°C to +85°C
Board Size20 mm × 17.5 mm
ApplicationsIoT, Smart Home, Robotics, Automation, Wearable Devices, Wireless Sensor Networks

LED blinking

Code used

const int LED_PIN = 1;   // GPIO1

void setup() {
  pinMode(LED_PIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_PIN, HIGH);  // Turn LED ON
  delay(1000);                  // Wait for 1 second

  digitalWrite(LED_PIN, LOW);   // Turn LED OFF
  delay(1000);                  // Wait for 1 second
}