Raspberry Pi Security Camera Network using motionEye

In this project, I will set up a Raspberry Pi security camera network using the motionEye software. You can use the standard Pi camera, such as the one I used in the time-lapse tutorial.

Raspberry Pi Security Camera

This project is a cost-effective way of getting a security camera network up and running. You can view the cameras over the network and have them record based on motion.

Remember, the Raspberry Pi isn’t a powerhouse, so performance will degrade if you try to do too much, such as adding too many high-definition cameras.

This tutorial previously used MotionEye OS, but as it is no longer maintained, we have updated it to use the underlying MotionEye software on the default Raspberry Pi OS.

If you want to use the Raspberry Pi camera, follow our webcam guide before starting this tutorial. The process is relatively simple but does require a bit of tweaking.

Other security camera software that is compatible with the Raspberry Pi and worth looking at is Frigate or ZoneMinder,

With all that said, motionEye still an excellent way of building an affordable camera network. So, let’s get to it.

Equipment

You will need the following equipment to complete this Raspberry Pi security camera project.

Optional

  • Raspberry Pi Case ( Amazon )

This tutorial was last tested on the Raspberry Pi 5, running the latest version of Raspberry Pi OS Bookworm.

Installing MotionEye on the Raspberry Pi

For this tutorial, we will be installing motionEye on Raspberry Pi OS. I settled on using MotionEye as it is an all-in-one solution that fits my requirements, and it also didn’t involve as much fiddling around to get it to work.

It is best to install this software on a clean version of the Raspberry Pi OS. If you are installing on an existing operating system, you may run into conflicts with other software.

1. First, update the packages on the Raspberry Pi to the latest version by running the following commands.

sudo apt update
sudo apt upgrade

2. First, we must install the required packages for the motionEye software to work. Enter the following command to install the packages.

sudo apt --no-install-recommends install ca-certificates curl python3 python3-dev libcurl4-openssl-dev gcc libssl-dev

3. The Python package manager pip software should already be installed. You can check if pip is installed by entering the following command.

pip --version

If pip is installed, you should get a response like the one below.

pi@gusdevpi:~ $ pip --version
pip 23.0.1 from /usr/lib/python3/dist-packages/pip (python 3.11)

If pip is not installed, you will see an error message. To install pip, run the command below.

sudo apt install python3-pip -y

4. Due to the requirements of MotionEye, you will need to update the settings to allow Python packages to be installed outside a virtual environment when using pip. You can read more about the pip external environment changes.

The command below will allow these packages to be installed without encountering the “Externally Managed Environment” error. Also, the command below will make the change systemwide as motionEye requires it.

sudo python3 -m pip config set global.break-system-packages true

5. Prepare MotionEye for installation by running the following Python command.

sudo python3 -m pip install --pre motioneye

You will see warnings about not using a virtual environment. You can safely ignore these warnings. If you see an error about mismatching hashes, run sudo apt update and sudo apt upgrade and try running the command again.

6. The installation process will take a while.

Once done, enter the following command to install and start MotionEye.

sudo motioneye_init

7. You can now check to see if motionEye successfully started by running the following command.

systemctl status motioneye

You should see some output indicating the service is active and running without errors.

8. Now get the IP of the Raspberry Pi so you can access the web interface of motionEye. To do this, use the hostname command.

hostname -I

Configuring MotionEye on the Raspberry Pi

Now we are ready to configure the software and connect to our cameras. We will need to communicate to the Raspberry Pi over the network rather than directly as I have done in most of the previous tutorials.

Logging into motionEye

1. First, we will need the IP of the Raspberry Pi. Once you have the IP, enter it into your favorite web browser. You will need to use the port 8765.

For example, I access my instance using the following IP.

http://192.168.0.16:8765/

2. You should be greeted with a login page. The username is admin, and the password is blank. The password should be updated once you have logged into the admin.

motionEye Login Page

3. Once logged in, you can access all the settings for the camera streams. If you want to alter these settings, keep reading, and I will explain them as much as possible below. Now, we should have a working security hub that we can configure.

How to Set Up Multiple Network Security Cameras

In this section, we go through how to set up multiple cameras within motionEye. You can view all the camera feeds within a single web interface.

You can even add a stream that has been set up using the Raspberry Pi Webcam server tutorial.

1. First, click on the three vertical lines in the upper left-hand corner.

2. Under the general settings tab, you can update the password to something more secure. Once you update the password, you will need to log in again with the new details.

Update Password in motionEye

3. Click the three lines in the top left-hand corner of the screen to open the settings.

Next, in the top left-hand corner, click the drop-down box and select “add camera“.

Add Camera to motionEye

4. In the pop-up, you have five settings to configure.

  • Camera Type: This allows you to select the camera type you wish to connect.
  • URL: This is the URL to the other network camera. E.g. http://othercamera:8080
  • Username: This is the username of the camera device. If no username/password is required, then leave the fields blank.
  • Password: This is the password for the username chosen above.
  • Camera: Select the camera you wish to add.

Below is an example of adding a Reolink network camera with RTSP enabled.

motionEye Add Camera Settings pop-up

In the example below, camera1 (Pi Camera) and camera2 (USB WebCam) are connected to the Raspberry Pi running MotionEye. At the same time, camera3 comes from a different Raspberry Pi set up using our webcam server tutorial.

This method is great for setting up a strong Raspberry Pi security camera network.

Raspberry Pi Multiple Cameras

Configuring the Settings in MotionEye

You can configure a vast range of settings within MotionEye. I will briefly go through them in this section.

Raspberry Pi motionEye Interface

General Settings

You can set the administrator username and password in the general settings tab. This account will have access to all the settings you see at the moment.

A surveillance username and password can be set in here. This can be used to access the camera interface.

Video Device

Under this menu, you are able to set certain settings regarding the cameras.

  • Camera Name: Set this to whatever you want the camera to be named. For example, the name kitchen would work well for a camera in a kitchen.
  • Camera Device: You’re unable to edit this one, but this is the device name of the camera.
  • Automatic Brightness: This will enable automatic software brightness, which means the software will adjust for the brightness. You do not need to activate this if your camera already handles it. In here, you change the brightness, contrast, and saturation of the camera’s video.
  • Video Resolution: Here, you can set the camera’s video resolution. The higher the resolution, the more room it will take up and the more bandwidth it will need to use to stream the footage. I set mine to 1280×800, and that seems to work perfectly fine.
  • Video Rotation: You can rotate your video if it faces the wrong way.
  • Frame Rate: This sets the number of frames that will be sent every second. The higher this is, the smoother the video, but again, this will increase the storage and bandwidth used.
Video Device Settings

File Storage

Under this menu, you can specify where you would like the files stored for the Raspberry Pi security camera network.

This location can be a custom path on the Pi, the predetermined path, or the network path.

File Storage Settings

Text Overlay

Within the text overlay tab, you can set the text overlay on the camera’s output.

By default, the left text displays the camera name, and the right text displays the time stamp (Today’s date and current time).

Text Overlay

Video Streaming

In this menu, you can set the video streaming options. This is the video stream you see in the browser.

  • Streaming Frame Rate: This is the same as mentioned above under video device.
  • Streaming Quality: This setting is good to reduce if you need to access the camera on a low bandwidth device often.
  • Streaming Image Resizing: Enable this if you want MotionEye to resize the images before sending them to a browser.
  • Streaming Port: This is the port that the device will listen to for connections looking to view the stream. Eg. http://192.168.0.16:8081
  • Authentication mode
  • Motion Optimization: This will reduce the frame rate whenever no motion is detected. This setting will save you bandwidth.

You can also see three URLs that can be used to access different footage.

These URLs are very important if you have multiple cameras per Pi as each camera will have a unique port that you listen to the stream.

Video Streaming Settings

Still Images

In this tab, you can set the Raspberry Pi security camera network to take still images whenever motion is triggered, during specific intervals, or all the time.

Still Images Settings

Movies

Within this section, you can set the software to record movies whenever motion is detected. There are several settings you can change, such as the movie quality, file name, and more.

Movie Settings

Motion Detection

In here, you can activate the security camera motion detection that is included in the software.

You can make adjustments to the settings here to get better motion detection.

Motion Detection Settings

Motion Notifications

You can set up email notifications, webhook notifications, or even run a command whenever motion is detected.

This option will notify you whenever activity is detected on the cameras, perfect if they are monitoring areas with low traffic.

Motion Notification Settings

Working Schedule

Here, you can set the days and the hours of operation you would like the system to be monitoring (If you leave this off, then it is 24/7).

This option is perfect if you only need it running during specific hours.

Working Schedule Settings

Connecting to the Surveillance Outside Your Network

Now that you have your Raspberry Pi security cameras set up it might be worth considering allowing access to the central Pi so you can monitor your cameras elsewhere.

To do this, head over to our guide on how to set up port forwarding and dynamic DNS. You can find the guide at Raspberry Pi Dynamic DNS & Port Forwarding.

You will need some important information to set up the port forwarding.

  • The IP of your Raspberry Pi. For example, mine is 192.168.0.16
  • The internal port is 8765.

Ensure you also have set up passwords on both the admin and the surveillance user to help avoid unwanted visitors.

Once set up, you should now be able to connect using your external IP address such as XXX.XXX.XXX.XXX:8765.

Summary

The Raspberry Pi security camera system is a great way to have multiple cameras hooked up locally and over a network.

All the extra settings MotionEye provides allow you to have a strong functioning security hub for your home, office, or wherever you are setting this up.

I hope this tutorial has helped you in creating a fantastic Raspberry Pi security camera network.

If you have had any problems, want to provide feedback, or have a great setup you would like to share, please feel free to comment below.

If you’re after more great Raspberry Pi projects, check out many other great tutorials.

Leave a Reply

Your email address will not be published. Required fields are marked *

184 Comments

  1. Avatar for Nick
    Nick on

    I had my system set up and running perfectly fine and one day I went to set it up for wireless network and it no longer connects. I cannot see it in my router config and I copied the SSID and PW directly from the router. Any thoughts?

  2. Avatar for Jake
    Jake on

    The problem with using motionEyeOS (now new name, check github) is that the software ‘motion’ is CPU intensive, and does NOT use the RPi’s GPU to offset the video work. You will NOT get more than 2-3 fps due to the bottleneck. Quality will be low, and delay will be ~30seconds on motion.

    It works great on a powerful cpu, but it just isn’t viable as a solution IMHO. The performance is terrible on an RPi

  3. Avatar for Prakash
    Prakash on

    hi…

    Raspberry is new to me.I have some experience with Microcontroller.

    Recently i purchased the raspberry Pi 2.I also purchased reloaded Noobs SD card from Amazon.I did the initial boot.Now as per the above article, i need to format the SD card and then load the MotionPie. But, if I format the SD card and only load MotionPie, how the Raspberry Pi will boot without OS in SD Card? Correct me if i am wrong or I should load both Noobs and MotionPie into SD card? Please let me know….

    1. Avatar for Gus
      Gus on
      Editor

      MotionPie is already pre-packed with an operating system so you don’t need to worry about installing NOOBS/Raspbian.

  4. Avatar for Manuel
    Manuel on

    I want to contratulate you for your wonderful tutorial. I am starting with raspberry and after checking many tutorials yours makes the difference. Thanks again

    Best regards

    Manuel

    1. Avatar for Feri
      Feri on

      Hi! Seems to be good, but i have loaded the version for raspberry2 (i have raspi B+) – this show me the clor table only, then the version for raspberry (motionpie-raspberrypi-20150719.img.gz), this is running until: “eth0: starting dhclient” then waiting approx 1 minute and does reboot!
      How to get it to work please?

  5. Avatar for Miao Sun
    Miao Sun on

    Not able to ssh to my mention pie, have the ssh server service enabled, tried both the serial number and the password I set in the mention pie web interface, and the original pi pass, all of them give the result of “Permission denied”. Please help!

  6. Avatar for pierson
    pierson on

    Hi Gus,
    While adjusting the settings on my PI for the camera, It somehow triggered an infinite reboot loop..
    Any idea what setting could have triggered this?

  7. Avatar for Kirk
    Kirk on

    Is there a way to set the display default to the 7 in touch display? I’ve got it up and running, but have to connect it through the HDMI port.

  8. Avatar for sim367sim
    sim367sim on

    I followed your instructions and setup usb cam-creative HD cam. It works fine, but when motion is detected it stopped working. what should I do? need some help.

  9. Avatar for Blablas
    Blablas on

    Would it be possible to do this with the Raspberry pi zero ?

  10. Avatar for Ben
    Ben on

    Awesome build!
    Thanks for a top project.
    Question: Is it possible to use FTP on the Raspberry Pi to push stills or video to a secured FTP server on the internet.
    The aim of this is to remove the need to open ports on the router.

  11. Avatar for Kennet
    Kennet on

    Hi

    Great program!!

    When I push the Snapshot/Record button on the Window with the camera I get an “error”. Pictures taken my “camera” – (no media files), and nothing is saved.
    Tried to change storage folder from NAS to SD card, but it’s still the same.

    Kennet

  12. Avatar for Jared
    Jared on

    Can you use multiple IP cameras on the PI set up through a LAN?

  13. Avatar for Jelle
    Jelle on

    I can do the initial setup, add the wireless ID and password, but somehow the configuration is not saved/stored. So when I disconnect and reboot, it defaults to wired internet connection and all settings are gone. Do i miss something?

  14. Avatar for Daniel de Colli
    Daniel de Colli on

    Great project! There seems to be a support for Easy cap EM2860 and the pi seems to recognize it as a “V4L2 Camera”. Unfortunately I just get a black screen in the motionPie interface (connected through web browser). I´m using the version 20150719 of motionPie. Any suggestions?

  15. Avatar for Gerald
    Gerald on

    Using Fast Network Camera mode and tried to use “Authentication mode = Basic” under Video Streaming. After “apply” I can’t see any streams and it is not possible to connect to 8081.
    Any hints? Thanks

  16. Avatar for Paul Cook
    Paul Cook on

    Could someone pls help me? I have had motion pie working but now if i use the following browser these things happen:
    Internet explorer……I get some kind of file E9NF01XV downloading from 192.168.1.9 (rasp ip address)
    Firefox…… I just get the live stream of the camera image but I have no buttons to access the web ui.
    Please help me find access to my web ui settings again.
    Thanks

  17. Avatar for Victor Ramamoorthy
    Victor Ramamoorthy on

    I am using Pi 2 and corresponding motion pie for 2. The file system is locked and I can not install any new packages for no-ip or modify any files. How do I get around this problem? I am limited to only my local wifi network!!

    Help!

  18. Avatar for Victor Ramamoorthy
    Victor Ramamoorthy on

    I could get the motionpie project working in half an hour, thanks to your description. I find that two problems in setting the camera outside the local area network:

    1.The system is locked for writing. “mount -o remount,rw” does not do anything.

    2. I can not make IP address static to enable access from outside my wifi network (through internet). It seems that wpa_config files are not used. Also the usual /etc/network is missing. Perhaps it can be done only through motionpie web interface and not through programming.
    3. The last line in the /boot/config.txt is supposed to turn off the camera LED, but does not do it
    4.Also “sudo” does not work. Changing the config.txt with nano seems to be not possible.

    Please help.

    Thanks

    1. Avatar for Jaasiel
      Jaasiel on

      Victor,
      I have the same problem. Would really like to disable the LED.
      -Jaasiel

  19. Avatar for Jon
    Jon on

    I am new to the Pi and I installed the image and everything works fine. I logged into the system using the admin and password. When I access my router it recognizes the Pi but says that it is not connected to the wireless. How do I connect my Pi to the wireless setting using my computer? Or do I have to use the command line on the Pi? and how do I do that?

    Thanks

  20. Avatar for romanus
    romanus on

    Hi! i really like this project. Is there an option for sending the picture with the notification email as attachement, when motion is detected? That would be a very nice feature and extend the use of this project even more. Also sending files to an ftp server could also be useful.

    Thanks