Introduction: DIY $25 USD Security Camera (ESP32-CAM)
The ESP32 is a microcontroller with WiFi and bluetooth capabilities, it is somewhat affordable and can have a variety of uses.
An ESP32-CAM takes the same microcontroller but with a camera module equipped, meaning it shares the same WiFi capabilities, and can also video-stream to a web server. The web server can be used to monitor video (just like a security camera!).
Usually an ESP32-CAM wouldn't come with a USB connector, but this project easier the ESP-32 I used comes with a micro USB port installed, so you don't need to worry about using an FTDI programmer (or any additional hardware for that matter).
The following is how to get the ESP32-CAM working as a simple security camera for your household, office space, or anywhere else that needs monitoring!
Supplies
ESP32-CAM with Micro USB port - $20 SGD
3.0m Micro USB cable - $9 SGD
3D Printing Supplies
Flashforge Adventurer 5M Pro - $448
eSun PLA+ Filament - $26
Step 1: Download Arduino IDE and ESP32 Library
To program my ESP32-CAM, I used Arduino IDE. You will need Arduino IDE installed along with the ESP32-CAM add-on to do this project.
- Download IDE from here https://www.arduino.cc/en/software/
- Select correct version
- Install
Once you have Arduino IDE, you need to install the ESP32 library, follow these steps.
- Arduino IDE
- Boards Manager
- Search for ESP32
- Install the add-on (esp32 by Espressif)
Step 2: Load Example Code
After the library is installed, you can now load the necessary code for this project. Go to:
- Files
- Examples
- ESP32
- Camera
- CameraWebServer
This will load the CameraWebServer example. Fig 2.1 shows steps to get there.
The example code you should see is on Fig 2.2.
Step 3: Prepare Code for Upload
Now, you need to comment (which is a #) your correct ESP32-CAM model, and uncomment (which is //) the models that arent the same as yours. If the model is incorrect, you may face issues later on..
For the ESP-32 CAM I cited in supplies, that model would be the CAMERA_MODEL_AI_THINKER. Visual for this is on Fig 3.1.
You also need to fill in your network SSID (WiFi name) and password, so it can connect to your wifi. This is shown on Fig 3.2.
Once the necessary information is filled in, you can now upload your code.
Step 4: Uploading Code
Before uploading, make sure you have the correct board selected.
- Tools
- Board
- AI-Thinker ESP32-CAM (or whichever you are using)
With the ESP32-CAM I linked in supplies, the AI-Thinker ESP32-CAM is the correct board model. You also need to make sure it is connected to the right COM port
- Tools
- Port
- Choose the correct COM port.
Now press the upload button and let the magic begin!
*You may need to hold on the on board boot/flash button as it uploads the code, to put it into boot mode. And as you see the “connecting…” message you might need to press the flash button once. If it works otherwise this can all be ignored.
If all goes well the code should start uploading. It should look like Fig 4.1.
Then as it uploads the code it will show as Fig 4.2.
After a while, the code should be fully uploaded. It will show the message on Fig 4.3
Step 5: Connecting to the Web Server
Now that the code is uploaded. We can now open the Serial Monitor to retrieve the IP address (link to the webserver.)
First, open the serial monitor. (Fig 5.1)
Then switch to a rate of baud rate of 115200. (Fig 5.2)
It will take a minute to connect to the wifi. Then, the IP address should be loaded in. As shown on Fig 5.3.
If this IP address doesn't load, press the on board reset button once. This button is the equivalent of cutting the power physically, without having to actually disconnect it. The ESP should start connecting to wifi after the button is pressed.
Step 6: Web Streaming
Now, we can connect to the web server! Open up the link and the photo above should show up.
On the side there is a variety of video settings to play with. For me personally, I change the resolution to a slightly larger view, and horizontally mirror and vertically flip. You can refer to the video above for the settings I like to use. Other than that, it's up to you how you want to use it.
Now scroll down and press “Start streaming”. Your ESP-32 is now web streaming!
Step 7: Housing
Now that the ESP32-CAM is up and running. If you want to use it as a security camera, it needs a proper housing.
My CAD skills aren't the strongest, so my housing was pretty simple, with one hole at the top for the cable, and a hole at the front for the camera. It isn't the most complex, but it works. The lid is also removable.
My housing is simple, but works. If you are more interested in 3D printing, you could probably find better housing online on websites like GrabCAD, or Thingiverse. I attached the STL files to my design if you would like to use it.
Attachments
Step 8: Security Camera
Now you can use your ESP32-CAM CAM as a real security camera! Set it up wherever you would like and monitor video around your household! I set mine up in the living room and was able to watch my dog lounge around in the living room.
Congratulations! You learnt how to use Arduino IDE, successfully uploaded code, and created your very own DIY security camera.
Step 9: Troubleshooting and Warnings
You will definitely face some issues when trying to create this. Here are some tips based on my experience.
- Some Micro USB cables are power ONLY, you need a data cable to upload code.
- Make sure you have the right COM port selected, or else it will not receive any serial data.
- Double check your WiFi credentials (Password and name.).
- This web streaming service is NOT 100% secure. If you are on a public wifi, other people may be able to watch through the camera at the same time as you.
For other troubleshooting tips, you can go to this link for proper support. ESP32-CAM Troubleshooting Guide: Most Common Problems Fixed | Random Nerd Tutorials




