Table of Contents
- Group Assigment
- Compare as many tool options as possible.
- Document your work on the group work page and reflect on your individual page what you learned.
- Individual Assigment
- Write an application for the embedded board that you made. that interfaces a user with an input and/or output device(s)
- Final Project Development
This week my laptop broke down suddenly so it needed to be repaired but the technicians were out of town, so I had to wait.
However if I waited then i would not have been able to update my documentation so I got another laptop.
Since the new laptop didn’t have my previous setup, I had to start by pulling my documentation folder from the repository.
I followed the same steps I had done duringweek 1.
To briefly recap, I generated a new SSH key because this was a different device and the GitLab server didn’t recognize it yet.
After generating the SSH key, I copied the public key and added it to my GitLab account under SSH Keys. This allowed me to securely connect to my repository using SSH.
Then I used Git to pull my documentation folder and began working on it just like before.
- Opened Git Bash or Command Prompt: On Windows, I opened Git Bash (you can also use Command Prompt or PowerShell).
- Ran the SSH Key Generation Command: I entered the following command:
ssh-keygen -t ed25519 -C "youremail@gmail.com"
- -t ed25519: Specifies the type of key (recommended).
- -C "..." : Adds a label (your email) to identify the key.
- Pressed Enter to Accept the Default File Location: I just hit Enter when it asked where to save the key, so it saved to the default path:
C:\Users\YourName\.ssh\id_ed25519
- (Optional) Added a Passphrase: I was asked to enter a passphrase. I could either leave it blank (just press Enter) or add one for extra security.
- Copied the Public Key: Then I copied the key using this command:
or by opening the file in a text editor:cat ~/.ssh/id_ed25519.pub
C:\Users\YourName\.ssh\id_ed25519.pub
- Pasted the Key into GitLab: Went to GitLab > Preferences > SSH Keys, pasted the key into the field, and saved it.

After generating the SSH key, I copied the public key and added it to my GitLab account under SSH Keys. This allowed me to securely connect to my repository using SSH. Then I used Git to pull my documentation folder and began working on it just like before.

- Set My Global Git Username: I ran the following command to set my global username for Git:
git config --global user.name "tsheltrimlhamo2021"
- Set My Global Git Email: I ran this command to set my global email for Git:
git config --global user.email "tsheltrimlham2021@academy.bt"
- Initialized the Git Repository: Since the folder wasn't a Git repository yet, I ran the following command to initialize it:
git init
- Added Files to the Git Repository: After initializing, I added all the files using:
git add .
- Committed the Changes: I committed my changes with a message:
git commit -m "Initial commit"
- Linked the Repository to GitLab: I then linked my local repository to the GitLab repository with:
git remote add origin https://gitlab.com/your-username/your-repo.git
- Pushed the Changes to GitLab: Finally, I pushed the changes to GitLab with:
git push -u origin master

Group Assignment
For the group assignment, we You can access the group assignment here
Individual Assignment
Tkinter
Tkinter is a built-in Python library that facilitates the creation of graphical user interfaces (GUIs) for applications. It provides a variety of widgets such as buttons, text boxes, labels, and menus, allowing developers to design interactive interfaces for their programs. To begin with Tkinter, I first had to download the python application from google. First search python download on google. Then select your preferred options and proceed with the installation. Then to check if python is installed in my laptop I used a command in terminal.

I installed pyserial using pip (with a command like pip install pyserial) so that Python could use the serial module — specifically serial.Serial() — to communicate with hardware like Arduino or other microcontrollers over a serial port (USB, COM, etc.).
By default, Python doesn't include the serial module. The installation step ensures that the pyserial package is added, which gives:
import serial
Without installing it, you'd get an error like ModuleNotFoundError: No module named 'serial'.

Getting Started with Tkinter!
Before coding, I first created a Python file in Visual Studio Code (VSCode). I saved the file with a .py
extension and made sure to select Python as the programming language.
Before running a program, I watched a tutorial I understood I needed to install the Python extension in VSCode. After installing it, I wrote a code prompting AI and it worked successfully!
Now that the setup is done, it’s time to get serious with more coding…
Fundamental Tkinter Code I Learned
1. Importing Tkinter
import tkinter as tk
2. Creating the Main Window
root = tk.Tk()
3. Adding Widgets (Labels, Buttons, etc.)
label = tk.Label(root, text="Hello, Tkinter!")
button = tk.Button(root, text="Click me!")
4. Organizing Widgets Using Geometry Managers
Using pack:
label.pack()
button.pack()
Using grid:
label.grid(row=0, column=0)
button.grid(row=1, column=0)
5. Configuring Widget Properties
label.config(font=("Arial", 12), fg="blue")
button.config(bg="green", command=some_function)
6. Defining Event Handlers
def some_function():
print("Button clicked!")
7. Running the Main Event Loop
root.mainloop()
Next up, I’ll try designing my own GUI — just before I begin working on the LED switch project!
Bhutanese look to Buddhist astrology for all sorts of reasons from major events such as marriage and partner compatibility.
Akin to the Chinese and Tibetan cultures, Bhutanese have 12 zodiac signs represented by 12 animals.
The twelve animals are believed to be the audience before Buddha passed into Mahaparinirvana, according to an oral tradition. Each animal represents a certain month and year and 12 years is considered one cycle.
So I designed a GUI to calculate the zodiac based on ones birth year with the help of AI

import tkinter as tk from tkinter import ttk def chinese_zodiac(year): animals = [ "Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig" ] base_year = 2020 # Year of the Rat, a known reference index = (year - base_year) % 12 return animals[index] def calculate_zodiac(): try: birth_year = int(year_var.get()) if birth_year < 0: raise ValueError zodiac = chinese_zodiac(birth_year) result_label.config( text=f"Year {birth_year} is the Year of the {zodiac} 🐾" ) except ValueError: result_label.config( text="❌ Invalid input! Please enter a valid positive year." ) # Create main window win = tk.Tk() win.title("Chinese Zodiac Calculator") win.geometry("350x180") win.resizable(False, False) # Year input ttk.Label(win, text="Enter your birth year:", font=('Arial', 11)).grid(column=0, row=0, padx=10, pady=10, sticky='w') year_var = tk.StringVar() year_entry = ttk.Entry(win, textvariable=year_var, width=20) year_entry.grid(column=1, row=0, padx=10, pady=10) # Calculate button calculate_btn = ttk.Button(win, text="Calculate", command=calculate_zodiac) calculate_btn.grid(column=1, row=1, padx=10, pady=5, sticky='e') # Result display result_label = ttk.Label(win, text="", font=('Arial', 12), foreground="blue") result_label.grid(column=0, row=2, columnspan=2, padx=10, pady=15) win.mainloop()
-
Function:
chinese_zodiac(year)
This function determines the Chinese Zodiac animal based on a given year. It uses a list of animals and calculates the index using modulo operation:base_year = 2020
is used as the reference year for "Rat".index = (year - base_year) % 12
gives the corresponding animal.
-
Function:
calculate_zodiac()
This function reads the year entered by the user, validates it, and updates the result label with the corresponding zodiac sign:- Checks if the year is a valid positive number.
- If valid, calls
chinese_zodiac
and displays the result. - If invalid, shows an error message.
-
GUI Components (Tkinter)
Tkinter is used to create a simple and user-friendly interface:ttk.Label
– Displays instructions and results.ttk.Entry
– Text input for the birth year.ttk.Button
– Triggers the zodiac calculation.result_label
– Displays the output in blue font.
-
Main Window
The main window setup includes:win = tk.Tk()
– Initializes the main window.win.title()
– Sets the window title.win.geometry()
– Sets fixed window size (350x180).win.mainloop()
– Starts the GUI event loop.
Then I tried controlling my LED with a web interfacec andI generated the code with the help of AI.

This is the code that I uploaded on my board via a USB and it listens for commands from the computer via the serial connection. When it receives a signal (either '1' or '0'), it turns the LED on or off accordingly.
import serial from tkinter import * def led_on(): arduino_data.write(b'1') def led_off(): arduino_data.write(b'0') led_control_window = Tk() led_control_window.title('LED Control') btn_on = Button(led_control_window, text='Turn LED On', command=led_on) btn_on.pack(pady=10) btn_off = Button(led_control_window, text='Turn LED Off', command=led_off) btn_off.pack(pady=10) arduino_data = serial.Serial('COM13', 9600) led_control_window.mainloop()
This is the code in Python which runs on my computer and provides a user interface (GUI) using Tkinter. It allows you to press buttons to send commands to the Arduino, which then controls the LED.
import serial from tkinter import * from tkinter import font def led_on(): arduino_data.write(b'1') def led_off(): arduino_data.write(b'0') # Set up the Tkinter window led_control_window = Tk() led_control_window.title('LED Control') # Set background color to pink led_control_window.configure(bg='pink') # Use a different font for buttons and labels my_font = font.Font(family='Helvetica', size=14, weight='bold') # Create the "Turn LED On" button with a different style btn_on = Button(led_control_window, text='Turn LED On', command=led_on, font=my_font, bg='lightgreen', fg='black', padx=20, pady=10) btn_on.pack(pady=10) # Create the "Turn LED Off" button with a different style btn_off = Button(led_control_window, text='Turn LED Off', command=led_off, font=my_font, bg='lightcoral', fg='black', padx=20, pady=10) btn_off.pack(pady=10) # Initialize the serial connection to Arduino arduino_data = serial.Serial('COM13', 9600) # Run the Tkinter event loop led_control_window.mainloop()
Simple Explanation:
Libraries Used:
- serial: To communicate with the Arduino through the USB port.
- tkinter: To create the GUI (window, buttons).
- font: To customize the font style.
Functions:
- led_on(): Sends '1' to the Arduino to turn the LED on.
- led_off(): Sends '0' to the Arduino to turn the LED off.
Window Setup:
- A pink-colored window titled "LED Control" is created.
- Buttons are styled with custom fonts and colors.
Buttons:
- Turn LED On: Sends '1' to the Arduino when clicked.
- Turn LED Off: Sends '0' to the Arduino when clicked.
Serial Communication:
- Connects to the Arduino on COM13 with a baud rate of 9600.
- Make sure the Arduino code is ready to read '1' and '0' to control the LED.
Mainloop:
- Keeps the window open and interactive.
Final Project Development
This week, I focused on testing and ensuring that the components functioned correctly. I worked with a 4-channel relay module connected to a DHT sensor. The setup was programmed so that when the DHT sensor detected a temperature above 30°C, it would trigger the relay to turn on a fan. To simulate this condition, I used the warmth of my hands to raise the temperature near the sensor—and it worked perfectly!

I used the PCB that I made during the Electronics production week , a 4 channel relay, a 9V battery, a 5V dc fan and then some jumper wires.
Connecting the relay to the fan and the power supply and the PCB!

Connecting the dht to the already connected relay

The codes that were uploaded kept on giving issues, so I used a multimetre and BINGO- realized there were some short circuits in my board. So then I remade and remilled a generic board this time and when I tested it with it, it worked fine!! Whoo! That debugging and troubleshooting process was very tiresome. I even tried booting my Xiao several times and even changed my code a lot of times. However the problem lied with my board. So I made a generic board, milled and soldered it and then Woohoo! it worked.
This video showcases the successful test of my program in action. Initially, the fan remained off as the temperature was below 30°C. However, after applying heat to the DHT sensor using my hands—triggering heat transfer—the sensor detected a rise in temperature above 30°C. In response, it sent signals to the Xiao ESP32-C3, which then activated the relay, turning the fan on.
#include "DHT.h" // Pin definitions #define DHTPIN 2 // GPIO2 on XIAO ESP32-C3 #define DHTTYPE DHT22 // Use DHT11 if that's your sensor #define RELAY_PIN 3 // GPIO3 to control the relay #define TEMP_THRESHOLD 30.0 // Temperature threshold in °C DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(115200); dht.begin(); pinMode(RELAY_PIN, OUTPUT); digitalWrite(RELAY_PIN, LOW); // Ensure fan is off at start } void loop() { delay(2000); // DHT sensor requires at least 2 sec delay float temperature = dht.readTemperature(); // Check if reading failed if (isnan(temperature)) { Serial.println("Failed to read from DHT sensor!"); return; } Serial.print("Temperature: "); Serial.print(temperature); Serial.println(" °C"); if (temperature > TEMP_THRESHOLD) { digitalWrite(RELAY_PIN, HIGH); // Turn fan ON Serial.println("Fan ON"); } else { digitalWrite(RELAY_PIN, LOW); // Turn fan OFF Serial.println("Fan OFF"); } }
Files
You can access the files here
Generic Board's rml and kicads original file too