ESP32 Getting Started with Arduino Development (3) --Uploading a program

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 upload an Arduino program to the ESP-WROOM-32 module.

 

introduce

The purpose of this article is to explain how to upload an Arduino program to the ESP-WROOM-32 module.

I'll go into more detail about the hardware configuration required to upload the program to the module. You can check in more detail from previous posts for Arduino IDE support for ESP32 .

Note that this is an ESP32 module suitable for integration in an electronic design, not a development board for test / development. Therefore, the pin spacing is very small and some special hand soldering skills are required to use it. Of course, this spacing is suitable for non-hand soldering procedures.

hardware

To be able to upload programs to this module, we need a USB to serial converter so we can communicate with it. The core board I use has a CP2102 chip for serial download, which allows us to switch between 3.3V and 5V operating voltage.

Important:  ESP32 is a 3.3V device, the WROOM module does not do any level shifting. Therefore, the USB serial converter to be used must work at 3.3V . Otherwise, the ESP32 may be damaged.

One thing we need to consider is that in order to be able to program the ESP32 , GPIO0 must be held low. Also, in order for the device to work, the EN pin (chip enable pin) must be connected to VCC as it is configured to operate active high.

Therefore, with the above points in mind, Figure 1 shows the minimum configuration required to be able to program the ESP-WROOM-32 module. For simplicity, other pins of the device are not shown. Also note that I'm assuming that the serial -to- USB converter power is provided by the USB connection, which is a typical use case.


Figure 1  - Minimum hardware configuration required to program the ESP-WROOM-32 .

Note that for simplicity, I have not followed the best practices here, such as including power supply bypass capacitors and other important aspects needed to make the device work with optimum reliability. So please do not use this hardware configuration in the final design as it is only suitable for quick interaction with modules.

Although in the diagram we connect IO0 to GND , this configuration is only for uploader. After that you need to disconnect it from GND in order to upload the program.

code

The code for this tutorial will be very simple and consist of a simple "Hello World" message that is periodically printed to the serial port. So, we first open a serial connection in the setup function with a baud rate of 115200 . You can find more information on starting a serial connection here .

Next, in the main loop function, we will print a simple "Hello World" message. To do this, we can call the println method on the Serial object . After that, we do a short delay by calling the Arduino delay function, which receives input to  wait for the number of milliseconds. 

Full source code for this simple program.

void setup()
{
  Serial.begin(115200);
}
void loop()
{
  Serial.println("Hellofrom DFRobot ESP-WROOM-32");
  delay(1000);
}

Arduino IDE deployment

To be able to upload the code to the Arduino , we need to select the appropriate upload configuration in the Tools menu. We can use the same configuration as the FireBeetle-ESP32 board as shown in Figure 2 .


Figure 2 - ESP32 FireBeetle board selection in the  Arduino IDE .

Once the board is selected and the correct COM port assigned to the USB serial port is selected, hit the upload button. Now code and upload the code. After uploading correctly, you should get output similar to Figure 3 on the IDE console.


Figure 3  - Message after successful upload

After that, power off the module, disconnect the IO0 pin from GND and power on the device again. Then, open the serial monitor of the Arduino IDE . You should get output similar to Figure 4 , where our defined "Hello World" message is printed every second.


Figure 4  - Output of the "Hello World" program

 

Supplementary Notes

You can confirm that the soldering is done correctly before trying to upload the program. If you power on the module, connect to a USB serial converter, and IO0 is disconnected from GND , a preloaded program should run and print the detected WiFi network to the serial console, as shown in Figure 5 .


Figure 5  - The output of the preloader.

Also, if you turn on the module with IO0 connected to GND and the Arduino IDE serial monitor previously turned on, you should get an output similar to Figure 6 , which means the ESP32 is ready for a new program.


Figure 6  - Output of the module when in programming mode.

 

refer to

[1]  https://github.com/espressif/arduino-esp32

[2]  https://www.espressif.com/sites/default/files/documentation/esp_wroom_32_datasheet_en.pdf


Guess you like

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