ESP32 Getting Started with Arduino Development (2)--Hello world

Note: If you are interested in ESP8266 and ESP32 open source technology, you can join the group, let’s explore and exchange learning together, group number: 551636355. Group name: ESP32 open source technology exchange group.

The purpose of this article is to explain how to use the Arduino IDE as a development environment to make a simple "Hello World" program with the ESP32 .

 

introduce

The purpose of this article is to explain how to make a simple "Hello World" program with the ESP32 . This will be a very simple introduction, so this tutorial will cover printing messages to the Arduino IDE Serial Assistant.

Now, on Espressif 's github page , there is a very good tutorial on how to install Arduino-ESP32 on Windows . Check out the tutorial mentioned here . Also, please note that there are other OS support, which can be seen here .

Note that in the tutorial mentioned earlier, the directory where you cloned the git repository might be different from yours. In my case, for example, Arduino was installed in C:\Programs ( x86 ) \Arduino . Also, the hardware directory already exists, so only the \espressif\esp32 folder is automatically created by Git .

Other important things are that you may need to run the Git GUI and the get.exe file as administrator in order to create the correct folders. In both cases, just right-click the executable and select Execute as administrator  " . It should work fine.

 

code

The code for this tutorial is pretty straightforward, especially if you have previous experience with Arduino or ESP8266 .

So, in the Setup function, we first open a serial connection with a baud rate of 115200 , for this, we just call the begin method of the Serial object with the mentioned baud rate as input. Next, in the loop function, we simply call the println method to print the "Hello World" message on a new line at the end. After that, we use the delay function to do a short delay of 2 seconds ( 2000ms ).

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

run the code

Since we're still in the early stages of the ESP32 product life cycle, most vendors still refer to these boards as "ESP32 development boards " or something similar. In my case, I used one of the generic boards sold on Taobao. So I chose "ESP32 Dev Module" in the Arduino IDE as shown in Figure 1 .


Figure 1  - The ESP32 board for the currently available Arduino IDE .

Still, the code compiles and uploads just fine. As you can see from Figure 2 , we get the correct "Hello World" output on the serial console. Don't forget to use the correct baud rate defined in the code as shown in the picture.


Figure 2  - Output of the "Hello World" program

related information

§  Espressif Arduino ESP32 Core Github page

§   Windows Installation Tutorial

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324784716&siteId=291194637