Let’s install the ESP32 in Arduino IDE!
Espressif’s ESP32 microcontrollers are perfect for various projects, from IoT applications to home automation. In this guide, I will show you how to set up your ESP32 microcontroller board in the Arduino IDE.
Keep reading!
#1 Prerequisites: Install the Arduino IDE
The first step is to download the Arduino IDE. In this guide, we will use the new Arduino IDE version 2. However, the same steps apply to the original version as well. Also, if you’ve already installed the Arduino IDE, you can skip to the next step.
Follow this (Arduino.cc/en/software) link to navigate to Arduino’s official download page and select a download option. For Windows users, select the Windows installer where it says “Win 10 and newer.” On Linux, download the Zip file. If you are on a Mac, choose whether your system is based on an Intel or Apple processor.
The next steps depend on the operating system you are using.
Arduino IDE on Windows
On Windows, open the .exe file you downloaded to run the installer. Then, follow the steps in the installer. They should be pretty self-explanatory.
If you start the Arduino IDE for the first time, you will be asked to install multiple drivers. Allow it to install them. Otherwise, the communication with your boards might not work properly.
Arduino IDE on Linux
If you are on a Linux system, extract the ZIP file you downloaded and place it in the location where you want the Arduino IDE to be installed.
In the extracted folder, which is called something like “arduino-ide_x.x.x_Linux_64bit“, there should now be a file called arduino-ide. Open that file to start the Arduino IDE.
Arduino IDE on MacOS
For MAC users, just copy the downloaded file into your application folder.
#2 Add the ESP32 Boards Manager URL
In the Arduino IDE, we need to add a boards manager index that contains all the ESP32 boards. To do so, paste the following Boards Manager URL under File > Preferences > Settings > Additional boards manager URLs.
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
#3 Install ESP32 Boards
After adding the boards manager index URL, we need to install the actual boards manager in the corresponding menu in the Arduino IDE. If you use version 2 of the Arduino IDE, click on the board icon on the left and search for esp32. Then, install the “esp32 by Espressif Systems” boards manager.
On the older version of the Arduino IDE, select Tools > Board > Boads Manager and search for esp32.
Now just wait until the installation is complete. Don’t worry if the process takes a little moment.
#4 Upload The First Sketch
We now have successfully installed ESP32 in Arduino IDE! Let’s upload the first sketch to the ESP32 board.
Select board type and COM port
To do so, we need to select the correct ESP32 board type and the COM (“USB”) port, it is connected to. Therefore, click Select Board and enter ESP32 along with other identifiers of your board. In my case, I search for “ESP32 Dev Module” and choose the port COM4.
When you are unsure which port is the right one, try unplugging your board and checking which COM port disappears.
Alternatively, if you are using the older Arduino IDE, you can select the board type under Tools > Board > esp32 > …
And select the COM port under Tools > Port > …
ESP32 in Arduino IDE Blink Sketch
Last but not least, we need to upload a test sketch to the ESP32. Feel free to copy the following sketch that blinks the internal LED of the ESP32 board and outputs a little text to the serial monitor.
The built-in LED pin for most ESP32 boards is pin number 2.
Hit the upload button to upload the sketch to your board.
// Define buit-in LED pin
#define LED 2
void setup() {
// Initialize Serial Output
Serial.begin(115200);
// Initialize LED pin
pinMode(LED, OUTPUT);
}
void loop() {
Serial.println("Switching LED On . . .");
digitalWrite(LED, HIGH); // LED on
delay(1000);
Serial.println("Switching LED Off . . .");
digitalWrite(LED, LOW); // LED off
delay(1000);
}
Troubleshooting Tips and Common Errors
A fatal error occurred: Could not open COMX, the port doesn’t exist
If you get this message when trying to upload a sketch to your ESP32 board, it means that there is nothing connected to the specified COM port. Try reconnecting your ESP and making sure, you selected the right COM port.
I can’t find the COM port of my ESP32 board
When the COM port does not appear after plugging in your board, check whether the USB cable you use supports data transfer. If it doesn’t, use a different cable. Additionally, try using a different USB port on your computer. In case the COM port still does not appear, your board might be broken.
A fatal error occurred: Failed to connect to ESP32: Wrong boot mode detected (0x13)! The chip needs to be in download mode.
If this error appears, your board doesn’t automatically switch to download mode. To fix this issue, press the BOOT button on your ESP32 board, while the console says Connecting . . . .
COM Port not found/not available
You probably need to install additional drivers. Check out this guide on how to install the ESP32 drivers.
ESP32 in Arduino IDE: Conclusion
Setting up ESP32 in Arduino is straightforward when you follow these simple steps. I hope I was able to help you out, installing the ESP32 in the Arduino IDE and getting started with your projects!
Please share your thoughts and experiences in the comments!
Also, check out this post if you want to learn about wireless communication using ESP-NOW!
Thanks for reading, happy coding!