Setting up the ESP32-CAM with the Arduino IDE and Camera Web Server example.
The ESP32-CAM module features an ESP32-S chip, an OV2640 camera and a microSD card slot. There are other ESP32 based camera modules available that should work if the pins are set in the sketch.
Adding or Updating the ESP32 Range in the Arduino IDE
If you’ve never used an ESP32 board in the Arduino IDE you need to follow the first part of this tutorial: ESP32 Built-in OLED Heltec WiFi Kit 32
If you already have the ESP32 boards available in your IDE then you just need to update to the latest version of the board libraries. To do this, open the Arduino IDE and in the menu: Tools > Board:xxxxx > Boards Manager:
Search for ESP32:
Use the 1.0.4 or 1.0.5 versions. The face recognition code has been updated in the most recent versions (2.x.x) and no-longer works on ESP32 and ESP32-S2 based boards like this.
The ESP32-CAM doesn’t come with a USB connector so you need either a CP2102 or a FT232RL USB to TTL Serial Converter to connect it to your PC. When using WiFi the ESP32 can use more current than is supplied via USB through these devices resulting in the module crashing and rebooting. I found the top device worked fine but the FT232RL didn’t work for me. If you use a FT232 with 5v and 3.3v, set the voltage jumper to 3.3v. You might be able to use the 5V from the side of the board to power the 5v pin on the camera.
Wire the module according to the diagram above. The green connection should be connected when flashing the module and disconnected when running.
There are now also power boards like the one below that make the connection much easier for uploading and reading the serial output.
Running the Camera Web Server Example
Plug in your module and change the board settings to these:
Open the Sketch by navigating File > Examples > ESP32 > Camera > CameraWebServer:
Edit the Sketch defines to look like this (assuming you are using the Ai-Thinker module):
// Select camera model //#define CAMERA_MODEL_WROVER_KIT //#define CAMERA_MODEL_M5STACK_PSRAM #define CAMERA_MODEL_AI_THINKER
Change the following two lines to match your WiFi connection details:
const char* ssid = "NSA"; const char* password = "orange";
Click Upload to build and flash the Sketch to your device.
If you get an error that the device fails to connect. Check that the IO0 pin (green in the diagram) is connected to GND and press the reset button under the module and try again.
When the device has completed flashing, unplug IO0 from GND.
Open the serial monitor via Tools > Serial Monitor.
Press the reset button on the ESP32-CAM and watch the start up sequence in the serial monitor:
Look for the IP address that the ESP32 has been given on your network.
Type that IP address into your browser. You should be able to see a GUI on the left where you can control elements of the camera, set face detection and face recognition. Click Get Still to take a photo. Click Start Stream to see a video stream from the camera.
On-Board vs IPEX Antenna
A few people have commented that they have received the board with the antenna jumper set for an external antenna rather than the on-board antenna. You can see the two different settings below:
If you have a low frame rate or poor reception this might well be the problem. You can either move the jumper with a bit of very careful soldering or buy an IPEX WiFi antenna which will improve the signal.
ESP32-CAM Video Playlist
IF you prefer your tutorials in video format you can visit the Robot Zero One YouTube channel and view the ESP32-CAM playlist here: https://www.youtube.com/channel/UCpqVEutU_Jcq34ws4tyUReQ/playlists
Here’s a list of resources that I used to get this working:
https://github.com/espressif/arduino-esp32/tree/master/libraries/ESP32/examples/Camera/CameraWebServer – Arduino Camera Web Server example
https://github.com/espressif/esp-who – Homepage for the face recognition library
If you found something useful above please say thanks by buying me a coffee here...