A cheap, hackable, WiFi-enabled camera is a holy grail for makers. When we first heard about the ESP32-CAM from AI-Thinker, we had to find out if we had such a product for our maker toolbox. We ordered one for £6.66 (including delivery to the UK) from YX Electronic Components on AliExpress.
It came in two parts. The main board (which is an ESP32 module mounted on a larger board) and a separate camera module. The flex cable from the camera slots into the main board. Although there’s no specific mounting for the camera, it sits nicely on top of the memory card slot, so with a drop of glue or tape, you can secure it easily.
The board is based on an ESP32 module, which is a programmable microcontroller with built-in WiFi and Bluetooth, with an additional 4MB of external RAM. Also on the board is a memory card slot and a camera connector that can take an OV2640 or OV7670 camera module (the former was included in the price of our board). In principle, this is a pretty beefy unit. The ESP32 has plenty of processing power, with two 120MHz 32-bit processing cores.
The memory card slot is listed as ‘TF’ (which stands for TransFlash) on every spec sheet we’ve seen. This is a little odd as this is the original name for what has now become microSD. We’re not sure why they’re listed using this name and not the current microSD, but you can use microSD cards in this port (though you will have to add support to them in your software).
Let’s take a look at what it takes to get the board up and running. There are a few ways of programming the ESP32-CAM, but we’re most familiar with
the Arduino IDE, so we tried this. To install the ESP32 boards, go to File > Preferences and add ‘https://dl.espressif.com/dl/package_esp32_index.json’ to the Additional Board Manager URLs box – this is a comma-separated list, so add a comma before it if you already have any URLs in the box.
In the Tools > Boards section, you should now have an ESP32 Arduino section. In that section, you should see an entry for AI Thinker ” ESP32-CAM. However, we weren’t able to program the board using this. Instead, we used the definition for another, similar board: the ESP32 Wrover Module.
Once you’ve selected this, you should find the web server example sketch, which is a great test to make sure everything’s connected properly. This is in Files > Examples > ESP32 > Camera > CameraWebServer.
You’ll need to make a few changes to this sketch. First, add ‘//’ to the start of the following line to comment it out.
Then delete the // at the start of this line to enable it.
Finally, you’ll need to enter your WiFi details in the following lines:
const char* ssid = “”;
const char* password = “”;
You’ll also need to set the Partition Scheme to Huge App and the Upload Speed to 115200 (these are in the Tools menu). That’s the software side of things set up for this board, so let’s now take a look at the hardware.
You may notice that there’s no USB port on this board, so you’ll need a USB to serial adapter to program it. Any USB to UART adapter should work, and they are available for a few pounds. We used a Particle Debugger because we happened to have one with us, but this is overkill for this project.
You’ll need four connections between the UART adapter and the ESP32 Camera: 5 V (this may be labelled VUSB) to 5 V, GND to GND, TX on the USB adapter to U0R on the ESP32-CAM, and RX on the adapter to U0T on the ESP32-CAM. Also, you’ll need to connect IO0 on the ESP32-CAM and GND – this puts the board into flashing mode, and we’ll remove this once we’ve programmed the board.
With that setup,you can plug your USB to UART adapter into your computer’s USB port, and now you should be able to select a Port from the Tools menu in the Arduino IDE. Press the upload button (the arrow icon) and – after a short wait – your code should be on your board. There’ll be a message in the black box at the bottom of the screen saying that the upload was successful (or not).
You can now unplug the IO0 to GND connection but leave everything else connected for now. Open the serial monitor in the Arduino IDE, set the baud rate to 115200 (bottom-right corner), and press the reset button on the ESP32-CAM.
In the serial monitor, you’ll see a bit of debug code followed by something like:
Camera Ready! Use ‘http://x.x.x.x’ to connect
If you point a web browser to that URL, you’ll see the camera control page. Press ‘Start stream’ to see the output of the camera.
For a cheap IP webcam, this works well if you’re happy using the Arduino IDE to upload credentials. You can get streaming output at up to 1284×1024 pixels (we got a frame rate of about 6 fps at this size, and faster at smaller sizes). The fact that it outputs data in a standard format, and so works well with open-source IoT hubs, is a bonus. There’s also some rudimentary face recognition, but we found this to be quite unreliable.
The cooling on the board does struggle if you’re streaming continuously. The board gets very warm, and some users report it stopping working. We’d expect this to be a bigger problem if the unit is enclosed, so if you plan to use a case of some sort, you may need to take this into account with a heat sink or even a fan.