How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (2024)

In this project, I’ll be showing you how to assemble and configure a Raspberry Pi Zero W to be used as a WiFi security camera, which is also accessible over the internet.

We’ll be using an operating system called MotionEyeOS on the Raspberry Pi, which is a web-based, mobile and tablet friendly surveillance system. It can be used with both the Raspberry Pi camera or any USB web camera plugged into the Raspberry Pi. You can also set up motion detection with email notifications, take still images and time-lapse movies, and even configure it to upload media files to network storage locations or to cloud storage services.

Here’s a video of the build and the camera in operation, read on for the full step by step instructions.

What You Need To Build Your Camera

Optional Alternative (You’ll still need to buy the camera):

  • Pi Zero W Kit (Includes Pi Zero W, Case, SD Card, Power Supply & Camera Ribbon Cable) – Buy Here
How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (1)

Assembling The Raspberry Pi Zero WiFi Security Camera

I’ve used a Raspberry Pi Zero W for this project because they’re relatively cheap and compact, making them perfect to mount discretely around your home. You can set up a couple of cameras around your home for less than $100. The W version has built-in WiFi, so there’s no need for an external WiFi or Ethernet adaptor to connect it to your home network.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (2)

Let’s start by assembling the components into the Raspberry Pi Zero case.

If your Pi Zero came with a heat-sink, attach it to the board using the adhesive tape on the heat-sink.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (3)

Once you’ve done that, you’ll need to connect the camera to the Pi.

The ribbon cable just slides into the connector with the contacts facing towards the board.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (4)

Make sure that the black clip is pulled away from the connector to open it. Then push the black clip back into place to grip the ribbon cable once it is seated correctly in the connector.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (5)

Now do the same on the connector on the Raspberry Pi to connect the camera module to the Pi.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (6)

Next open up the case and push the Pi into the back of the case. There are small pegs on the case which align with the screw holes on the Pi and the ports should all be aligned with the cutouts on the side of the case.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (7)

Next, clip the camera into place on the top cover and then close up the case to check that it all fits correctly.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (8)

We can now move on to preparing the SD card with the MotionEyeOS operating system.

Loading The Operating System Onto The SD Card

Use a card reader to plug the card into your computer.

Now you’ll need to download the MotionEyeOS software.

If you’re not using a Raspberry Pi Zero, or you’d like to use a different board, have a look at the list of Supported Devices to see which version of the operating system you should download.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (9)

Go to the list of latest releases and make sure that you download the latest version of the software which is compatible with your board.

We’ll be using the Raspberry Pi version which was released on the 6th of June.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (10)

Once you’ve downloaded the software, you’ll need to unzip it to a folder on your computer. I used Easy 7-Zip for this. Don’t try to flash the zipped image to your SD card, it won’t work.

You’ll then need to use an image flasher to flash the disk image to your SD card. The one recommended in the installation instructions on GitHub is Balena Etcher. Once you’ve downloaded and installed the software, you can flash the disk image.

You’ll need to first select the source file, which is the disk image that you unzipped in the previous step.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (11)

Then select your destination target, which is your SD card.

Then click on Flash and wait for the software to write the disk image to your SD card.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (12)

Finally, you’ll need to tell your Raspberry Pi how to connect to your WiFi network.

To do this, use the template below. It’s a basic text file in which you’ll need to add your country code and then your Network name or ID and the network password.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (13)

wpa_supplicant TemplateDownload

You can find a list of country codes on Wikipedia.

Rename the file to wpa_supplicant.conf, making sure to change the extension as well and then put it into the 30MB settings partition which you’re able to write to on your SD card.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (14)

Once you’ve done this, your SD card is ready to be installed into your Pi for the first boot up.

Booting & Configuring Your Pi Zero Security Camera

You don’t need to attach a monitor for this next step, but it is helpful to check that you don’t get any error messages and to make sure that the Pi has finished booting up.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (15)

The first boot up takes about a minute or two to complete, it’ll boot up much faster than this after the first boot.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (16)

If you haven’t used a monitor then you’ll need to find the IP address of the Pi using a network analysing tool on your computer.

Once you’ve found the address, type it into your browser to access the Pi and it’s video feed.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (17)

If everything is working correctly, the video feed from your camera should show up after a few seconds.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (18)

If you open up the settings menu, you can also shutdown or restart your Pi, which you’ll need to do if you’re going to be disconnecting it to install elsewhere. If you’re asked for login details, the default username is admin, with no password.

Mounting Your Camera

I 3D printed a small GoPro adaptor to stick onto the back of the Pi case so that it can be mounted onto any standard GoPro mounts.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (19)

Pi GoPro Mount Print FileDownload

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (20)

I’m going to be using a suction cup mount to mount the Pi onto an outside window. It’s under cover, so it’s protected from direct sunlight and rain.

This mount also enables the camera to be positioned so that it’s pointing in the right direction.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (21)

You’ll need to power it using a USB power supply. You can also use a power bank to temporarily power it for a mobile surveillance system.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (22)

Let’s have a look at the video feed outside.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (23)
How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (24)

You can also access the camera using your mobile phone or tablet by typing the same IP address into your device’s browser.

Configuring Port Forwarding To Access Your Camera Over The Internet

The last step is to configure port forwarding on your router, so that you can access the camera from the internet.

You’ll need to start by assigning a fixed IP address to your camera, so that it doesn’t change every time it re-connects to the network. This can be done in the MotionEyeOS settings menu. Set the IP configuration to manual and then change the IP address to the address you want to always assign to the camera. This should be out of the range that your router typically assigns addresses to otherwise you’ll land up with a conflict it that address has already been used.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (25)

For example, if your router typically assigns IP addresses in the 192.168.10.1 to 192.168.10.20 range then you should pick an address higher than 20, so something like 192.168.10.21 and onward for your cameras.

You might also need to change your Default Gateway to your Router’s address.

Next, you’ll need to set up port forwarding on your router. This is something I can’t really show you how to do because it’s very different for each router make and model. But you essentially need to login to your routers configuration page and then add a port forwarding instruction so that requests from outside your local network on a specific port are forwarded to a particular device, in this case, your Raspberry Pi camera.

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (26)

Here’s the general idea of what you need to do:

  • You’ve got your Raspberry Pi’s local IP address (this is what you’ve been using to access the camera through your browser), you now need to know what port number it is communicating on. This is usually Port 80 by default. Since this is the default, it’s a good idea to change it to a port number that is unused by any other services as a security measure.
  • Next, you’ll need to find your router’s external IP address. This can be done by googling – “What’s My IP” from any device connected to the same internet-connected network.
    • This is the IP address you’ll need to type in over the internet in order to access your camera while you’re away from home. It is the IP address which your provider has assigned to your router. So this might change if you don’t have a fixed IP address arrangement with them.
  • Lastly, you need to choose an external port to forward. Again, you can choose any unused port. You’ll use the combination of your router’s IP address and this port number in your mobile device’s browser in order to access the camera.

Now that you have an external IP address and port as well as your internal IP address and port, you should have all of the information that you need to configure the port forwarding instruction on your router. This is the part that is very different for each router manufacturer and model, so you’ll need to figure out how to do this on your own router.

Essentially what you’re doing is telling the router that when an external request is sent to it on the particular port you’ve chosen, the router should forward the “web page” which is served to it when it calls the local IP address and port number so that you’re able to see it from outside the network.

Once this is done, you should be able to access your camera over the internet in the same way you could do it locally. If you’re still unsure how to do this, try searching for setting up Port Forwarding on your specific router make and model.

Let me know if you’ve built your own Raspberry Pi Zero WiFi Security Camera in the comments section. What are you using it for?

Share This Guide

How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (27)
How To Make A Raspberry Pi Zero WiFi Security Camera - The DIY Life (2024)
Top Articles
Latest Posts
Article information

Author: Dan Stracke

Last Updated:

Views: 6028

Rating: 4.2 / 5 (63 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Dan Stracke

Birthday: 1992-08-25

Address: 2253 Brown Springs, East Alla, OH 38634-0309

Phone: +398735162064

Job: Investor Government Associate

Hobby: Shopping, LARPing, Scrapbooking, Surfing, Slacklining, Dance, Glassblowing

Introduction: My name is Dan Stracke, I am a homely, gleaming, glamorous, inquisitive, homely, gorgeous, light person who loves writing and wants to share my knowledge and understanding with you.