The objective of this post is to explain how to upload an Arduino program to the ESP-WROOM-32 module.
Introduction
The objective of this post is to explain how to upload an Arduino program to the ESP-WROOM-32 module, from DFRobot.
We will cover in more detail the hardware configuration needed to upload a program to the module. You can check in more detail how to enable the support for the ESP32 in the Arduino IDE on this previous post.
Please note that this is a ESP32 module suitable for integration in electronic designs and not a development board for testing/development. Thus, the pin spacing is very small and it requires some special manual soldering skills to be able to use it. Naturally, these kind of spacing is adequate for non-manual soldering procedures.
The hardware
In order to be able to upload programs to this module, we need a Serial-USB converter, so we can communicate with it. I’ve used the one shown here, which allows us to change between 3.3V and 5V operating voltage.
Important: The ESP32 is a 3.3V device and the WROOM module doesn’t do any voltage level conversion. So, the Serial-USB converter to be used must operate at 3.3V. Otherwise, the ESP32 may get damaged.
One thing that we need to take in consideration is that in order to be able to program the ESP32, the GPIO0 must be kept low [1]. Also, for the device to work, the EN pin (chip enable pin) must be connected to VCC, since it operates in an active-high configuration [2].
So, taking the previous points in consideration, figure 1 shows the minimal configuration needed to be able to program the ESP-WROOM-32 module. The other pins of the devices are not shown for simplicity. Also note that I’m assuming that the Serial-USB converter power is being supplied by the USB connection, which is the typical use case.
Figure 1 – Minimum hardware configuration needed to program the ESP-WROOM-32.
Please take in consideration that for the sake of simplicity I’m not following the best practices here, such as including power supply bypass capacitors and other important aspects needed to keep the device working with the best reliability. So please don’t use this hardware configuration in a final design, since it is only suitable for a quick interaction with the module.
Although in the figure we have the IO0 connected to GND, this configuration is only adequate for uploading the program. After that, you need to disconnect it from GND, so the program uploaded runs.
The code
The code for this tutorial will be very simple and consists in a simple “Hello World” message being printed periodically to the serial port. So, we start by opening a serial connection in the setup function, with a baud rate of 115200. You can check more on initiating a serial connection here.
Next, on the main loop function, we will print a simple “Hello World” message. To do so 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 as input the number of milliseconds to wait.
Check bellow the full source code for this simple program.
void setup() { Serial.begin(115200); } void loop() { Serial.println("Hello from DFRobot ESP-WROOM-32"); delay(1000); }
The Arduino IDE configuration
In order to be able to upload the code to the Arduino we need to select a suitable uploading configuration in the Tools menu. We can use the same configurations of the FireBeetle-ESP32 board, as shown in figure 2.
Figure 2 – ESP32 FireBeetle board selection in Arduino IDE.
After selecting this board and selecting the correct COM port assigned to the Serial-USB converter, just hit the upload button. The code should now be compiled and uploaded. After a correct upload, you should get an output similar to figure 3 on the IDE console.
Figure 3 – Message after successful upload.
After this, power off the module, disconnect the IO0 pin from GND and power the device on again. Then, open the serial monitor of the Arduino IDE. You should get an output similar to figure 4, where our defined “Hello World” message is being printed each second.
Figure 4 – Output of the “Hello World” program.
Additional notes
You can confirm if your soldering was correctly done before trying to upload your program. If you power on the module, connected to the Serial-USB converter and with IO0 disconnected from GND, a pre-loaded program should be running and printing the detected WiFi networks to the serial console, as shown in figure 5.
Figure 5 – Output of the pre-loaded program.
Also, if you power on the module with the IO0 connected to GND and the Arduino IDE serial monitor previously open, you should get an output similar to figure 6, which indicates that the ESP32 is ready for getting a new program.
Figure 6 – Output of the module when in programming mode.
Special thanks
I would like to leave a special thank you note to my friend Pedro Marques, who helped me soldering this module, since my skills aren’t the best for this kind of pin spacing.
References
[1] https://github.com/espressif/arduino-esp32
[2] https://www.espressif.com/sites/default/files/documentation/esp_wroom_32_datasheet_en.pdf
Pingback: DFRobot’s FireBeetle ESP32 board | techtutorialsx
Pingback: DFRobot’s FireBeetle ESP32 board | techtutorialsx
Pingback: ESP32 Arduino: Getting started with WiFi | techtutorialsx
Pingback: ESP32 Arduino: Getting started with WiFi | techtutorialsx
Pingback: ESP-WROOM-32 Tutorial: Uploading a program with Arduino IDE – EverythingESP
Pingback: ESP-WROOM-32 Tutorial: Uploading a program with Arduino IDE – EverythingESP
Hey, I need some kind of help…
I have a custom design with ESP32. My GPIO0 is held LOW, my EN pin is connected to 3.3v. When I boot, I get the “waiting for download” prompt. However, I always get the famous “Timed out waiting for packet header” error.
Any help is appreciated 🙂
Hi!
Unfortunately I haven’t worked much more with ESP-WROOM-32 modules directly or custom designs, and I’ve mostly been using ESP32 boards from vendors.
So I never faced that issue and I’m really not sure how to solve it.
My suggestion is to ask around the ESP32 forum, since others probably have already faced the same problem and can help:
https://esp32.com/
Hope this helps you finding some answers 🙂
Best regards,
Nuno Santos
I realise that you may be thinking of the installation module, but I have been getting a similar problem with the development kits. Only some of the development modules have given me this fault and it is “cured” by connecting a 0.01uF polyester capacitor from the EN pin to ground. Larger capacitors have had the same effect, even electrolytics up to 10uF.
I don’t know why, I just know I read it on a Github post and it worked.
Hey, I need some kind of help…
I have a custom design with ESP32. My GPIO0 is held LOW, my EN pin is connected to 3.3v. When I boot, I get the “waiting for download” prompt. However, I always get the famous “Timed out waiting for packet header” error.
Any help is appreciated 🙂
Hi!
Unfortunately I haven’t worked much more with ESP-WROOM-32 modules directly or custom designs, and I’ve mostly been using ESP32 boards from vendors.
So I never faced that issue and I’m really not sure how to solve it.
My suggestion is to ask around the ESP32 forum, since others probably have already faced the same problem and can help:
https://esp32.com/
Hope this helps you finding some answers 🙂
Best regards,
Nuno Santos
Hi thanks for this amazing tutorial tomorrow i am going to use esp32 smd for the first time and over the whole internet i just got this tutorial easy and very much useful. Thank you so much. God bless you
thank you so much