Embedded Programming¶
Group Assignment
- Demonstrate and compare the toolchains and development workflows for available embedded architectures
- Document your work to the group work page and reflect on your individual page what you learned
Individual Assignment
- Browse through the datasheet for your microcontroller
- Write a program for a microcontroller, and simulate its operation, to interact (with local input &/or output devices) and communicate (with remote wired or wireless connection)
Learning Outcomes
- Implement programming protocols
Have you answered these questions?
- Linked to the group assignment page
- Browsed and documented some information from your microcontroller’s datasheet
- Programmed your simulated board to interact and communicate
- Described the programming process(es) you used
- Included your source code
- Included ‘hero shot(s)’
Time Management¶
For our timetable, our local instructor advised us to implement the ideas and principles of Bhutan Baccalaureate by making a roadmap. A roadmap is an effective mechanism to plan out your goals and how you will be achieving them by firstly specifying your goal, then designing your action plan, and finally outlining your indicators of success which serves as a measure to indicate whether you have achieved your goal or not. You can get more details about it by exploring our school’s page by clicking this link.
This is what my timeable looks like now.
You can access my timetable here.
Group Assignment¶
You can access the link to our group assignment here
Reflection¶
For our group assignment, we had explored the microcontrollers Arduino UNO, ATTINY44, and ESP32. We tried to understand their specifications such as their number of pin configurations, programming processs and how each of this controllers are different, enabling us to know more about these boards. I learned a lot!
Individual Assignment¶
What is Embedded Programming?
Embedded programming languages are designed specifically for microcontroller-based applications and other devices that require low power and minimal memory usage .-deepseadev website
New Vocabularies
There are a ton of new words to learn this week which was hard for me to keep up with. Therefore, I made a very detailed page in my Vocabulary and Software section for this week, which lists all the necessary words needed. You can visit my link by clickling here.
Analog and Digital Signal
During our local session with Mrs. Tshering Wangzom and Rico, we learned about the difference about Anaglog and Digital Signal.
Analog signals are sent in a continuous waves which can vary in frequency and amplitude. Digital signals are signals represented in discrete values- 0 and 1.
Browsing through the datasheet¶
The microcontroller I plan on using for my final project is ESP32-WROOM-32 mainly because of its build-in Wi-Fi and multiple GPIOs for easy RFID integration.
ESP32-WROOM-32 pinout diagram
You can learn more about the different types of pins in this link.
Here is an image of the microcontroller ESP32 Functional Block Diagram found from the datasheet of ESP32 itself.
Important findings from the datasheet
ESP32-WROOM-32 (ESP-WROOM-32) is a powerful, generic Wi-Fi+BT+BLE MCU module that targets a wide variety of applications, ranging from low-power sensor networks to the most demanding tasks, such as voice encoding, music streaming and MP3 decoding. .*-ESP-32-WROOM-32 datasheet’
Chip: ESP32-D0WDQ6
Clock frequency: adjustable from 80 MHz to 240 MHz
Clock frequency refers to the speed of an MCU. Its clock frequency is considered pretty high for microcontrollers but low for the processors in computers.
Peripherals: capacitive touch sensors, Hall sensors, SD card interface, Ethernet, high-speed SPI, UART, I2S and I2C.
Peripheral are the build-in hardware features of a microcontroller.
Sleep current: less than 5 µA
Sleep current refers to the current consumption of the microcontroller in sleep mode, whereas the current consumption in standby mode(deep power saving mode) is called standby mode. A sleep current of less than 5 µA makes it favourable for battery powered and wearable electronics applications.
Data rate: up to 150 Mbps(Megabits per second)
This means that the maximum amount of data the ESP32 can send and receive is 150 Megabits per second.
Output power at the antenna: 20.5 dBm(decibels-milliwatts)
This deals with the strength of the Wi-Fi signal. ESP32 has a stable Wi-Fi connection even over long distances.
Operating System: freeRTOS
Power Supply: 3.3V
Programming Language: Arduino IDE, MicroPython, ESP-IDF, and PlatformIO can be used.
Pin Layout:
Programming a microcontroller¶
I am going to be using Arduino IDE, as recommended by Rico, throughout this week. You can learn how to download it here.
To get started, I went to File, Examples, Basics, and then Blink.
This will open a new window which looks like this.
The writings in grey are comments which explains the user about the code and who wrote it and all.
I copied the code(not the comments because it’s not necesarry) and opened tinkercad.
In your tinkercad dashboard, under Create, go to Circuits.
Select Arduino under the Starters dropdown menu, and select ‘Blink’.
Under the ‘Code’ dropdown menu, select ‘Text’. A confirmation tap will appear. Just press ‘continue’. Paste the code you copied earlier.
Replace LED_BUILTIN with the pin number where the positive terminal of your LED is connected. In my case, it is 13.
That’s the code for making one LED blink. Now, let’s make things a bit more complicated by adding a button to it. I generated the code using ChatGPT. Here is the prompt atfter attaching my intial code:
this is my initial code for making one LED blink with a delay of 1 second using Arduino UNO. edit this to make by adding a button which will be communicate with the LED. when i press the button, the LED should blink
This is the correct response code it generated me, after debugging it:
const int buttonPin = 7; // Button connected to pin 7
const int ledPin = 13; // LED connected to pin 13
int buttonState = 0;
void setup() {
// Initialize the button pin as input with internal pull-up resistor
pinMode(buttonPin, INPUT_PULLUP);
// Initialize the LED pin as output
pinMode(ledPin, OUTPUT);
}
void loop() {
// Read the button state
buttonState = digitalRead(buttonPin);
// If button is pressed (LOW state due to INPUT_PULLUP)
if (buttonState == LOW) {
digitalWrite(ledPin, HIGH); // Turn the LED ON
delay(1000); // Wait for 1 second
digitalWrite(ledPin, LOW); // Turn the LED OFF
delay(1000); // Wait for 1 second
}
// If the button is not pressed, the LED will be off
else {
digitalWrite(ledPin, LOW); // Ensure LED is OFF
}
}
Here is the result!!!
You can access the video of my simulation in this link.
Working with Wokwi¶
Since this is my first time getting started with Wowki, I wanted to learn how to create a simple LED simlution. For this I went through this tutorial that Rico sent us. You can also follow along here.
-
Click here to enter the Wowki workspace. Make sure to sign in.
-
Tap on your profile and go to ‘my projects’.
- Under ‘new project’ select ‘Arduino UNO’. You should enter a workspace that looks like so.
- Add an LED and a resistor. You can do so by clicking on the ‘+’ button on the top to create a new part.
The green button is to start the simulation, and the grey button is to zoom, grid, and more.
Connect the LED to GND and the anode of the LED to the resistor which will connect to digital pin 8.
- Declare your LED pin as an output in the setup function and inside the loop function, create an instruction to light the LED. This is what the finished code looks like.
void setup() {
// put your setup code here, to run once:
pinMode(8, OUTPUT); // Added missing semicolon
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(8, HIGH); // Added missing semicolon
}
- Run the simulation. The LED should be lighting up.
Important links and tutorials¶
- Arduino Workshop
- What is a microcontroller
- LEDs & Breadboards With Arduino in Tinkercad
- Getting started Wowki
- Link to the datasheet of ESP32
- Link to the datasheet of ES-32-WROOM_32
Reflection¶
For my individual assignment, I learned about embedded programming, focusing on the ESP32-WROOM-32 microcontroller, which I plan to use in my final project. I explored concepts such as analog and digital signals and how they differ, along with reviewing the microcontroller’s datasheet to understand its capabilities. I also practiced programming using the Arduino IDE, starting with a basic LED blink program and adding complexity by incorporating a button to control the LED. Overall, this week has been really fun!!
Thank you!
The template for this website was provided by Mr. Anith Ghalley and used with his permission