Site icon techtutorialsx

ESP32: Hello World

Introduction

The objective of this post is to explain how to write a simple “Hello World” program with the ESP32, using the Arduino core. This will be a very simple introduction, so this tutorial will just consist on printing the message to the serial port and read it on the Arduino IDE serial monitor.

If you prefer, you can check below the video version of this tutorial on my Youtube channel:

At the time of writing, I didn’t find a way to install the libraries for the Arduino IDE using the Boards manager, as we previously did for the ESP8266 (see the post here). Nevertheless, it’s probably a matter of time until it is supported.

For now, there is a very well explained tutorial on how to install the ESP32 Arduino support on Windows, on Espressif’s github page. Please check here for the mentioned tutorial. Also, note that there are other operating systems supported, as can be seen here.

Please note that in the previously mentioned tutorial, the directory where to clone the git repository may be different from yours. In my case, for example, the Arduino installation was in “C/Programs(x86)/Arduino”. Also, the hardware directory already existed, so only the “/espressif/esp32” folders were automatically created by Git.

Other important thing is that you may need to run both Git GUI and the get.exe file as administrator, in order for the correct folders to be created. In both cases, you just need to right click the executable file and select “Execute as administrator”. It should work fine.

The ESP32 Hello World code

The code for this tutorial is really simple, specially if you have previous experience with Arduino or the ESP8266.

So, in the Arduino setup function, we start by opening a serial connection, with a baud rate of 115200. To do so, we just call the begin method of the Serial object and pass as input the mentioned baud rate.

Next, on the loop function, we just call the println method, to print the “Hello World” message with a new line at the end. After that, we do a short delay of 2 seconds (2000 milliseconds), using the delay function.

void setup() {
   Serial.begin(115200);
}
 
void loop() {
   Serial.println("Hello World");
   delay(2000);
}

Running the code

Since we are still in the early stages of the ESP32 product life, most of the vendors still call the boards as “ESP32 development board” or something similar. In my case, I’m using one of those generic boards sold at eBay. So, I’ve selected the “ESP32 Dev Module” in the Arduino IDE, as can be seen in figure 1.

Figure 1 – ESP32 currently available boards for the Arduino IDE.

Nevertheless, the code compiles and uploads just fine. As can be seen in figure 2, we get the correct “Hello World” output at the serial console. Don’t forget to use the correct baud rate defined in the code, as highlighted in the figure.

Figure 2 – Output of the “Hello World” program.

Related content

Related posts

Exit mobile version