I am supported by our readers and may earn a commission if you buy through our Affiliate Links at no cost to you. Thank you so much for your support. Read More
The ESP32 Cam combines a microcontroller with a 2MP camera. Not only that but it has built in WIFI and Bluetooth with a micro SD card for storage. If you were to try this with an Arduino, it would be a lot more expensive and complicated. Likewise a Raspberry Pi would also be more expensive. Their webcam alone is around $60.
The camera modules is inexpensive, around $10 so it’s the perfect hardware if you need a camera.
Unlike an Arduino board, there is no USB connector. You have 2 options available.
- Use an FTDI board and connect 4 wires to the ESP32 Cam
- Buy the modules with a pluggable shield.
The FTDI board is a small board that you connect to temporarily allow a USB connection. I suppose you could leave it plugged in, but most buy a couple of these and use them just for programming multiple ESP32s. They are also used if you are making your own microcontroller board using the ATMEGA328-PU chip.
2 Pack with removable usb shield
For this tutorial, I’m going to use the second option. I bought 2 of these for cheap and each has it’s own USB connection. You are free to remove it after programming. I chose this option because I thought it would be easier than manually jumping wires.
Connecting With Arduino IDE
There are a few steps required in order to get the board connected to the Arduino IDE.
- Install required libraries
- Select correct baud rate
- Select correct board
Install Libraries
The Arduino IDE boards manager will show all available libraries. If you type in ESP32 and nothing shows up, then that means you need to tell the IDE where it can find new libraries. This is simple. All that is required is that you add a comma separated list of URLs.
The URL for the ESP32 libraries is located at:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
I am using MAC OS so the instructions here are based on that. Your’s may be different but the general procedure is the same.
Navigate to Arduino->Preferences and then look for the Additional Boards Manager URLS input field.
Here you can see that I have already added a URL for Adafruit. To add the URL for the ESP32, just insert a comma and the URL above and press save.
Once complete, go back to the Boards Manager and add the ESP32 library Tools->Manage Libraries
Select Your Board
For this tutorial we are running the demo WebCamera Server sketch. If you open the sketch you will notice that the default board is the AI Thinker
This is defined by this line of code.
#define CAMERA_MODEL_AI_THINKER // Has PSRAM
This is the board I selected under the tools manager.
Run Test Sketch
We need to try a test sketch to ensure everything is working right. I chose to setup a Camera Webserver so that I could test both WIFI and the camera.
After you have selected the right board (Node32 S) and baud rate, navigate to File->Examples->Examples for Node32S->ESP32->Camera->CameraWebServer
Locate these two lines
const char* ssid = “**********”;
const char* password = “**********”;
replace the *****’s with your SSID and Wifi password for your network.
Upload the sketch and check the serial monitor. You should see this.
Webserver Optons
Open a web browser on any device using the same WIFI network. Navigate to the ip address shown. Mine was 192.168.50.55 Press Start Stream and the web camera window will open below if everything is working correctly.
You should see a window at the bottom for the webcam video. You can change the size of the output by scrolling near the top of the options and setting the resolution.
Troubleshooting
Won’t Compile
Check to see if the baud rate is correct (115200). This happened to me so I was surprised that it was the baud rate.
Check to see if correct board is selected (Node32 S for this tutorial)
Check to see if all libraries are installed
Garbage in Serial Monitor
This can happen if you have not set the serial monitor to the correct baud rate. Check to make sure it is set to 115200