How I built my Raspberry Pi 3 CCTV using a MotionEyeOS image for home surveillance
When I bought my Raspberry Pi 2, I also bought the first version of the Raspberry Camera Module just for the fun of it. After setting up my Raspberry Pi 2 as a TV box for my wife, that camera module became an ornament. Feeling bad about such wastage, I bought another Raspberry Pi 3 to utilise the camera module in performing home surveillance.
This post documents the steps that I took to build my Raspberry Pi 3 CCTV via a MotionEyeOS image for home surveillance.
Getting the hardware for my Raspberry Pi 3 CCTV
I used the following hardware to realise my Raspberry Pi 3 CCTV:
- A Raspberry Pi 3 motherboard
- A Raspberry Pi Camera Module
- A Raspberry Pi Model B+ Case Enclosure (Clear)
- A SanDisk Ultra 64 GB microSDXC Micro SD
Getting the MotionEyeOS image for my Raspberry Pi 3
After I got the hardware, I went on to download the MotionEyeOS image for my Raspberry Pi 3. Calin Crisan had created a page for us to download different releases of MotionEyeOS for different Single Board Computers. I chose motioneyeos-raspberrypi3-20160410.img.gz and saved it onto the file system of my Windows machine.
I then used 7-zip to extract the .img file from
motioneyeos-raspberrypi3-20160410.img.gz. Once the .img file was extracted, I used Win32 Disk Imager to write the .img file into the SanDisk microSD card via the SD card drive on my laptop
Booting into my MotionEyeOS on my Raspberry Pi 3 CCTV
After my Win32 Disk Imager completed writing the MotionEyeOS onto my microSD card, I inserted the microSD card into the microSD card slot on my Raspberry Pi 3 CCTV.
To have a glimpse of what will happen the first time my Raspberry Pi 3 CCTV boots up, I connected my Samsung monitor and my Logitech keyboard to it.
I also connected my Raspberry Pi 3 with my network cable so that I could configure it via a web browser.
Lastly, I connected my Raspberry Pi 3 CCTV to my Belkin micro USB cable which was in turned connected to my USB wall plug charger.
Key activities that MotionEyeOS did when it boots up for the first time
When my MotionEyeOS image booted up for the first time, it performed the following:
- Expanded the data partition to take the entire microSD card space
- Configured a default hostname
- Created a default password for the root user, which was empty
- Configured the network settings of the ethernet port of my Raspberry Pi 3 to request an IP address via DHCP
Among the initial configurations, my MotionEyeOS also started syslogd, the watchdog, brownout detector, eudev, http date updater, crond, sshd, proftpd. smbd, nmbd and motioneye.
The IP address that was allocated to my MotionEyeOS was also shown before the login prompt.
Accessing my camera video stream with my browser from within my home network
After my Raspberry Pi 3 CCTV had booted up successfully, I opened a browser from a computer that is connected to my home network and entered the IP address of the Raspberry Pi 3 CCTV in the location bar. With that, I was shown a window that showed a video stream from the camera on my Raspberry Pi 3 CCTV:
Ensuring that my Raspberry Pi 3 CCTV can only be accessed through my user account
It felt insecure to have my Raspberry Pi 3 CCTV showing the video stream from its camera without any login prompt. As such, I proceeded to set some passwords to guard accesses to my Raspberry Pi 3.
To apply access control to my Rasberry Pi 3 CCTV, I would need to login as the admin user.
To login as the admin user, I clicked on the second button at the top left corner. I was then shown the login screen:
At the login prompt, I entered admin as the username, left the password field blank and clicked on Login.
After that, the browser would show the video stream from my camera again.
I then clicked on the first button on the top left corner to get the following screen:
Setting a password for the admin user
In MotionEyeOS, the admin user is given the rights to configure MotionEyeOS.
The username of the admin user cannot be changed.
To set a password for the admin user, I entered a password in the Admin Username text field.
Creating the surveillance user
The surveillance user is only granted view access to the video stream from my Raspberry Pi 3 camera. Configuring a username and password for the surveillance user would ensure that the video stream from my Raspberry Pi 3 CCTV camera only displays after either the surveillance user or admin user logs in successfully.
To create a surveillance user, I entered a username in the Surveillance Username text field and a password in the Surveillance Password text field.
Applying password changes made to the admin user and the surveillance user
After I had keyed in the details for the admin and Surveillance users, I clicked on the Apply button on the top to persist the changes. With that, the following prompt appeared to get me to reboot my Raspberry Pi 3 CCTV:
I clicked Yes to make MotionEyeOS reboot itself.
After my Raspberry Pi 3 CCTV started up again, I was shown the login prompt.
I keyed in my admin user credentials to continue on with the rest of the configurations.
Changing the default timezone
Since I do not reside in a region that is part of the UTC timezone, the timestamp reflected on my video stream was incorrect. An inaccurate time display would create inconvenience when I wanted to verify whether the deliveryman from the postal service had really attempted to come to my house at the time that they claimed in their failed delivery sms message.
To change the default timezone to the one that my region followed, I clicked on the first button on the top left corner to open up the settings drawer. Inside the settings drawer, I located the General Settings section and clicked on the toggle button next to Advanced Settings. After doing so, I was able to change the Time Zone on my Raspberry Pi 3 CCTV:
To configure the Time Zone on my Raspberry Pi CCTV, I selected Asia/Singapore from the Time Zone dropbox and clicked the Apply button at the top of the screen to commit the changes. I clicked Yes when MotionEyeOS asked to reboot itself.
After my Raspberry Pi 3 CCTV started up again, I keyed in my admin user credentials to continue on with the other configurations.
Configuring wireless connection to my home network
Since Raspberry Pi 3 comes with wifi capability, configuring my CCTV to connect to my home network connection wirelessly would eliminate the need for another cable for network communications.
To configure wireless access, I first clicked on the first button at the top left corner to bring out the configurations drawer.
After that, I clicked on the Network tab to expand the network settings section:
I then clicked on the toggle button for Wireless Network to turn on wireless network connections. This would make the Wireless Network Name and Wireless Network Key text fields appear for me to key in my home wireless network details.
Once I was done with my Wireless Network configurations, I clicked the Apply button and rebooted my Raspberry Pi 3 CCTV.
When my Raspberry Pi 3 CCTV started up, I keyed in my admin user credentials to continue on with the other configurations.
To get the IP address that my Raspberry Pi 3 had gotten for its wifi interface, I connected my monitor to it and looked for the status output that looked like the following:
Interface wlan0 has IP address 192.168.0.107/24
In this case, I would enter 192.168.0.107 in the location bar of my browser from a computer that is connected to my home network so as to connect to my Raspberry Pi 3 CCTV via its wifi interface.
Turning off the camera LED indicator
Seeing the video stream would be sufficient for me to determine that the camera is working. As such, I went on to turn off the camera LED indicator so that I can reduce the power consumption of my Raspberry Pi 3 CCTV.
To do so, I first clicked on the first button on the top left of the screen to bring out the configurations drawer.
I then looked for the Expert Settings tab and clicked on it to expand the expert settings section:
To turn off the LED indicator of the camera, I clicked on the toggle button for Enable CSI Camera Led to switch it off.
I then click on the Apply button at the top and rebooted my Raspberry Pi 3 CCTV.
After my Raspberry Pi 3 CCTV booted up again, I keyed in the admin user credentials to continue with the other configurations.
Limiting the preservation of still images and movies
By default, MotionEyeOS keeps pictures and movies for as long as it can. However, I figured out that I would only require the still images and movies be kept for one month.
As such, I went on to configure my Raspberry Pi 3 CCTV to keep pictures and movies for a maximum of 1 month.
To configure the preservation period of pictures and movies, I first clicked on the first button on the top left of the screen to bring out the configurations drawer.
I then clicked on the Still Images and Movies tabs to expand both configuration sections:
I then chose the For One Month option for Preserve Pictures and Preserve Movies and clicked Ok on the prompts that appeared.
Once I was done with that, I clicked on the Apply button at the top to persist the configurations and rebooted my Raspberry Pi 3 CCTV.
With that, I was satisfied with the configurations that I wanted for my Raspberry Pi 3 CCTV.
Enabling access from the internet
At this point, I would have a CCTV that does home surveillance for me.
Whenever there are movements in the area where my CCTV points to, my Raspberry Pi 3 CCTV will save a video recording onto its file system. When needed, I would be able to access 192.168.0.107 from the browser of a computer that is connected to my home network to view the video recordings.
However, to be able to view the video stream of my Raspberry Pi 3 CCTV wherever I go, I would need to enable access to my CCTV from the internet. Since I do not power off my Internet modem and router, the public IP address that my home router got from my Internet Service Provider would remain unchanged. Hence, with some configurations at my home router, I would be able to access my Raspberry Pi 3 CCTV at anytime, from anywhere.
By default, my Raspberry Pi 3 CCTV utilises port 80 to display the dashboard and video streaming. Hence, to enable access to my Raspberry Pi 3 CCTV via my public IP address, I logged into my router to add a Network Address Translation entries to map the port 80 of my public IP address to port 80 of 192.168.0.107.
Once that was done, I could then use my public IP address to access my Raspberry Pi 3 CCTV from any device that is connected to the Internet.
Buying your Raspberry Pi 3 CCTV camera from Amazon
If you do not have the Raspberry Pi 3 components mentioned in this post yet, you may want to purchase them from Amazon. Simply click on the button below to add the Raspberry Pi 3 components to your cart. You may remove anything that you already have or replace some of the components with other components.