In this blog I will show you how to program a ESP32S and a ESP32 + CAM as I use these the most. It fairly the same as the ESP8266. There’s an add-on for the Arduino IDE that allows you to program the ESP32 using the Arduino IDE and its programming language. In this tutorial we’ll show you how to install the ESP32 board in the Arduino IDE on MacOS or Linux.
Installing and Configuring
To get yourself a working environment go over these steps:
- Download the Arduino IDE.
- Go to File –> Preferences and add the link https://dl.espressif.com/dl/package_esp32_index.json to the Additional Boards Manager URLS.
Go to Tools –> Board –> Boards manager
You should now have the esp32 as an option there since you’ve added it to the Additional Boards. Select it and press Install.
Now, You have the ESP32 boards configure. Choose the board you have, in my case “AI Thinker ESP32-CAM“.
Choose the ESP32 USB port when you connect your ESP module and you’re done!
And that’s it, you are ready. From what I understood by digging through the files, the new code interpreting the common Arduino functions into a clear c++ code, then using the esptool to create a new firmware and flash it on the ESP32.
Writing a program to the ESP32
Flashing a program to the ESP32 is a bit more annoying than flashing an Arduino. When flashing the arduino, all you have to do is press the reset button and release while you upload a program (or even not doing anything if you have FTDI such as in arduino UNO,NANO, MICRO, etc.) and the arduino will start uploading. With the ESP32 you have to reset the micro-controller and start it in flashing mode using the GPIO0-to-Ground.
The sketch shows the ESP32 connected to FTDI Programmer with common GND.
NOTE: Be Sure that you hold the program button when you power on the CAM module, so it starts in Program mode!
As you can see two buttons have been added. The Left button, when pressed, connects the RESET pin to the ground and when it is released, connects the RESET pin to the VCC through a pull-up resistor.
The Right button, when pressed, connects the PROGRAM pin to the ground and when it is released, connects the PROGRAM pin to the VCC through a pull-up resistor.
I also added A LED when the ESP is in PROGRAMMING STATE state the LED is ON. When The ESP is in “NORMAL” state the LED is OFF. Using this two buttons you can do all the tasks you need with the ESP32:
- Working on NORMAL mode – Both buttons are released.
- RESETTING the ESP32 – Press the RESET button and release.
- Start in FLASH MODE – Press both buttons, release the RESET button and then release the PROGRAM button.
Programming your ESP module
Now your ready to program your ESP module. You can connect the USB cable from the FTDI programmer to your computer and open Arduino IDE. Happy programming.
Because I always use the Fritzing app to illustrate the hardware setup of a new project, I need a new fritzing part for future setup’s. So after some designing in illustrator this is the end result.