ESP32 CAM Board – How to begin and blink a LED

In this tutorial I am going to show you how to blink a LED using ESP32-CAM development board. With this module you can develop WiFi/bluetooth projects, that are capable of remote access to images. The ESP32-CAM is a development board with an ESP32-S chip, an OV2640 camera, several GPIOs to connect peripherals and microSD card slot to save images while cummunication is not available.
For now, let’s start by knowing the basics.

Parts Required

The ESP32-CAM Board

Figure 1

ESP32-CAM module is starting to be widely used in applications that need image brodcasting, facial recognition, image procecing and most important, with built-in Wifi and bluetooth. The ESP32 chip is so powerfull that it can even process images. It also include I2C, SPI, UART communications as well as PWM and DAC outputs.

Now lets talk about the general pinout of the board. You can follow the figure 2 as we progress.

Figure 2

GPIO 1 (TX) and GPIO 3 (RX) are the serial pins. Because the board does not have a built-in programmer, you need to use these pins to communicate with a FTDI programmer and upload the code. You can use GPIO 1 and GPIO 3 to connect other peripherals. But remember, if you occupy them, you woould not be able to open the Serial Monitor.

GPIO 0 determines whether the ESP32 is in flashing mode or not. When GPIO 0 is connected to GND, the ESP32 is in flashing mode.

GPIO 16 is by default a UART pin. However, you can use it as an input. It is internally connected to a 10k Ohm pull-up resistor.

There are three GND pins (black color) and two power pins (red color): 3.3V and 5V. The board can be powered through the 3.3V or  5V pins. However, a lot of people recomend to power the board through the 5V pin. So, we will respect that.

Atention:
There is also the pin VCC (yellow color). You should not use that pin to power the board. That is an output power pin. It can either output 5V or 3.3V, whether it is powered with 5V or 3.3V.

These pins are internally connected to the microSD card reader:

  • GPIO 14: CLK
  • GPIO 15: CMD
  • GPIO 2: Data 0
  • GPIO 4: Data 1 (also connected to the on-board LED)
  • GPIO 12: Data 2
  • GPIO 13: Data 3

If the pins are not being used for microSD card, you can use these pins as regular inputs/outputs. All these GPIOs are RTC and support ADC: GPIOs 2, 4, 12, 13, 14, and 15.

GPIO 33 is an on-board LED, that is next to the RST button. That on-board LED works with inverted logic, so you send a LOW signal to turn it on and a HIGH signal to turn it off.

The camera connections between the camera and the ESP32-CAM AI-Thinker are shown in the image below.

Figure 3

Circuit

Figure 4

The board can be powered by any power supply available, like batery or USB port on your computer. In this setup, it will be powered through USB port via the FTDI power pins, like in figure 4. So start by connecting the FTDI GND to the Board GND and do the same with VCC. Connect the (Orange wire) FTDI TX to the Board RX and FTDI RX to the Board TX (White wire).

Note: the FTDI pins on the diagram may not match your FTDI. Make sure you check the silkscreen label.

Since, GPIO 0, determines whether the ESP32 is in flashing mode or not, we need to cennect GPIO 0 to GND to turn the ESP32 is in flashing mode. After uploading the code, the GPIO 0 must be desconected from GND pin.

Programing Using FTDI

Our development board can be programmed using Arduino IDE, but for that we need to use a FTDI. After completing the schematic above, we can connect the FTDI to the computer.

To upload code to the board, follow the next steps:

1 – Go to Tools Board and select AI-Thinker ESP32-CAM. You must have the ESP32 add-on installed. Otherwise, this board won’t show up on the Boards menu. If you have not done the instalation, there is a guide below on how to do it.

2 – Go to Tools Port and select the COM port the board is connected to.

3 – For simplicity, you can upload a blank sketch to your board.

4 – When you start to see some dots on the debugging window, press the on-board RST button. After a few seconds the code should be successfully uploaded to the board.

Figure 5

5 – When you see the “Done uploading” message, remember to remove GPIO 0 from GND and press the on-board Reset button to get the board ready.

Install the ESP32 Library and Add-on

To program the ESP32-CAM board with Arduino IDE, you need to have Arduino IDE installed as well as the ESP32 add-on.

Before starting, make sure you have the latest version of the Arduino IDE installed in your computer. You can get the latest version from arduino.cc/en/Main/Software.

Follow the next steps to install the ESP32 add-on and board on arduino IDE.

  • In your Arduino IDE, go to FilePreferences
Figure 6
  • Enter https://dl.espressif.com/dl/package_esp32_index.json into the “Additional Board Manager URLs” red field the figure below. Then, click the “OK” button:
Figure 7
  • Open the Boards Manager. Go to Tools > Board > Boards Manager
Figure 8
  • Search for ESP32 and press install button for the “ESP32 by Espressif Systems“. It should be instaled after a few seconds.

After you make this steps, the ESP32-CAM board should be ready. Plug the ESP32 board to your computer. In your Arduino IDE open Tools > Board menu and select the board, like figure 10. In our case is AI-Thinker ESP32-CAM. Select the correct port and it is ready to program.

Figure 9

Coding

Bibliografy

  1. https://randomnerdtutorials.com/esp32-cam-ai-thinker-pinout/
  2. https://randomnerdtutorials.com/about/
  3. https://randomnerdtutorials.com/program-upload-code-esp32-cam/
  4. https://loboris.eu/ESP32/ESP32-CAM%20Product%20Specification.pdf
  5. https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf

Please follow and like us:
Ricardo Carreira

Author: Ricardo Carreira

Portuguese Electrical Engineer interested in Automation, Energy, Power generation, Renewables and 3D printers . With a degree in Electrical and Computer Engineering in the field of Energy and Automation. Currently starting in Master’s degree in Electrical Engineering.

Leave a Reply

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