Embedded Programming
Embedded Programming is the process of writing software to control hardware-based systems. These systems—like microcontrollers—are embedded into devices to perform specific tasks. Unlike general-purpose computers, embedded systems are resource-constrained and highly optimized for real-time control, data collection, and automation.
What Is an Embedded System?
An embedded system is a combination of hardware and software designed to do a dedicated function. Examples include:
-
Microwave oven controller
-
Smartwatches
-
Car engine control units (ECUs)
-
IoT devices (e.g., weather stations, fitness bands)
These devices usually run on microcontrollers (like AVR, ARM Cortex, ESP32, etc.) or microprocessors and have limited resources (memory, power, etc.).
Key Concepts in Embedded Programming
Concept | Explanation |
---|---|
Microcontroller | A small computer on a single chip (e.g., ATmega328P, ESP32, STM32) |
Firmware | Software that is permanently programmed into ROM/Flash |
Registers | Memory locations inside a microcontroller used to control hardware |
Interrupts | Events that temporarily pause normal code to handle high-priority tasks |
Timers | Hardware tools to measure or generate time intervals |
GPIO | General Purpose Input/Output pins for sensors, LEDs, buttons, etc. |
Drivers | Code that communicates with external peripherals (sensors, displays, etc.) |
RTOS | Real-Time Operating System for task scheduling (optional, for complex apps) |
Typical Embedded Programming Workflow
1) Write Code in C/C++ (Arduino, PlatformIO, STM32CubeIDE, etc.)
2) Compile the code into machine language (e.g., .hex, .bin)
3) Flash the code into the device’s memory via USB or programmer
4) Test and Debug using serial monitor, LEDs, or debuggers
5) Optimize for speed, memory, and power
Group Assignment: Exploring Different Boards
As part of the group assignment, we explored different microcontroller workflows. Here’s a quick overview of the boards we worked with:
For this week’s group activity, our Fab Academy colleagues Samruddhi and Sharvari took the lead and carried it out. The documentation for this is linked.
Toolchain and Workflow Comparison
I explored, programmed, and compared multiple microcontroller families using distinct toolchains. The microcontrollers I worked with are:
- Arduino Uno
- Arduino Nano
- ESP8266 NodeMCU
- Seeed Studio XIAO RP2040
- Seeed Studio XIAO ESP32-S3
Feature / Board | Arduino Uno | Arduino Nano | NodeMCU ESP8266 | XIAO RP2040 | XIAO ESP32-S3 |
---|---|---|---|---|---|
Architecture | AVR (ATmega328P) | AVR / RP2040 | Xtensa LX106 | ARM Cortex-M0+ (RP2040) | Xtensa LX7 (ESP32-S3) |
Programming Language | C/C++ | C/C++ | C/C++ | C/C++, MicroPython | C/C++, MicroPython |
Main IDEs | Arduino IDE, PlatformIO | Arduino IDE, PlatformIO | Arduino IDE, PlatformIO | Arduino IDE, Thonny, VS Code | Arduino IDE, PlatformIO |
Compiler | avr-gcc |
avr-gcc / arm-none-eabi-gcc |
xtensa-lx106-elf-gcc |
arm-none-eabi-gcc |
xtensa-esp32s3-elf-gcc |
Uploader | avrdude (USB) |
avrdude / DFU |
esptool.py (UART) |
Drag & drop / UF2 bootloader | esptool.py / USB CDC |
Bootloader | Optiboot | Optiboot / UF2 | NodeMCU Bootloader | UF2 bootloader | ROM bootloader |
USB Support | Emulated via UART | Emulated / Native USB | Native USB-UART | Native USB (MSC + CDC) | Native USB + UART |
OTA Support | ❌ | ❌ | ✅ (via Wi-Fi) | ❌ | ✅ (via Wi-Fi, BLE) |
RTOS Support | ❌ | ❌ | Basic (Non-RTOS) | FreeRTOS (optional) | ✅ (FreeRTOS) |
Debugging | Serial.print only |
Serial.print |
Serial.print |
CMSIS-DAP (advanced) | JTAG + Serial |
For this assignment, I explored the ESP32-S3 microcontroller using the Wokwi simulator. The goal was to simulate real-world embedded programming tasks, interact with input/output devices, and document the process. Here's a detailed breakdown of the journey:
XIAO ESP32-C3
The Seeed Studio XIAO ESP32-S3 is a powerful, compact microcontroller board based on Espressif’s ESP32-S3 chip. It supports Wi-Fi and Bluetooth LE (5.0), making it ideal for IoT projects.
This site helped alot getting started with esp32 : SeeedStudio
XIAO_ESP32C3 Datasheet : Datasheet
Key Features:
- CPU: 32-bit RISC-V single-core, 160 MHz
- Wireless: Wi-Fi + BLE 5.0
- Flash: 4MB
- GPIOs: 11 usable pins (supports ADC, PWM, I2C, SPI, UART)
- USB-C for programming & power
- Super compact: 21mm x 17.5mm
Getting Started with Wokwi
Objective: Explore the Wokwi platform and familiarize myself with the ESP32-S3 microcontroller.
- I began by signing into Wokwi and creating a new project. Selected the ESP32-S3 board and Arduino template for the simulation environment.
Blinking LED with Serial Monitor
- Chose a template of blinking Led.
- played with the vaules and tried changing words .
Experiments
1 Servo with 1 Joystick
To begin, I wanted to test the basics — controlling a single servo motor using just the X-axis of a joystick. I used the Seeed XIAO ESP32-S3 board and simulated everything on Wokwi.
In Wokwi, I used the following components:
-
Seeed XIAO ESP32-S3
-
Joystick module (x-axis and y-axis)
-
Servo motor (SG90 or similar)
-
Wires
CIRCUIT CONNECTIONS
Joystick Module
A joystick has 5 pins usually:
-
VCC → Connect to 3.3V on the XIAO
-
GND → Connect to GND
-
VRx (X-axis) → Connect to A0 (GPIO1) on XIAO ESP32-S3
-
VRy (Y-axis) → Connect to A1 (GPIO2) (optional for now)
-
SW (button press) → You can leave it unconnected for this project
Servo Motor
-
Signal → Connect to D6 (GPIO6) on XIAO
-
VCC → Connect to 5V (or 3.3V, if using low-power servo in simulation)
-
GND → Connect to GND
CODE
Realization About the Servo Library
At first, I tried using the regular Servo.h library, but I got a compiler error saying it doesn't support ESP32-S3. So I switched to the ESP32Servo library, which works perfectly with the XIAO board.
2 servo 1 Joystick
I wanted to control two servo motors using a single joystick module, with each axis of the joystick controlling one servo. I used the Seeed XIAO ESP32-S3 because it’s compact and supports analog input and PWM output, and I simulated everything using Wokwi.
Components I Used -
-
Seeed XIAO ESP32-S3
-
Joystick module (with X and Y outputs)
-
2x Servo motors (SG90)
-
Jumper wires
Circuit Connections
Joystick Wiring:
-
VCC → 3.3V on XIAO
-
GND → GND
-
VRx (X-axis) → GPIO1 (A0)
-
VRy (Y-axis) → GPIO2 (A1)
-
SW (button) → (Not used for this project)
Servo Wiring:
-
Servo 1 signal → GPIO6
-
Servo 2 signal → GPIO7
-
Both servo VCCs → 5V (simulation), or external 5V in real life
-
Both servo grounds → GND
CODE