Introduction: How to Make a WiFi Security Camera (ESP32-CAM) DIY Wireless CCTV Camera
Hey, fellow makers! I welcome you to my first instructable about this Homemade wireless ESP32-CAM WiFi Surveillance Camera which we're going to make today to monitor our home, environment, or perhaps to even spy on someone ;)
Even though decent commercial WiFi Security Cameras aren't all super expensive, they still cost quite a bit especially when you're wanting to buy several of them for your home security. In this instructable, you will learn how to make your own DIY Surveillance camera for cheap, under $15 depending on the supplies you may already have. This project will be based on the $9 ESP32-CAM AI thinker WiFi camera module, in my opinion, one of the best and cheapest camera development boards out there.
With this security camera, you can log into the web server by typing in its unique IP address into your web browser, and view what the camera sees along with being able to change things around on the side control panels. The camera with its current code can save recorded .MJPEG video files to an SD card when something/someone moves in front of the camera triggering it to start recording. The Security camera comes loaded with even more features which will be mentioned below.
So without taking up any more of your time, let's prepare to make this CCTV cam!
You may also want to watch the project's YouTube video. Link:
• ESP32-CAM with OV2640 2MP camera sensor
• FTDI USB to Serial converter (for programming) + Female-to-female jumper wires
• 4GB MicroSD card (TF Card)
• Clip-on antenna
• TP4056 1-cell Li-Ion Charging module
• (x2) 18650 3.7V 2600mAh battery
• Mini SPDT sliding switch (3A toggle switch is recommended)
• Some 24-gauge electrical wire
• 3mm Red LED
• 220 Ohm resistor
• Cylindrical plastic container (choice of camera's enclosure is optional)
• GoPro mount accessories (if you want your camera to be attached to a wall)
Step 1: Programming ESP32-CAM
First, let's upload the ESP32-CAM_MJPEG2SD code to the ESP32-CAM (credits to GitHub user "s60sc" for making their code available for anyone to download) please visit https://github.com/s60sc/ESP32-CAM_MJPEG2SD for more information and specs about the code, as well as the code itself.
To program the camera module, connect the camera module to a USB-to-serial converter "FTDI" like in the diagram seen above, with GPIO pin 0 connecting to GND allowing you to program the ESP. Don't forget to press the onboard reset button on the back of the camera module to set it into flash mode before uploading.
Step 2: Making Sure You've Got the "ESP32 .json Link"
Before we move on to the actual code, check that you have this ESP32 .json link pasted in the preferences tab of the Arduino IDE. This link gives you access to example codes, all of the needed libraries, etc...
Step 3: In the Code: Filling in Necessary Parameters
Open the Security Camera's code which you've downloaded (ESP32-CAM_MJPEG2SD) and fill in the necessary params such as selecting your camera model (uncomment "CAMERA_MODEL_AI_THINKER" if that's your board), enter your WiFi credentials, and lastly, FTP credentials (optional) if you're into getting hold of recorded footage remotely.
Step 4: Uploading Code to Board
Check that you have the following board, upload speed, flash freq, flash mode, partition scheme, core debug level, and your COM port selected. Then hit upload. Do know that uploading to the board may take a while, it's totally normal, please be a bit patient :)
Step 5: Preparing ESP32-CAM for Use & Getting IP Address
Be sure to unplug the jumper wire going from IO0 to GND, press the reset button, insert a Micro SD card into the module's slot (Min. 4GB), then obtain its unique IP address from the Serial monitor (Serial button can be found at the top right-hand corner of the Arduino IDE).
Step 6: Opening Up ESP32-CAM's Web-server
After typing in the given IP address into your web browser with the camera still being powered, you should get a page looking like this, by pressing the "Start Stream" button, you will be able to view live what the camera sees.
(With the latest version of this code from the GitHub user "s60sc", you can now manually start and stop recording. Before, you were only able to trigger it to record when it sensed a movement.
Step 7: Assembling the DIY Security Camera
Here are the parts you'll need in order to make the actual WiFi CCTV Cam. (Not totally accurate on the image to what was used)
• TP4056 1S battery charging board
• 18650 Li-Ion 3.7V battery
• SPDP Micro slide switch or 3A toggle switch
• 3mm Red LED
• 1/4W 220-ohm resistor
• 24-gauge electrical wire
• GoPro-compatible screw-mount
For its case/enclosure, choose a container or material that will be easy for you to work with, as for myself, I've had lots of trouble getting the hardware fitted into that flattened PVC pipe shown above. (Later, you see me use a cylindrical plastic container)
Step 8: Enabling Board for an External Antenna
Desolder this 0-Ohm resistor that connects the ESP to its onboard antenna and resolder it to connect the ESP to the external antenna port.
This step must be done if you want a better range by being able to connect your own antenna.
Step 9: Connecting Up the ESP32-CAM's Power Supply
Hook up this TP4056 4.2V charging board to the battery, B+ & B- connections from the board to the battery go as shown (Connect the board's input terminals near the Micro USB port to the battery's terminals)
Step 10: Extending Connections of Components
De-solder the ESP32-CAM's pin headers from both sides, instead, extend those pin headers by soldering them back on through wires. (Not to confuse you, try to use matching wire colors to their asserted purposes.
You can also add an LED (3mm Red LED) as a power indicator, connect it across the input power terminals of the camera board with a 220-ohm resistor.
Step 11: Circuit Diagram
Here's the DIY WiFi Security Camera's full circuit diagram.
Following this simple wiring diagram, you should have all of the hardware for your Homemade CCTV cam complete.
Step 12: Choosing the Right Battery to Fit a Certain Case
As you saw, I started out with a flat Li-Ion battery since I thought the components would go into a differently shaped case. Then realized swapping out the battery was needed in order for it to fit into its new, proper cylindrical case.
Best to use a battery with a capacity or mAh rating higher than 2000 for better performance.
I ended up using x2 3.7V 2600mAh 18650 batteries in parallel, giving 5200mAh in total. A decent amount of power capacity.
Step 13: Preparing the Hardware to Be Fit Into Its Case
Mark and drill out holes for certain parts of the hardware to poke out of the case
When choosing a good case for your camera, use something with two parts to it, a case that's fairly easy to work with.
3D printing your own one is definitely an option going for if you've got a printer.
Step 14: Fitting Things In
Next, add some adhesive/double-sided tape to parts such as the ends of the battery pack and ESP32-CAM module, then stick them into the case.
Seal any component that sticks through with glue (preferably hot glue)
Step 15: Weather-proofing
You may use hot glue to secure certain parts to the case if needed. Tape off the halves' joining section with electrical tape to prevent any water such as raindrops from seeping into the cam.
Slice corresponding pieces of rubber, fit them into any gaps/holes such as the Micro USB port at the back and SD card slot at the top front.
Step 16: Testing the End Product
Slide in your Micro SD card into the cam's slot, push that little piece of rubber back in, power the camera up by sliding the switch on the rear, and find its unique IP camera web-server (Return to previous steps 5 & 6 for more clarity).
The camera's procedure to starting up and finding its web server goes as followed, though, this time you won't have to press any reset button as you're not reprogramming the camera.
On your viewing device, in the camera web-server menu, simply press the "Start Stream" button and you should get a live video feed from the CCTV camera.
Step 17: Camera's Live Video Feed Panel
In this panel of the webserver, you should see a live video feed once you've pressed on "Start Stream".
Below you have additional info about whether it's recording or not, detecting low light (night time), space left on SD card, recording date, camera temperature, etc...
You may even toggle the ESP's onboard LED lamp with the slide of a panel button, show AI-detected motion, alter sensitivity on certain functions, and more.
To change the camera's recording resolution (not only viewing res.) you can open the resolution tab, scroll through and choose a lower or even a higher one. (1600 × 1200 is the highest)
Under the "Get Folder" tab, there you can preview the recorded video files and start playing the selected video file by pressing the same "Start Stream" button.
Step 18: Making a Wall Mount
This is optional, you may even create a mount to attach the DIY CCTV camera onto a wall, or the surface of your choice where you'd like to monitor things from.
I happened to use a set of action cam attachments for my mount.
Step 19: Powering the Camera Via USB
With the Homemade CCTV camera being attached to a wall, one would be better off having it continuously powered. So you may connect a 5V power supply to the Micro USB charging module connected via the cam's rear (Micro USB cable from wall socket phone charger). This is basically recharging the battery, but at the same time continuously powering the ESP32-CAM.
The battery won't last for too long if let's say you're going to record a spot overnight. Though running the camera on the battery can come in handy when you want to monitor an outdoor environment for a shorter period of time where a power outlet can't be reached.
Step 20: Emptying Recorded Footage
Once you can see your MicroSD card is getting full, you can slide it out of the camera and slot it into your PC via an SD card adapter to then view the .MJPEG files via a player such as "VLC Media player".
As you can see on the left-hand side of the phone's screen under the "Recording" status, when nothing is moving in the frame, the camera won't record anything until something or someone moves within the frame. It stops recording as soon as it doesn't detect any more motion.
There you have it, folks! Since you made it this far with your new cool little Homemade WiFi Security Camera, go out there with your new DIY CCTV cam and add an additional layer of security to your home! :)
Once again, here is the code & its extensions, additional information, specifications, possibilities, and more at the ESP32-CAM MJPEG2SD GitHub repository (Repository credits to the user "s60sc"): https://github.com/s60sc/ESP32-CAM_MJPEG2SD
You may also prefer to watch the full video tutorial on my YouTube channel:
This is an entry in the
Anything Goes Contest 2021