Raspberry Pi Zero W CCTV Camera with motionEyeOS

8

After the successful deployment of my first motionEyeOS Pi security camera last year I was keen to get another setup. I wanted to use a Pi Zero W so I could mount it inside my conservatory using a Pi Hut “ZeroView”. This is a mount for the Pi Zero that lets you stick a Pi camera to a glass window.

motionEyeOS makes it so easy to setup a security camera and the difficult bit is usually the practicality of physically mounting it all. By using the ZeroView mount even this stage can be straightforward. The Pi Zero W would also allow me to put the camera in a place where I had no Ethernet available.

The following instructions explain how to quickly create a motionEyeOS based CCTV camera with a Pi Zero W.

Hardware

The components you will need for this project are :

  • Raspberry Pi Zero W (or Pi Zero with WiFi dongle)
  • Official Pi Camera
  • Camera ribbon cable
  • Pi “ZeroView” camera mount
  • Official 5V power supply
  • 16GB SanDIsk microSD card [Amazon]

I chose a standard camera rather than the Pi NoIR version as I’ve got standard motion activated flood lights which can provide illumination at night.

You can use a different sized SD card but I think 16GB is a good starting point.

Step 1 – Download motionEyeOS SD Card Image

Motion LogomotionEyeOS is available for a number of different hardware platforms. For the Pi Zero you need to download the image compatible with the “Raspberry Pi” rather than those available for the Pi 2 and Pi 3.

On Windows I used 7-zip to extract the image from the archive.

Step 2 – Configure Wireless

This is a crucial step when using the Pi Zero W. In order to configure the Wireless without messing about with monitors and keyboards you can configure it manually. To do this you need to add a text file to the boot partition on the SD card named “wpa_supplicant.conf”. Instructions for creating the wpa_supplicant.conf can be found in the Manually setting up Pi WiFi using wpa_supplicant.conf tutorial.

Pay careful attention to this step as a mistake can result in the Pi Zero failing to boot. You may need to re-write the SD card and start again in order to get a network connection.

Step 3 – Assemble Components

Next you should assemble the components :

  • Attach Pi and camera to the ZeroView mount
  • Insert microSD card
  • Attach ZeroView to window
  • Connect power supply

Step 4 – First Boot

Once everything was connected turn on the power. During the first boot the system performs some configuration so is best left for a few minutes.

Assuming the Pi has connected to your WiFi you need to find its IP address. You can either look in your router admin interface or use an IP scanner. “Angry IP Scanner” is suitable for this and is available for Windows, Linux and Mac.

Once you have the IP address you can enter it into the address bar of your browser to load the motionEyeOS web interface. With any luck you should see the output of your camera :

MotionEyeOS Pi Zero W camera

The icon in the top left can be used to open the settings side panel. Click the “person” icon to login :

MotionEyeOS Pi Zero W camera

Use “admin” as the username and leave the password blank. Click “Login” and you can now access the settings side panel.

Step 5 – Settings

Under general settings you should set passwords for “Admin Password” and “Surveillance Password”. I usually change the default “Camera Name” to something more unique and this is particularly useful if you have more than one camera.

MotionEyeOS Pi Zero W camera

Click the “Apply” button to save these changes.

Step 6 – Advanced Settings

By setting “Advanced Settings” to “ON” and clicking “Apply” switch you can enable a lot of useful extra settings :

MotionEyeOS Pi Zero W camera

These include the ability to :

  • change the Time Zone
  • change the Hostname
  • check for updates
  • Shutdown
  • Reboot

Step 7 – Other Settings

The following are settings I tend to change from the defaults.

> Preferences

As motionEyeOS can support more than one camera you can display their feeds in a grid. With only one camera I change these settings :

  • Layout Columns = 1
  • Layout Rows = 1

> Expert Settings

As we are using a Pi Zero :

  • Enable CSI Camera Led = OFF
  • Overclocking = PiZero

> Video Device

  • Camera Name = “Garden”
  • Video Resolution = 1600×1200
  • Frame Rate = 2

If your camera is mounted upside-down you can use the Video Rotation setting to rotate the image. I use this setting in my Garage camera. You may  also want to experiment with different video resolutions. Bigger is better but higher resolutions will create bigger images and these will take longer to shift over your network/mobile connections. Finding the ideal resolution is a balancing act between quality and performance.

> Video Streaming

These settings allow you to adjust the properties of the image streamed to the browser. These may require adjusting depending on the performance of your network and/or internet connection.

  • Streaming Frame Rate = 1
  • Streaming Image Resizing = ON
  • Streaming Resolution = 50%
  • Motion Optimization = ON

The image resizing allows the stream to use a lower resolution than the resolution set under “Video Device”. A low frame rate reduces the data-rate but still allows you to see what is going on in the scene.

> Still Images

  • Preserve Pictures “For One Month”

> Movies

  • Movie Format = H.264 (.mp4)
  • Preserve Movies “For One Week”

> Motion Detection

You will almost certainly need to experiment with these settings depending on where your camera is and what it can see :

  • Frame Change Threshold = 10%
  • Light Switch Detection = 75%
  • Motion Gap = 20
  • Captured Before = 5
  • Captured After = 5
  • Minimum Motion Frames = 10
  • Show Frame Changes = ON

Step 7 – Fixed IP Address (Optional)

To make it easier to find the web interface in the future I like to give my cameras a fixed IP address. The IP address can be specified in the Network settings :
MotionEyeOS Pi Zero W camera

Step 8 – Viewing Images and Movies

Now the camera is up and running you just need to sit back relax.

To view images and movies you can click on the camera image and use the icons that appear in the top right.

motionEyeOS Image and Movie Gallery Buttons

You will then be presented with a gallery that you can click on.

motionEyeOS Image Gallery

Timestamps are shown so you can see when the media was created. The gallery takes longer to load if there are more images. Play around with it and you will get a feel for how it works.

Final Thoughts

I am very impressed with motionEyeOS and it does almost everything I would expect. It’s easy to setup which allows more time to worry about mounting the camera. It is the main reason I decided to not continue creating my own software.

It is worth experimenting with the settings (resolution, motion detection percentages etc) to get the best performance for your location given the number of detection events you are likely to get on a day-to-day basis.

It’s worth looking at the motionEyeOS Wiki for details on the settings as well as other features that I haven’t covered here. The github page also has an “issues” section where you can research any problems you may experience. It may be worth asking questions in the Google Group unless you are sure you have found a genuine issue.

motionEyeOS Links

Here are some motionEyeOS links that are worth visiting for additional information :


All my motionEyeOS based projects are listed under the motionEyeOS tag.

Share.

8 Comments

  1. The wire hanging down is what ruins this. If you could add a solar cell at the front with a battery it would change this from an eyesore to a really useful bit of kit. Very few wives/girlfriends would allow you to get away with something to ugly.

    • This photo was taken of my test setup upstairs. It is stuck in the middle of the window and as you say the wire looks a bit messy. I am going to move it downstairs and stick on a conservatory window and route the wire along the window frame to make it a bit neater. In most home automation/security projects the technology is easy. Making it look nice and dealing with power cables is the hard bit!

      I might also have a go at 3D printing a back-shell for the ZeroView.

  2. Can this setup be used as a security camera? I mean if i can connect to the Raspberry Pi Zero W CCTV camera outside of my WiFi network (e.g. via cellphone, from abroad, etc.).

    • Yes! It has to have a network connection but with “port forwarding” setup on your router you can check the video feed from anywhere in the World.

  3. Thanks much for this tutorial. Nubie question tho: How does one shut down the RPI. Do you SSH in to the device, then type “shutdown” or something? If so, what would be the SSH password?

    Thanks!

  4. Matt- Do you continue to have success with motioneyesos using the RPI Zero W? Most times when I (re)boot my Zero W, it won’t connect to my router. The boot echo notices seems to hang for longer that expected on the “Configuring wireless network” step, then in the next step indicates failure to get the date via HTTP.

    If you’re still having success, can you confirm you are using the following motioneyes image file from github:

    motioneyeos-raspberrypi-20170329.img.gz

    I can’t see on the git page “Raspberry Pi 1” per your instructions above. So I’m assuming the image file without the “2” or “3” after “raspberrypi” is for the Zero.

    Thanks!

    • I’m currently using motionEye Version 0.35.2, 4.0.1+git37b3595, 20170329.

      I was getting a lot of reboots but that was with a 700mA power supply. I swapped for an official supply rated at 2.5A and that has been much better. The image for the Pi Zero W is indeed the “raspberry pi” version rather than the two others for the Pi 2 and 3.

Leave A Reply