How to upload the code to ESP32 CAM using Arduino or programmer

Learn how to upload the code or how to program ESP32 CAM board using Arduino UNO board, FTDI or USB to TTL converters.

In this quick tutorial, learn how to program or upload the code to ESP32CAM board through Arduino IDE with the help of Arduino UNO board, USB to TTL or FTDI converters.

Overview: What is ESP32CAM, how it works, What are its applications?

ESP32-CAM AI-Thinker is ESP32 based development board which is compact, small in size with integrated OV2640 camera. It also has few best features like GPIO pins to connect it with few modules, On board flashlight for camera picture quality and Micro SD card slot to read and save images and data.

The ESP32-CAM AI-Thinker board has integrated WiFi, Bluetooth and low-power BLE, with 2 high-performance 32-bit LX6 CPUs. It is designed in 7-stage pipeline architecture, with Hall sensor, temperature sensor and few other sensors on board. It’s main frequency setting ranges from 80MHz to 240MHz and computing power upto 600DIMPS(Dhrystone Million Instructions per Second). This board supports interfaces such as I2C/SPI/UART/PWM/ADC/DAC and camara units such as OV2640 and OV7670.

Fully compliant with WiFi 802.11b/g/n/e/i and Bluetooth 4.2 standards, it can be used as a master mode to build a standalone network controller or as a slave to other host MCUs to add network capabilities to existing devices.

It is suitable for smart home devices, industrial wireless control, wireless monitoring, QR codes identification, wireless positioning system signals, and other IoT applications. It is an ideal solution for prototype builds, and DIY projects.

ESP32-CAM pinout diagram:

Below is the image of ESP32-CAM AI-Thinker development board pinout

esp32 cam module pinout diagram

As you can see from the above image it has the support for 3.3v and 5Volts power supply input pins, Few GPIO pins, Tx and Rx pins, and few other pins.

Add external antenna to ESP32-CAM to increase the range(Optional)

It has an inbuilt antenna at the top as you can see from the above image, If the distance from the router to the board increases the signal strength decreases, as a solution to increase the range it has a support to add external antenna with IPEX connector. It is very easy just get an external antenna online or from store and plug it to the slot given on the ESP32-CAM board and realign the resistor beside it as shown in the below image.

how to attach external antenna to ESP32-CAM boardTo attach an external antenna first desolder the resister carefully as it is very small and resolder it in the opposite position as in the above image. If you feel soldering the resistor again is hard then just connect the points with solder without resistor. It works as long as the points are connected.

ESP32-CAM on board antenna works good with in 10-15 meters range and sometimes it may disconnect so get an external antenna for strong and stable connectivity and range.

Note: ESP32-CAM AI-Thinker board does not have a display, microphone, motion sensors, battery connector, built-in programmer, grove connectors, or function buttons, so you need to find solutions to these if you need them.

Related article: Interfacing OLED display with ESP32

How to Upload the code to ESP32-CAM using Arduino UNO

As we already learnt ESP32-CAM doesn’t have an inbuilt programmer to upload the code directly to it using Arduino IDE, so in this method we are using Arduino UNO board, which works as a programmer to upload the code to ESP32-CAM module instead of using converters such as FTDI programmer. Follow the below detailed steps to do so.

Components required:

  • ESP32CAM module
  • Arduino UNO
  • Few connecting wires.

Circuit Diagram to interface ESP32CAM with Arduino UNO

Connect the above required components according to the below circuit diagram.

Interfacing Esp32 CAM with arduino uno to upload the code

From the above schematic diagram you can see that there are two jumper cables connected one is for ESP32CAM connected between GND and IO0, and another is for Arduino UNO GND and RESET pins. ESP32CAM module is powered from the Arduino UNO 5v and GND pins connected to same on ESPCAM. The data transfer pins UOT and UOR from the ESP32CAM are connected to TX and RX pins of Arduino respectively.

Thats it for connections now you can connect the Arduino UNO board to PC and follow the below steps to upload the code.

Related post: Live stream with ESP32 camera module over internet with Face Recognition

Setting up Arduino IDE.

Download and install Arduino IDE on your PC, where Arduino UNO board is connected.

Now add ESP32 board manager by opening File -> Preferences and paste the below URL in the Additional boards manager URLs field.


Now open Tools -> Board:xxxxx -> ESP32 Arduino -> select : ESP32 Wrover module

Set the Tools menu settings as shown below

  • Board: “ESP32 Wrover Module” >
  • Upload Speed: “115200” >
  • Flash Frequency: “80MHz” >
  • Flash Mode: “Q10” >
  • Partition Scheme: “Huge APP (3MB No OTA/1 MB SPIFFS)” >
  • Core Debug Level: “None” >
  • Port: “COMx’ > According to your port connection

arduino ide tools settings for esp32cam module

Uploading the code: ESP32CAM webserver

As an example lets use the code from the ESP32 Examples library by opening File -> Examples -> ESP32 -> Camera -> CameraWebServer. An example ready made code will be loaded, you just need to change the WiFi credentials in the code and click on Upload button.

esp32 code uploading dots

After clicking on upload icon you can see the connecting dots as the above image, when you see them press the RST(Reset button) on the board which leads to code upload, with in few seconds you will see the message “Done uploading” on status bar of Arduino IDE means code uploaded successfully.

Now remove the jumper connection between GPIO1(IO0) and GND on ESP32 CAM module. Open serial monitor and set the baud rate to the value which we mentioned in the code i.e., 115200 and press RST button on the ESP cam board.

Now you can see the IP address of the webserver from where we can access the ESP32 CAM features, camera etc. as shown in the serial monitor image below.

esp32 cam webserver ip address Now Open the address in a web browser to access the ESP32CAM dashboard.

esp32-acam local server stream

How to Upload the code to ESP32-CAM using USB to TTL/FTDI programmer

In this method a special board is used to upload the code to ESP32 CAM named USB to TTL or FTDI converter. This boards will provide the connectivity between USB and UART interfaces. There are wide varieties of FTDI programmers are available with different output voltages like 3V, 5V.

In this method we are using FT232RL USB TO TTL Converter.

FTDI PROGRAMMER pinout diagram

Features and Specifications of FT232RL USB TO TTL Converter

This section mentions some of the features and specifications of the FT232RL USB to TTL Converter:

  1. Operating Voltage: 5V/3.3V DC
  2. Connector: Mini USB
  3. Max Current Draw: 5V – 500mA; 3.3V – 50mA
  4. Data transfer rates from 300 baud to 3 Mbaud (RS422, RS485, RS232) at TTL levels
  5. Fully integrated 1024 bit EEPROM storing device descriptors and CBUS I/O configuration
  6. 128 byte receive buffer and 256 bytes transmit buffer

Components required:

  • ESP32CAM module
  • FTDI Programmer/USB to TTL programmer
  • Few connecting wires.

Circuit Diagram to interface ESP32CAM with USB to TTL programmer

Connect the above required components according to the below circuit diagram.

inTERFACING esp32 cam WITH usb TO ttl fTDI CONVERTERAs you can see from the above schematic diagram GND and GPIO0 pins are connected with a jumper on ESPCAM board. ESPCAM board is powered from the VCC and GND from FTDI to 5V and GND respectively, The transfer and receive pins TX and RX pins from FTDI are connected to TX and RX pins of ESPCAM respectively.

Setting up Arduino IDE

This is same as the Above Arduino UNO method, Please refer the above method to setup Arduino IDE.

Upload and execute the Code:

This is same as the Above Arduino UNO method, Please refer the above method to setup Arduino IDE.

After uploading the code remove the jumper between GPIO0 and GND pins on ESPCAM.

Errors while uploading:

Failed to connect to ESP32: Timed out waiting for packet header

Solution: Check the wiring connections between the Arduino/FTDI programmer and ESP32CAM board, if everything is ok Press the RST button when dots are processing after clicking on upload icon.

Brownout detector was triggered

This error occurs for the following reasons: when the quality of the USB cable is poor, cable is very long for the data to reach, Voltage is not sufficient to ESP32 CAM board.

Solution: If there is voltage problem use external 5v power supply to power the ESP board as Arduino UNO sometimes cannot provide 5v , use short USB cable for data transfer.

CircuitSchools Staff

We at CircuitSchools publish on basics of electronics and electric components and everything related to evolution of electrical technology with complete analysis of development boards and modules along with latest projects with innovative ideas.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button