How to Begin and Blink a LED with ESP32 CAM Board

In this tutorial, I am going to show you how to blink a LED using the 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 a microSD card slot to save images while communication 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 broadcasting, facial recognition, image processing and most importantly, built-in Wifi and Bluetooth. The ESP32 chip is so powerful that it can even process images. It also includes 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 serial pins. Because the board does not have a built-in programmer, you need to use these pins to communicate with an 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 would 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 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 recommend powering the board through the 5V pin. So, we will respect that.

Attention:
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 onboard LED, that is next to the RST button. That onboard 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 a battery or USB port on your computer. In this setup, it will be powered through a 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 connect GPIO 0 to GND to turn the ESP32 is in flashing mode. After uploading the code, the GPIO 0 must be disconnected from the GND pin.

Programing Using FTDI

Our development board can be programmed using Arduino IDE, but for that, we need to use an 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 installation, 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 on 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 in 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 these steps, the ESP32-CAM board should be ready. Plug the ESP32 board into 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


//LED BUILT_IN is GPIO 33 
void setup() {
  pinMode(33, OUTPUT); // Set the pin as output
}

// Remember that the pin work with inverted logic
// LOW to Turn on and HIGH to turn off
void loop() {
  digitalWrite(33, LOW); //Turn on
  delay (1000); //Wait 1 sec
  digitalWrite(33, HIGH); //Turn off
  delay (1000); //Wait 1 sec
}

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

38 thoughts on “How to Begin and Blink a LED with ESP32 CAM Board

  1. You actually make it seem really easy with your presentation however I in finding this topic to be really something which I
    feel I’d by no means understand. It seems too complicated and very vast for me.
    I’m having a look ahead in your next post, I will attempt to get the hang of it!

  2. Cool blog! Is your theme custom made or did you download it
    from somewhere? A theme like yours with a few simple adjustements would
    really make my blog shine. Please let me know where you got your design. Many thanks

  3. Aw, this was a very nice post. Taking a few minutes and actual effort to generate a great article…
    but what can I say… I procrastinate a whole lot and never manage to get
    anything done.

  4. It’s in point of fact a nice and helpful piece of information. I’m happy that you simply shared this useful info
    with us. Please keep us up to date like this. Thank you for sharing.

  5. We are a gaggle of volunteers and opening a brand new scheme
    in our community. Your website offered us with helpful info
    to work on. You’ve performed a formidable activity and our whole community will likely be thankful to you.

  6. I’m impressed, I have to admit. Rarely do I come across a blog that’s both educative and engaging, and let me tell you, you have hit the nail on the
    head. The issue is an issue that not enough people are speaking intelligently about.
    Now i’m very happy that I found this in my hunt for something concerning
    this.

  7. Hello I am so glad I found your blog page, I really found you
    by mistake, while I was researching on Yahoo for something else, Nonetheless I am here now and would just like to say thanks
    a lot for a remarkable post and a all round enjoyable blog (I also love the
    theme/design), I don’t have time to read through it all at the minute but I have saved it and also added your RSS
    feeds, so when I have time I will be back
    to read more, Please do keep up the awesome job.

  8. This is the perfect web site for everyone who wishes to
    understand this topic. You realize so much its almost hard
    to argue with you (not that I actually will need to…HaHa).
    You certainly put a fresh spin on a topic that has been written about for
    years. Excellent stuff, just great!

  9. Very nice post. I ust stumbled upon yoyr blog
    and wanted to say that I’ve truly enjoyed surfing around your blog posts.

    In any case I will be subscribing to your feed and I hope you write again very soon!

  10. Hello to every one, since I am genuinely keen of reading this website’s poet to
    be updated regularly. It carries nice data.

Leave a Reply to ucuz takipçi satın al Cancel reply

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

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.