ABOUT ASSIGNMENTS

WEEK 4: Embedded Programming

Group Assignment

Demonstrate and compare the toolchains and development workflows for available embedded architectures

Individual Assignment

Browse through the data sheet for a microcontroller
Write and test a program for an embedded system using a microcontroller to interact with local input &/or output devices and communicate with remote wired or wireless connections

Extra Credit Goals

Assemble the system
Try different programming languages &/or development environments


Group Assignment:


We learnt about different toolchains of different microcontrollers from different computer architectures. Along with that we compared our results to Rasberry Pi also, which is a full fledged computer rather than a microcontroller. Here is the link for the group assignment: https://fabacademy.org/2026/labs/kochi/group_assignmetns/week04/
This week we explored XIAO RP2040 microcontroller by first inspecting it's datasheet and programming and simulating it via Arduino IDE.


Individual Assignment:

XIAO RP2040

XIAO RP2040is a tiny microcontroller board made by Seeed Studio, using the RP2040 chip (from Raspberry Pi).It features a dual-core ARM Cortex-M0+ processor running up to 133 MHz, 2 MB of flash memory, and 264 KB of SRAM. The board includes 11 GPIO pins that support digital input/output, analog input (ADC), PWM, I2C, SPI, and UART communication.

The board provides 11 GPIO pins that support multiple communication and control interfaces, including:

Digital input and output
Analog input (ADC)
PWM (Pulse Width Modulation)
I2C communication
SPI communication
UART communication

The board uses a USB-C connector for programming and power supply. Due to its compact size and versatile features, it is well suited for embedded systems, Internet of Things (IoT) devices, robotics applications, and wearable electronics. The XIAO RP2040 can be programmed using Arduino, MicroPython, CircuitPython, or C/C++.



Hardware Overview




XIAO ESP32-C6

ESP32-C6 is a low-power microcontroller developed by Espressif that includes built-in Wi-Fi and Bluetooth connectivity. It uses a 32-bit RISC-V processor and is designed for wireless applications such as IoT devices, smart home systems, and robotics. The XIAO ESP32-C6 is a low-power microcontroller developed by Espressif that includes built-in Wi-Fi and Bluetooth connectivity. It uses a 32-bit RISC-V processor and is specifically designed for wireless applications.

This microcontroller is suitable for applications such as:
IoT systems
Smart home devices
Robotics

The ESP32-C6 can connect directly to the internet and control external components such as sensors, motors, and LEDs. It can also communicate with web servers and cloud platforms without requiring a wired connection. It supports GPIO, ADC, PWM, SPI, I2C, UART, and USB interfaces, making it ideal for fully wireless embedded systems like a desktop companion robot.



XIAO ESP32C6 Pin List



The Arduino IDE is used to write, compile, and upload programs to microcontrollers. To learn about the arduino basic function, check out this Website.

Installing ARDUINO IDE


Go to - Arduino IDE

to install and follow the given steps:


Downloaded and installed the Arduino IDE from the official Arduino website.



Go to "select board" panel on top of the page



select the board of your choice


After completing these steps, the Arduino IDE was ready for programming.

I have listed some definitions for some terms used in programming:

Function: A block of code that performs a specific task and reused at different parts of the code, eg: sleep in Micropython
Class: A 'blueprint' for creating objects, eg: Pin in Micropython
Object: A specific implementation of the class, with variables containing data specific to that object
Module: A file containing multiple Python functions, classes, and variables. eg: machine
Loop: A loop is used to repeatedly execute a block of code until a specified condition is met.
Example:
while True: in Python
void loop() in Arduino
If no condition is specified, the loop runs indefinitely (infinite loop).



Program 1: Controlling an external LED

Language: C/C++
Microcontroller: RP2040
Board: Rasberry Pi Pico
Environment: ARDUINO IDE





#define creates a constant named USER_LED_G.
It assigns the value 16, which is the GPIO pin number where the LED is connected.
This makes the code easier to read and modify.
setup() runs only once when:
- The board is powered on, or
- The reset button is pressed.
pinMode() sets the pin mode.
OUTPUT → sets pin 16 as an output pin.
loop() runs continuously forever. This is where the main program runs repeatedly.
digitalWrite() sends voltage to the pin.
HIGH means ON (3.3V)
delay pauses the program.
1000 milliseconds = 1 second

Program 2: Controlling multiple LEDs


Language: C/C++
Microcontroller: RP2040
Board: Rasberry Pi Pico
Environment: ARDUINO IDE



Following is the commented code for the program:


Program 3: Controlling an LED using button

Language: C/C++
Microcontroller: RP2040
Board: Rasberry Pi Pico
Environment: ARDUINO IDE



Following is the commented code for the program:


THONNY - Python IDE

Thonny is an integrated development environment (IDE) developed by the THONNY IDE team, tailored for beginners eager to learn Python programming. This free and open-source software provides a simplified solution to coding challenges, enabling users to focus on mastering the fundamentals of Python without unnecessary distractions. With its emphasis on ease of use, Thonny stands out as a key resource for novices entering the world of coding. This software is an ideal starting point for beginners or educators seeking a clear, visual, and accessible coding language.

Installing THONNY


Clink on THONNY IDEto install THONNY and also to find information regarding the software.
It will take you to the following page:


Click on download, after downloading this is how the page looks like:


The following is the code run to blink various lights on the XIAO RP2040 board:


Output:



The following are the main difference between both Enviorments:

Personally i prefer the ARDUINO IDE more, i found it easy to use because i felt that the code was more comprehendible compared to THONNY.

Getting Started with Seeed Studio XIAO ESP32C3 & Grove starter kit for SEEEDUINO LOTUS



Go to this Grove starter kit website and ESP32C3 to know how to set it up.

First i tried out the buzzer program with the grove starter kit.





Analogwrites - Writes an analog value (PWM wave) to a pin. It came out perfect.

Next, i tried to set up OTA, now this was tricky, took me 2-3 tries to set it up.


The wifi code is available in the ESP32C3 website and additionally i have attached it in the Final Files section or you can watch this Youtube video which tells you an alternative way.

Below is the line by line explanation of the wifi code:


After running the code, remember to set your port to network ports for OTA.


Then i tried sending code over wifi , but i kept on failing miserably. Took me one hour to figure out that when you're sending data over wifi you need to have the wifi code integrated to the rest of the code, because as you upload data the initial set up of OTA code gets overwritten. Also make sure that your serial monitor is closed, because the serial monitor cannot run during OTA

Final Files

DOWNLOAD ARDUINO FILES
DOWNLOAD THONNY FILES