First ESP32 Project “A peek at how to make ESP32 microcontroller works”

Hi guys, back again with me in this dusty Medium. I would love to share something again with you, but don’t worry I won’t be talking about complicated trams and trains again. This time I will show you something “bright” and exciting!

too bright

First thing first, this is part of Embedded System course from my fourth semester majoring in Information System and Technology, and I believe this course is somehow related to Electrical Engineering (IT sector) idk why just assuming haha. What an exciting course telling us to do “hands-on” in our second week. Anyway this will be my first article and there will be series of articles every week so stay tune! This time I’ll write about my first hands-on experience with ESP32, a computer, specifically a microcontroller which I’ll be using in the next few weeks. Oh! you will be able to see how the microcontroller works at the end of this article too, so it would be really nice if you read through till the end! Without any further do, let’s get started!

This time I’m going to test my ESP32 to find out whether the microcontroller can be used. I’m using an example code from arduino IDE called the BLINK code. The purpose of this experiment is to test whether the ESP32 board can accept the code submitted by the programmer or not, and indirectly provide assurance whether the installation we are doing on the board and IDE is suitable. Sounds complicated, yes i know :( but this is actually very simple once you get used to it. [1]

Okay, before I start, I’ll tell you everything we need in this experiment. To run a command on the microcontroller, of course we will need a microcontroller :)) The hardware needed are :

  • ESP32
  • Breadboard (optional)
  • Micro USB cable (Type B)
  • PC
The ESP32 on Breadboard(left), Micro USB type-B cable(right)

Besides hardwares, we need a software that can help us deliver code from our personal computers to the microcontroller. Here we will use an IDE (Integrated development environment) from a microcontroller company, Arduino IDE. To do the next step, we must have the Arduino IDE on our PC. we can download it first at https://www.arduino.cc/en/software/ select the option according to the specifications of our PC, and the download will be done automatically. So EZ ain’t it [2]

Arduino IDE downloading options

as I said, we need an ESP32 and a micro USB cable. From here you can already guess what are we going to do? : D Yep that’s right, we will connect our PC with the ESP32 using a micro USB cable. Insert the microUSB to the ESP32, while the USB part is inserted into the PC, like this [3]

Connected ESP32
  • After the Arduino IDE is installed on our PC, there are several settings that must be modified friends, because we are not using Arduino but ESP32. First of all we have to go to Preferences -> Settings, then in the Additional board section add https://dl.espressif.com/dl/package_esp32_index.json;
Preferences(left), Additional Boards Manager URLs(right)
  • Another configuration that must be done is selecting a board. By default the Arduino IDE will be set to give commands to the Arduino Uno, all we have to do is change that with ESP32. Go to Tools-> Board-> Board Manager, then type “esp32” and install the board that appears.
Boards Manager(left), Finding esp32(right)
  • Adjust the Port by going to Tools -> Port, then select the usb serial or COM. after all the configuration is done, code execution can be started.
Picking the USB serial

(configuration is quoted from https://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-ide-windows-instructions/ )

Now we can start preparing the program that we will run on the ESP32 microcontroller, the blink program, this program is an example program found on the Arduino IDE. This blink program can be accessed via File -> Examples -> Basic -> Blink, there are several other examples that you can try too! Like fade so you could be faded like Alan Walker.

Selecting Blink program

Maybe you are wondering, how is the program able to make the lights blink? Okay don’t be panic, let’s see the default program first

Blink Program
  • the first procedure: void setup, the code in this procedure is used to select LED_BUILTIN or ESP32 built-in LED as output.
  • the second procedure (void loop) itself functions to adjust the LED blink specification, digitalWrite (LED_BUILTIN, HIGH) means to give high voltage to LED_BUILTIN so that the LED lights up and lasts for a delay time below it, while digitalWrite (LED_BUILTIN, LOW) means giving low voltage to LED_BUILTIN so the LED turns off and lasts for the below delay time. [4]

As can be seen above, by default the program will make the LED blink on and off for 1000ms or 1 second each. — — So here we are free as birds to change the ON / OFF delay time as we wish, it could be 500 ms or 100ms or something else, here I am using 500 and 100 so the difference would be somewhat significant to our eyes haha.

Configuration for 500ms(left) and 100ms(right)
  • When it’s ready, just compile it by pressing the checklist button above the editor, then press the right arrow button next to it to upload the code to the ESP32. If successful, the LED will blink
  • If there any failure such as Failed to connect: Time Out, don’t panic, guys, press and hold the “BOOT” button on the ESP32, then upload, when it’s connected, let go of the “BOOT” button, another error solution can be seen here https: //randomnerdtutorials.com/esp32-troubleshooting-guide/ [5]

Well we’re done yay. The microcontroller is ready to use as the ESP32 accepted the code ran by the programmer through Arduino IDE and all the configurations are suitable. As you guys can see written in the IDE, the smaller numbers written on delays, the faster the LED blinks because the delay time indicates how long the LED must be given high and low voltage, the longer the LED is given high voltage, it’ll cause the lights to light up longer, while the longer the LED is given a low voltage, it’ll cause the lights to go out longer. The combination of these two events will produce a slow blink, while the opposition will result in a fast blink[6]. I believe the error in this experiment is pretty low because this experiment is quite simple, but if you’re facing unexpected error, Google will offer you many solutions that you can try 😊, Good luck!

This is the introductory module to modules ahead, so stay tune and wish me luck! (I Wayan Ananta Suandira / 18219038)

--

--