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.
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.
Recommended
- Raspberry Pi ( Amazon )
- Raspberry Pi Camera ( Amazon ) or USB WebCam ( Amazon )
- Power Supply ( Amazon )
- Micro SD Card ( Amazon )
- Ethernet Cable ( Amazon ) (Recommended) or Wi-Fi ( Amazon )
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.
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.
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“.
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.
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.
Configuring the Settings in MotionEye
You can configure a vast range of settings within MotionEye. I will briefly go through them in this section.
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.
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.
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).
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.
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.
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.
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 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.
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.
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.
I have now tried two computers to follow these steps and am getting the same error on both machines when trying to install Win32 Disk Imager (“Unable to execute file: C:\Program Files (x86)\ImageWriter\Win32DiskImager.exe CreateProcess failed; code 740. The requested operation requires elevation.”). Anyone seen this before? Any suggestions to get around it or another tool that would do the same task? Thanks!
Hey Matt! It should of installed however there is a weird bug when when it tries to launch the program.
To launch it correctly find and locate “win32diskimager” (It should have installed to -> C:\Program Files (x86)\ImageWriter) and right click on and then press “Run as administrator”
Gus, I have not made it all the way through all the steps yet, but that did seem to work for the error I was getting. Many thanks!!
Matt
Where do i go to acesss the files being recorded? Or is that in the interface, in which case why isn’t it saving the stream?
Can’t seem to make the pi connect wireless with this even when editing the settting, and when i goto my router page it says “unknown device” instead of the Mp setup.
I used the most recent image for the RPi2 from the github repos and tried to follow the dynamic dns guide that you linked to. None of the commands shown in the example function with whatever os is being used on the motion pie image. I’m not sure where to install noip to and sudo is not supported by the os…
Any help is appreciated.
Sounds like good suggestions Casper.
Hi Gus,
Great project, nice and friendly interface. Got it working in now time, (using pi-filler on a mac to copy the image).
I have two suggestions (sorry, it’s never enough):
– a test button for email settings
– ftp file storage
However, great and thanx.
Excellent work Gus!
Couldn’t get over how easy this was to install and get going.
This will suit my need for a weather webcam project I am currently working on.
Thank you very much for the effort you put into this.
I am using straight cable to connect my laptop to raspberry pi.
But, I can not access to raspberry pi from my laptop. How to do it?
I tried to setup the Raspberry Pi’s ip address in cmdline.txt such as:
ip=192.168.137.2::192.168.137.1
I could not get the IP address or hostname of Raspberry Pi.
When you say “straight cable” are you referring to a network cable or something USB?
You can enable ssh on the pi and use Putty (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html) to ssh from a PC over a network. From a Mac you can ssh from the terminal.
You can also install VNC to remote desktop into the Pi. I installed Tight VNC on the Pi and VNC Viewer on the Mac. I think Windows Remote Desktop, installed with Windows, can be used too.
Hey, you can use the camera with external battery? when it detects motion to start recording.
I want to buy Arlo cameras, battery operated, but their autonomy are 4-6 months active and recording only when motion is detected.
It is possible to do this with Raspberry?
Greetings!
I could use some help please. I got it all up and running with 2 cameras. Cool. Now I want to save video and stills, but on to a USB flash drive. I’ve never found a good way to auto-mount a flash drive, so I usually just ‘apt-get install usbmount’, but there is no apt-get on MotionPi. How do I go about installing it? Thanks.
hiya, when you say with two cameras, are both cameras running of the one pi? for example two usb camera’s?
thanks
Allen
Hi Allen,
Yes this is correct!
I also tried this with the Raspberry Pi camera + USB camera.
awesome thanks Gus. any posibility of getting sound?
see the PS3 EYE TOY i used has a mic on it, or so do some webcams. but it would just be a nice to have.
another question i have is, after a long day of taking timelapse photo’s the software wont do a zip or timelapse vid. have you had this befor? anyway thanks for the software its awesome, i have now passed it on to my peeps all over, south africa, canada, and more. cheers
sorry another question, If i leave the survailince log in empty, can you still use the software. Ie if i post the link then it auto loads the camera no log in screen. thanks
Hi guys,
I bought a raspberry pi yesterday. Its my my first time using the pi.
I followed all the procedures mentioned above. I formatted the micro SD and installed the image file to the SD using DiskImager. Then i inserted power cable, Ethernet cable and SD card in the pi and powered it up. But i was unable the find the raspberry Pi on my network.
So alternatively I went to my router settings and found the Pi name and IP address. I tried to used this IP address to access the Cam but it says “Webpage not available”.
make sure that if it is a raspberry pi 2, you use the raspberry pi 2 image not just a raspberry pi image
Thanks john p
The problem was resolved. Another problem i’m facing is im unable to SSH using putty. When i enter the password for the R Pi it says wrong password and access denied. But the R Pi has got its default login credentials.
Please shoot in some help ! 🙂
The password is the last digits of the name given to your camera. In the above example, the camera is called mp-40489697
Therefore the password is 40489697
Hi fellow coders,
I followed the steps to write the program correctly. But for some reason the Pi is not appearing in the network section of computer. As a result, im unable to access it. Let me know if there,s a solution. Thanks 🙂
Gus, I had a mental lapse. I was thinking the file had to be an iso. WRONG. I Extracted the image, formatted the SD card, wrote the image with WinDisk32. Voila!!!!! Booted up, works as advertised. I hope I did not waste your time. Thanks.
Gus, I really like the project idea, however, I am unable to extract the pi2 motionpie.img.gz file correctly. The file extracts with an .img extension, but the Windows 7 disc image burner says the image file is invalid and will not create the iso file. What am I doing incorrectly? I have made many Raspbian cards and other op sys cards for the pi. This one has me stumped. Thanks for any help.
I am having the same issue.
Hi Gus,
great Job, i’m searching such an image for a long time.
easy to use, thank you.
Thanks again for this great project. I was able to get everything running in just a short time. Can you shed some light on Fast Network Camera? I had everything working with three cameras and I went to the advanced setup and changed the camera configuration to Fast Network Camera and lost all of my camera feeds. Not know what to do I switched back and all is well. Can you maybe refer me to some additional help on this issue?
Thanks again,
Danny
Hey Danny,
Sorry to hear you’re having problems, here is an article (MotionPie Fast Network Camera) on Fast Network Camera as well as some troubleshooting! Hopefully this helps you out!
how to configure network camera or ip camera to rpi3 …error in URL…..
Hi,
it is possible to continuously record video on a file for example one per day and disable after certain hours (working schedule) ?
Thanks
Will this work if using remote desktop?
I have it all working but image quality is not good and the its VERY slow. Im not sure what settings to look at. im using a generic USB camera. I upped the frame rate to 15. resolution 680. Im using a wifi dongle (could that cause the latency?). Can you not connect more that one usb camera? It allows me to add a second but the image does not show, this could be the camera, i cant get it to show an image by itself. The interface takes forever (couple mins) to load. The camera constantly cuts out (the camera with a cross through sign). It was super easy to setup but im having a hard time using in practically. im a noob. raspberry pi B. Can i have it email me still images when i senses movement?
Thanking you for the nice sw, I tried to install it and all is working perfectly on my local network, but for me it was impossible to use a dyn DNS with noIP because, you need to install the client portion iof noIP on raspberry ..but, before to do it, you need to compile it…. at this point you do not have nor a make tool, nor a compiler gcc, not only but I was not able to get it: it is missing also the apt-get tool!!!. I’m new on Rpi… I’m sure I miss something, so please a little help for me… thank you very much. nick57
Good morning. Your camera system looks fantastic. I have just tried to ssh into the pi to change some network settings. The default pi – raspberry username-password seems to have been disabled, could you tell me how I now log into the pi using ssh ?
Default password for motion pie is the serial number of your pi. For example, motion pie mp-8181d18g has a default admin account with 8181d18g as the password. If you’ve changed the admin password via the web interface, then that overrides the default and so you use that.
Cheers
Jon
Hi Jon,
Thanks for your response. I can now ssh in, but I can’t sudo or su – these seem to have been disabled and /etc/fstab can only be editted by su…
Cheers
James
So what is the login: ????
admin or pi? I understand the password is the serial number.
Hi Jon, This looks very interesting but I can not use it at all because of how locked up everything is. Since we don’t have a root password and we cant sudo anything then we can even change the setting for the wireless network. Could you please respond back with the password you used for root. Thank Steven
Hi can you help?
If i switch it on in give me a login mere-22c7bd0!
What is the login and password I want it on wifi?
Hi I’ve been trying to log on to the system but i only get “login incorrect “. Do you know what I’m doing wrong?
What’s the username?
Hello, so I’m not sure about your problems, but I had trouble with ssh until I found out the username was admin and leave the password field empty. If you change the admin name or password via the web interface then the ssh name or password will likewise change.
user is Admin, leave pwd blank
Can i use a mobile device as a camera? if so how to do it?
Hi had the motion pie working I ve had to reinstall motion on the sd card it’s not showing up in my router how can I login
Hi,
I installed motion Pi on my Raspberry PI 3 but when I put the IP address of the PI into my browser nothing works? Please help 🙂
Please help, you lost me at step 3. To login as the admin go to key symbol in the upper left corner. The username is admin and the password is blank, this can be changed later.
I have the ip address of my Raspberry pi 3 it’s
http://192.168.1.70/
I got the ip from my router.I entered the ip in my web browser and it just times out.
I booted up my Pi and after about 10 min? the screen went black I assumed it was a screen saver???? but after messing with the keyboard and mouse and nothing happening I pulled the power cord on the Pi3 so it would reboot, it boots back up to a
“Welcome to meye-dead8c9!
meye-dead8c9 login: ”
What is the login and trying to log in on the Pi3 screen do anything?
Any screen shots or instruction videos of the setup?
Thanks.