Embedded System Journey #1: LED Blink with ESP32 on Arduino IDE
Hello, Vincent here. It’s not actually my first experience with Arduino. I took the Introduction to Engineering and Design in my first year program. This semester, I am taking II2260 Embedded System. We are diving deeper into the Arduino world deeper in this series. Although this is our project to post weekly progress, I guess it won’t be any harm to learn more about this stuff xixi. Please stay tune with me for the rest of the semester and I will be sharing what I will be learning in this course.
— Components
We are supposed to buy the components ourselves. I guess it’s gonna cost a lot though. Please spare me some pocket money 😔. The tools required are:
1. ESP 32 DOIT DEVKIT V1
2. USB-A to micro-USB Cable
3. Laptop / Computer with Arduino IDE
Luckily, a friend of mine offers to help me buy the components since he is gonna get some himself. I purchased the essential components (in my case, it’s only ESP32) for like IDR 70k. I recalled that I had USB-A to micro-USB cable and my friend offered me her breadboard since she won’t be using it anymore.
— Software Installation and Set Up
We are required to use Arduino IDE or other text editors. Thus I used Arduino IDE since it is primarily built for the Arduino. You can download the Arduino IDE from the link provided below. Get the one that match your Operating System and computer specifications. Arduino IDE is available for Windows, Linux, and even MacOS.
Download here.
If you are having trouble installing the software after downloading the IDE, you can always refer to the documentation given by the Arduino IDE itself.
After having Arduino IDE installed to your computer, we should make some configuration to the app itself. Arduino IDE is actually made for Arduino, not for ESP32. We should set the Arduino IDE up for our usage.
Let’s jump right to the configurations!
Hover the cursor towards Preferences and click it.
Get the Addition Boards Managers URLs made for ESP32
Insert https://dl.espressif.com/dl/package_esp32_index.json in the Addition Boards Manager URLs placeholder and click OK.
Set the board up in Arduino IDE
Go to the Boards Manager settings. You can do it by going to Tools > Board > Boards Manager or just press Ctrl + Shift + B
Install ESP32
Boards Manager panel will open up at the right side of the application screen. Insert “esp32” to the search placeholder and install the “esp32 by Espressif Systems”. Mine has been installed else it will show the button “install” instead of “installed”. The installation is gonna take a while. So just wait for it.
Get the board according to the one you have (In my case, it’s DOIT ESP32 DEVKIT V1)
If the installation is done, you can change your board into the corresponding boards that you have. You can change it by clicking Tools > Board > esp32 > <the board you have>. Mine is DOIT ESP32 DEVKIT V1.
There is an easier way to do this. You can just choose the board from the board selection as shown below. Insert “DOIT ESP32 DEVKIT V1” and it will show it on the search result. Select it and click OK.
Port Configurations
If you see on the App Status bar below, you will see that your ESP32 is still not connected.
It happens because we haven’t connected the ESP32 to our computer or haven’t chosen the port which our ESP32 has connected to. Let’s connect the ESP32 to the computer with the USB-A to micro-USB Cable we have. The cable have to be able to transfer data. Some cable are only compatible with charging only. Those cable can’t be used in this project since the ESP32 won’t be detected. Here’s my short experience.
I tried to connect the cable I used for charging water pump for this project. However, little did I know that the cable I had doesn’t support any data transfer. It only supports charging. I panicked a little and look for the solutions all over the internet, but still can’t find the solution. My friend told me that it might be the cable that is faulty. I recalled that I should have another cable used in my drawing pad. Luckily, I still have it and the cable is still intact. I tried to connect the ESP32 to my computer and IT WORKED ! I’m so happy :D OK BACK TO THE TOPIC.
After connecting ESP32 to your computer, you can choose the port connecting the ESP32 to your computer. In my case, it’s COM11. It may vary from one another. You can choose the port from Tools > port > COM
If you haven’t had the Port options available in Tools Toolbar, it is likely that you didn’t have any of the driver required for the connection. You can download the driver here. You can try to download the Universal Windows Driver and install it. To install the driver, you have to extract the driver, right-clicked the silabser.inf file, and install it. If it didn’t result in any good, you can try to download the CP210x Windows Driver (the non-universal version). Extract the file and install the .exe file according to your processor type (x64 for 64-bit processor and x86 for 32-bit processor).
You may now see that the port option is available in the Tools section. Choose the port corresponding to your board (in my case COM11).
If you have chosen the port, you will see at the status bar that the ESP32 has been connected. You will now be able to code for your ESP32.
— ESP32 Experiment: LED Blink
In this experiment, we will try to make the LED Blink This project’s purpose is to confirm that the ESP32 is ready to use. The LED Blink sketch has already been provided in the Arduino IDE. You can just hover to File section in the toolbar, choose Examples > Basics > Blink. We will use the provided code in this . (Although I copied the code online since I didn’t know Blink Code is provided in the IDE. Well, thank God it worked).
Let’s analyze the code here. We have the void setup() and void loop() function. Void setup() will only be ran once in the beginning, while void loop() function will be ran non-stop. In the void setup() function, we have pinMode (LED_BUILTIN, OUTPUT). This is used to initialize the digital pin LED_BUILTIN as the output.
In the void loop() function, we have a function to turn the LED on and off repeatedly. the LED will be seen as blinking. The delay is set to be 1000 ms so that it will be blinking every 1 second.
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
In order to make the LED Blink, we have to compile and upload the code to the board
— 1000ms
As shown, the LED turn on and off every 1 second.
— 2000ms
Curious, I changed it into 2000ms and as expected, the LED blinks slower than the first experiment.
— 500ms
I changed the delay to 500ms. We can see that the LED blinks faster. It’s actually twice as fast. I double checked it with the amount of blink in certain duration. Just try it by yourself to clarify it hehe :D.
— Resources
- https://randomnerdtutorials.com/getting-started-with-esp32/
- https://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-ide-windows-instructions/
- https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers
- and many more troubleshooting website that I don’t really think you need it :v