The Esp32-Cam is a cheap, 2-megapixel, small-size camera module developed by AI-Thinker. It integrates an Esp32, a single 2.4 GHz Wi-Fi-and-Bluetooth SoC (System On a Chip) designed by Espressif Systems, and an OV2640 camera from OmniVision.
Its dimensions and, of course, its price, make it a great choice for small IoT projects, even if getting started can appear more daunting than it is.
In this article, we’ll take a closer look at the Esp32-Cam, we’ll go over what the Arduino IDE is, and we’ll look at different ways to connect them so that you can start using an Esp32-Cam in your projects. We’ll see how it can be simple even if you’re a complete beginner, so let’s get started!
The standard AI-Thinker Esp32-Cam is compact (27 mm x 40.5 mm x 4.5 mm), and really cheap (around $10). Even the most expensive Esp32-Cam CH340 version will only set you back around $20.
The Esp32-Cam boasts a built-in flashlight and a microSD card slot to save images from the 2-megapixel camera. The same microSD card can be used to store files useful for your application.
Along with the integrated Wi-Fi and Bluetooth connectivity (with an onboard antenna), the board has a connector for an external antenna, which can be useful if you need to increase the range of your signal.
You can power the board with 3.3V or 5V – just choose the proper pin. Even if many GPIOs are used by the camera (15 pins), the microSD adapter (6 pins), the built-in flashlight (GPIO 4), and the built-in red LED (GPIO33), 10 GPIOs remain to be connected to external peripherals (see the light blue labels in the image above).
On the downside, because of its conveniently small size, there’s no built-in USB programmer (only the Esp32-Cam CH340 has it), and the reset switch is on the bottom, which isn’t easily accessible.
Nevertheless, having one or more Esp32-Cam boards on hand can help you start a project where you need a small camera and a cheap solution “all-in-one”. Maybe you can create a swarm of small robots to conquer the world! There are plenty of ideas for you to try.
The simplest way to start programming this little board is to use the Arduino Esp32 toolchain in the Arduino IDE (Integrated Development Environment), an application developed by Espressif that’s used to write and upload code (programs) to Arduino-compatible boards.
The Arduino IDE uses a stripped-down and simplified version of the programming language C++. Beginners can start with examples and tutorials, but more advanced programmers can create their own libraries and use a CLI (Command Line Interface) application.
With Arduino, your program is called a “sketch”, and when you compile it, it’s “magically” debugged, translated into proper C++, and sent to your board in binary form (machine language).
If you encounter errors while compiling, the Arduino IDE itself gives you suggestions to find your mistake. Quite often, especially for new users, it’s a syntax error. One of the most frequent errors is to forget to add a semicolon to the end of a line. You can learn more about Arduino IDE version 1, Arduino IDE version 2, Arduino Web Editor, and Arduino PRO CLI from the Arduino website.
There are different ways to connect your Esp32-Cam and Arduino IDE (running on your computer), both physical and remote. Next, we’ll go over five different physical ways to make the connection, then we’ll see how to work your Esp32-Cam and Arduino IDE, and finally, we’ll look at the alternative: connecting things remotely.
The FTDI (Future Technology Devices International) cable is a USB-to-Serial converter that provides a simple way to connect your standard Esp32-Cam to a USB port on your computer. If you have an FTDI cable on hand, you can power the board with the 3.3V or 5V pins, plus Ground (GND) pins.
Pin GPIO0 determines the Normal mode or the Flash mode of the module:
There are two serial pins, GPIO01 and GPIO03 (marked UOT and UOR), which can be used for serial transmission and to receive data with the UART (Universal Asynchronous Receiver-Transmitter) protocol.
Other than the FTDI cable, you’ll need five jumper cables to connect the Esp32-Cam, as seen in the image above:
Keep in mind that, because the reset switch is on the bottom of the board, it can be difficult to reach. To reset the board, you can simply disconnect and reconnect the 5V wire or the ground wire. Remember to keep the Arduino Serial Monitor open (Arduino IDE Menu > Tools > Serial Monitor) because it can give you important information and help you to debug your sketch.
An FTDI programmer has exactly the same functionality as the cable – it’s also a USB-to-Serial converter, allowing you to simply connect it to a USB port on your computer. The difference between the cable and the programmer is the different pinout of the serial connection:
Usually, FTDI programmers have a jumper to select 3.3V or 5V. Just remember to connect to Esp32-Cam accordingly. If you set the programmer to 5V, connect to 5V on the board; and if you set the programmer to 3.3V, connect to 3.3V on the board.
Maybe you don’t have an FTDI cable or an FTDI programmer at hand, but you may have an Arduino, be it a Nano, Uno, or other Arduino board.
You can send data from the Arduino board to the Esp32-Cam serially by using the UART Communication Protocol, which has the following connections:
The image above shows Arduino Nano connections.
To connect an Arduino Uno, you can follow the same instruction as for Arduino Nano; you can confirm the Arduino Uno connections in the image above.
If you want to use another Arduino board you already own, you just have to make sure you are using the proper pins according to the numbered schema above.
To connect the Arduino board to your computer, you only need a USB connector (a mini USB cable is needed for the Nano).
Esp32-Cam MB Micro-USB programmer is a shield for a standard Esp32-Cam board that adds a Micro-USB port. You just need to plug your board into the shield.
Once paired, as in the photo above, you only need a USB-micro-to-USB-A cable to connect to your PC or Mac and upload the code. That’s it. Easy, right?
You can buy either the MB shield alone or the kit, which includes the Esp32-Cam and the MB shield. To connect to your computer, you’ll need a micro USB cable.
The Esp32-Cam CH340 is the only Esp32-Cam version with an integrated serial port – the only con (if it even is one) is that the board is 8 mm longer, which may not be an issue for some. While the Esp32-Cam CH340 has a size of 27 mm x 48.5 mm x 4.5 mm, the standard Esp32-Cam is 27 mm x 40.5 mm x 4.5 mm.
The CH340’s chip is used to provide USB connectivity directly on the board, and perhaps the most important thing is you needn’t use a cable, a programmer, an Arduino board, or a shield!
Now that we’ve gone over different ways to connect your Esp32-Cam physically to your computer, let’s go over how to work on it with the Arduino IDE.
As mentioned, the Esp32-Cam from AI-Thinker comes with no built-in USB programmer, so we need to use some of its pins to give power, upload programs, and communicate with the board. This can be done in a few different ways, and we’ll look at how to use the Esp32-Cam with Arduino IDE.
While there’s a new version of Arduino IDE (Arduino IDE 2), it’s still a release candidate version. You can choose to go safe with the Arduino IDE 1 or try the new Arduino IDE 2 and, if you’re the adventurous kind, you can even choose to download a preview of the upcoming release with the most recent features and bugfixes.
Now you’re ready to write your first sketch and upload it to the Esp32-Cam!
You can find the differences between Version 1 and Version 2 of Arduino IDE on Arduino.cc documentation: “The new Remote Sketchbook integration, released in July 2021, is a ground-breaking feature that allows you to synchronize your Arduino Cloud Sketchbook to your local computer”.
If you create a sketch in the web editor and then go back to Arduino IDE 2.0 on your computer, in the Menu choice Arduino IDE/Advanced, activate Show/Hide Remote Sketchbook and small cloud icons will appear to Push or Pull your sketch. This means that you can choose your preferred version from IDE and “push” it to the Arduino Cloud, or choose the Cloud version and “pull” it to Arduino IDE.
Finally, let’s look at how to set up your Esp32-Cam with OTA in case none of the previous options work for you.
Perhaps a physical connection won’t cut it and you need a remote setup. Maybe you have a lot of devices running the same software or it might be difficult to make a physical connection to your board. Over-the-air (OTA) or Firmware-over-the-air (FOTA) updates come to the rescue.
There are many ways to implement OTA on generic Esp32s, but as the scope of this article is to give you the basics, we’ll concentrate on basic-over-the-air.
As of this writing, Basic OTA only works with Arduino IDE 1; an issue has been opened in the Arduino IDE GitHub repository about Arduino IDE 2 not working properly.
So, to implement Basic OTA, start Arduino IDE 1 and follow these steps:
To use OTA in your sketch, you need to keep the basicOTA structure and just add your code in the 4 basic sections of an Arduino sketch:
Happy OTA upload!
License: The text of "How to Use the Esp32-Cam with Arduino IDE" by All3DP is licensed under a Creative Commons Attribution 4.0 International License.
CERTAIN CONTENT THAT APPEARS ON THIS SITE COMES FROM AMAZON. THIS CONTENT IS PROVIDED ‘AS IS’ AND IS SUBJECT TO CHANGE OR REMOVAL AT ANY TIME.