How to setup a Raspberry Pi security camera for home surveillance with Raspbian Buster Lite and motionEye

Even though a Raspberry Pi security camera is not the cheapest surveillance camera, it can be worthwhile building one.

Especially for Raspberry Pi fans, you may have several unused Raspberry Pis because you buy one for each release. In such a case, a big part of your Raspberry Pi security camera is sunken cost.

Given that, let's look at how we can setup a Raspberry Pi security camera with Raspbian Buster Lite and motionEye.

Why use Raspbian Buster Lite + motionEye instead of motionEyeOS?

First of all, Raspbian Buster Lite does not come with a windowing system that we do not need for a security camera. Therefore, we won't be wasting too much of the Raspberry Pi computing resources. In addition to that, we can put other software on the same box when we choose the Raspbian Buster Lite + motionEye combination for our Raspberry Pi camera.

Steps to setup a Raspberry Pi security camera with Raspbian Buster Lite and motionEye

Before we dive into the details, let's take a look at the steps to setup a Raspberry Pi security camera:

  1. Gather the hardware parts for your Raspberry Pi security camera.
  2. Install Raspbian Buster Lite on your Raspberry Pi.
  3. Assemble the hardware parts for your Raspberry Pi security camera.
  4. Enable the camera interface for your Raspberry Pi security camera.
  5. Install motionEye and dependencies on Raspbian Buster Lite.
  6. Configure motionEye settings on your Raspberry Pi security camera.

1. Gathering the hardware parts for your Raspberry Pi security camera

In case you need it, here are some hardware combinations that you can procure for your Raspberry Pi security camera.

Parts to build a Raspberry Pi Zero W security camera

Parts to build a Raspberry Pi 3B+ security camera

Parts to install Raspbian Buster Lite onto the microSD card

2. Installing Raspbian Buster Lite on your Raspberry Pi

After you have gathered the hardware to build your Raspberry Pi security camera, setup Raspbian Buster Lite on your Raspberry Pi.

Once you have done so, you should be able to get into your Raspbian Buster Lite with a terminal program running ssh. Given that, shutdown your Raspberry Pi with the following command:

sudo shutdown now

3. Assembling your Raspberry Pi security camera

After your Raspberry Pi powers down, proceed to assemble your Raspberry Pi security camera.

For Raspberry Pi Zero W security camera

Connect Raspberry Pi camera module to Raspberry Pi Zero W and the official case.

For Raspberry Pi 3B+ security camera

Connect the Raspberry Pi Camera Module to Raspberry Pi 3B+ and put it into the case.

When you have done so, your Raspberry Pi security camera should look like the following:
Raspberry Pi Zero W and Raspberry Pi 2 3 camera with mobile phone clips

4. Enabling the camera interface for your Raspberry Pi security camera

After you had assembled your Raspberry Pi security camera, turn it on again.

When Raspbian Buster Lite had started, use ssh from a computer shell terminal to configure it again.

Since the camera interface is disabled on Raspbian Buster Lite by default, we need to enable the camera interface.

In order to do so, proceed to enable the camera interface on Raspbian Lite.

5. Installing motionEye and dependencies on Raspbian Buster Lite

After you had enabled the camera interface, go through the following steps to install motionEye and other dependencies on your Raspbian Buster Lite:

  1. Become root:
    sudo -i
    
  2. Update Raspbian:
    apt-get update
    
  3. Install ffmpeg and other motion dependencies:
    apt-get install ffmpeg libmariadb3 libpq5 libmicrohttpd12 -y
    
  4. Setup motion:
     wget https://github.com/Motion-Project/motion/releases/download/release-4.2.2/pi_buster_motion_4.2.2-1_armhf.deb
     dpkg -i pi_buster_motion_4.2.2-1_armhf.deb
    
  5. Install Python Pillow:
    apt-get install python-pillow -y
    
  6. Setup the dependencies from the repositories:
     
    apt-get install python-pip python-dev libssl-dev libcurl4-openssl-dev libjpeg-dev libz-dev -y
    
  7. Install motionEye:
    pip install motioneye
    
  8. Prepare the configuration directory:
    mkdir -p /etc/motioneye
    cp /usr/local/share/motioneye/extra/motioneye.conf.sample /etc/motioneye/motioneye.conf
    
  9. Create the media directory:
    mkdir -p /var/lib/motioneye
    
  10. Add an init script, configure it to run at startup and start the motionEye server:
    cp /usr/local/share/motioneye/extra/motioneye.systemd-unit-local /etc/systemd/system/motioneye.service
    systemctl daemon-reload
    systemctl enable motioneye
    systemctl start motioneye
    

6. Configuring motionEye on your Raspberry Pi security camera

At this point in time, you are ready to access the motionEye web portal to configure your Raspberry Pi security camera.

Given that, enter the IP address of your Raspberry Pi security camera, with port 8765, into the location bar of your browser.

For example, if the IP address of your camera is 192.168.1.107, you will enter 192.168.1.107:8765 into the location bar of your browser. When you do so, you should be greeted with the login screen:
motioneye-0.42 login screen

Given that, enter admin for the username field and leave the password field blank.

Adding a camera for your Raspberry Pi security camera

After you had logged into the web portal, motionEye will prompt you to add a camera:
motioneye-0.42 prompt for adding a camera

Therefore, click on the link to add your camera. When you do so, motionEye will show you a dialog to add a locally attached camera.
motioneye-0.42 dialog for adding a locally attached camera

Given that, choose mmal service 16.1 as the camera:
motioneye-0.42 dialog with mmal service 16.1 selected as the camera option

Next, click OK and you will see a video feed from your Raspberry Pi security camera:
motioneye-0.42 with Camera1 configuration drawer and video feed

If you do not see mmal service 16.1 as an option, then you need to check if you have enabled the camera interface.

Changing the login credentials for the admin user and surveillance user

In addition to the admin user, there is a surveillance user as well. While the admin user can configure every setting on your security camera, the surveillance user can only view the video feed.

Another point to note is that we can create a custom username for the surveillance user but we cannot change the username for admin.

Since it is insecure to use the default credentials, change the login credentials for both users through the form at the General Settings section:
motioneye-0.42 with user credentials section highlighted

After you have entered the new credentials, click Apply to apply the changes. When you do so, you will be prompted to login with the new credentials.

Changing video resolution of video feed

If you wish to increase the video resolution of your video feed, then you can do so via the Video Device section:
motioneye-0.42 with video resolution section highlighted

After you select your ideal video resolution, click on Apply to apply the changes. When you do so, you should see the video feed in the new resolution.

Enabling recording of still images and movies

If you wish to record your video feed, then you will want to enable recording of still images and movies:
motioneye-0.42 with Still images and Movies section highlighted

As shown above, you can also decide the mode of capture, preservation periods and other relevant configurations.

Configuring motionEye to only capture video if there are movements in particular sections of the surveillance area

When you only want motion detection to trigger if parts of the video feed changes, you can check out the Motion Detection section. Given that, this is how to configure motionEye to only capture video if there are movements in particular sections of the surveillance area.

About Clivant

Clivant a.k.a Chai Heng enjoys composing software and building systems to serve people. He owns techcoil.com and hopes that whatever he had written and built so far had benefited people. All views expressed belongs to him and are not representative of the company that he works/worked for.