ESP32: Hello World

The objective of this post is to explain how to do a simple “Hello World” program with the ESP32, using the Arduino IDE as development environment.


Introduction

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

If you prefer, you can check the video version of this tutorial in 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 code

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

So, in the 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.

ESP32 Selecting board on Arduino IDE.png

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.

ESP32 Hello World

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

 

Related content


Related posts

Advertisements
This entry was posted in ESP32 and tagged , , , , , . Bookmark the permalink.

11 Responses to ESP32: Hello World

  1. Pingback: ESP32: Connecting to a WiFi network | techtutorialsx

  2. GC says:

    Hi, may I know if you are using MacOS? I’m not able to connect to my ESP32 development board using MacOS, but is able to do it using Windows. Do you have any suggestion? Thanks.

    Liked by 1 person

    • antepher says:

      Hi! I’m also using Windows (version 8). Unfortunately I never tried it on Mac or Linux. But they have a different set of instructions on Mac:
      https://github.com/espressif/arduino-esp32#instructions-for-mac

      Have you tried them yet? If you already did, my recommendation is that you look in the issues on git for something similar to your problem and if you don’t find, open a new issue.

      If you can solve it please let us know, so others that find this post are able to solve it 🙂

      Best regards,
      Nuno Santos

      Like

      • GC says:

        Yes, I’ve followed the instructions to install.
        I do not seem to be able to detect the esp32 with the USB interface.
        Will update here if I find a solution.
        Thanks.

        Liked by 1 person

  3. Pingback: ESP32: FreeRTOS counting semaphores | techtutorialsx

  4. Pingback: ESP32: Dual core execution speedup | techtutorialsx

  5. Pingback: ESP32: DFRobot ESP-WROOM-32 Module | techtutorialsx

  6. Pingback: ESP-WROOM-32: Uploading a program with Arduino IDE | techtutorialsx

  7. Pingback: FireBeetle | techtutorialsx

  8. Pingback: FireBeetle ESP32: Blinking the on board LED | techtutorialsx

  9. Pingback: ESP32 Arduino: Getting started with WiFi | techtutorialsx

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s