How to Make a WiFi Security Camera (ESP32-CAM) DIY Wireless CCTV Camera

22,103

322

30

Introduction: How to Make a WiFi Security Camera (ESP32-CAM) DIY Wireless CCTV Camera

About: Hi! I'm Max, a young engineering enthusiast/hobbyist who also runs a YouTube channel. I'm here to bring you Electronical and Mechanically-related step-by-step project tutorials for you to easily follow along. …

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:

https://youtu.be/0uz-YrfaSO8

Supplies

• 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...

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json

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 :)

Code: https://github.com/s60sc/ESP32-CAM_MJPEG2SD

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)

• ESP32-CAM

• 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

• Antenna

• 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".

Step 21:

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.

Step 22:

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:

https://youtu.be/0uz-YrfaSO8

Anything Goes Contest 2021

This is an entry in the
Anything Goes Contest 2021

Be the First to Share

    Recommendations

    • Fix It Speed Challenge

      Fix It Speed Challenge
    • Jewelry Challenge

      Jewelry Challenge
    • One Board Contest

      One Board Contest

    30 Comments

    0
    antony.john.payne
    antony.john.payne

    Question 4 days ago

    Looks a great project.
    However I get a compilation error.
    'esp_log_system_timestamp' was not declared in this scope

    Can you advise why I get the error, possibly a missing library?
    Thanks

    0
    wolasteff
    wolasteff

    5 days ago

    Thankyou for sharing

    0
    ArindamD3
    ArindamD3

    Question 8 days ago

    what's the overall weight of your camera setup ?

    0
    Drishvarindani
    Drishvarindani

    Question 11 days ago

    how much money will it be to spend on the things that we need

    0
    JoeH245
    JoeH245

    14 days ago

    Have you had any issues with using the TP4056 for charging and load at the same time? If a load is attached to the battery while charging, then the TP4056 may not detect when the charge current has fallen to C/10, so it could continue charging and this could be dangerous.

    0
    Max Imagination
    Max Imagination

    Reply 12 days ago

    Hi,
    From my tests with my TP4056 charging board connected up with the cam's battery, I found that it won't overcharge the battery as it's got the cut off function, with the right current limiting resistor on-board, this shouldn't be a problem.
    Thanks for your input.

    0
    Tarantula3
    Tarantula3

    14 days ago

    Well done mate

    0
    rop12770
    rop12770

    14 days ago

    Hi. Can't it record on the sd card on a loop?
    Can a NAS be selected as backup for saving the records?
    Thanks

    0
    Max Imagination
    Max Imagination

    Reply 12 days ago

    Hi,
    Yes, once the MicroSD card starts getting close to being full, the footage will be deleted by the program and start filling up from scratch.
    You can have the recorded footage saved in the cloud or by an FTP server if you set one up, for instance.
    Cheers!

    0
    ed.darby
    ed.darby

    17 days ago

    Very nice.

    A little tip is that, if you use this sketch, you can then simply visit http://<yourCamIP>:81/stream and you can then view that in any browser or use it with webcam security software like Yawcan etc.

    0
    cliffburton71
    cliffburton71

    Reply 13 days ago

    With this "Yawcam" application, can it be viewed remotely ??? If it's only on the local network, it doesn't make sense in my opinion.

    0
    Max Imagination
    Max Imagination

    Reply 17 days ago

    Thank you for this! I'll keep it in mind for my DIY CCTV cam setup 👍

    0
    SandraN30
    SandraN30

    Question 17 days ago on Step 22

    Tem o protocolo RTSP e teria opção de autenticação nele? Uma questão de segurança já que esse protocolo é ignorado, porém é inseguro sem configuração de autenticação..

    0
    Max Imagination
    Max Imagination

    Reply 16 days ago

    Olá,Você deve ser capaz de criar sua própria senha adicionando-a ao " " apropriado na mesma guia onde você normalmente selecionaria o modelo da sua câmera.

    0
    Drishvarindani
    Drishvarindani

    17 days ago

    how long does it take to make this

    0
    Max Imagination
    Max Imagination

    Reply 17 days ago

    That can all depend... After all it is not about the time it takes, it's in fact about the final end result that one will be truly happy with using ✌😊

    0
    BillerB
    BillerB

    17 days ago

    Great instructable. Super clear. And great timing, got an ESP32 cam module and bird box for Xmas,

    0
    Max Imagination
    Max Imagination

    Reply 17 days ago

    Thanks a lot! Good luck with your project ✌