Using a Raspberry Pi and MotionEyeOS To Create a Home Security Camera

A few years ago, I had the desire to create a home security system. I at least wanted the ability to be notified when someone arrived at my house, and an image of them would be even better. I wasn’t as into Arduino and other microprocessors back then as I am now, however, I did like to tinker with Raspberry Pi’s.

So of course, I had an extra laying around. I started to see if anyone else had done something similar before. That was when I discovered MotionEyeOS. It is a lean Linux distribution designed for small computers like the Raspberry Pi. It is a very well made system, and I have been using it with few, although there have been some, errors for years.

In this project, I used all these parts:

The reason I’m using two Raspberry Pi’s is because I wanted to store the photos long-term on my own HDD. My HDD is being used, however, to house my media on another Raspberry Pi that is running LibreELEC as a media center. I’ll have another post about that, soon. This isn’t an issue for me, however. LibreELEC supports mounting the HDD on the network as a SAMBA share, and MotionEye supports saving images to SAMBA shares. If you wanted to only use one RPi and a USB Flash Drive that would work fine, too.

 

Here are some photos that show system and its functionality:

Encased with a 3D printed case, with the Xbox WebCam cord visible on top
Raspberry Pi with NoIR Camera mounted onto it, pointed towards the driveway
The Xbox 360 WebCam mounted towards the front Door
A screenshot of a motion notification from Pushover
Password Protected image viewing
The online image viewer that uses h5ai

 

The software I used to make this all happen includes:

Alright, now I’ll go ahead and explain how I set it all up. I’m not going to go into detail for every step, however if someone wants more depth on a specific part let me know.

First, I installed MotionEyeOS onto my RPi using this tutorial. After getting it set up, I plugged in each of my cameras and configured them how I wanted. Then, I set the following options as follows:

File Storage settings

I added the SAMBA share here, using the IP from my other RPi and the appropriate folder on the HDD. The command that I run to upload the picture to my external site is here, too. The whole command is

/root/upload.sh %H-%M-%S Doors %Y-%m-%d

Now, the upload.sh script contains this code:

#!/bin/bash

DATE=$3
FILENAME=/data/media/motioneye_192_168_2_77_wyatt_hdd_security_${2,,}/$3/$1.jpg
CAMERA=$2

ssh EXTERNALDOMAIN “mkdir -p /usr/share/nginx/www/security/$CAMERA/$DATE”
echo “mkdir -p /usr/share/nginx/www/security/$CAMERA/$DATE”
scp $FILENAME user@EXTERNALDOMAIN:/usr/share/nginx/www/security/$CAMERA/$DATE/$1.jpg

This script is pretty simple. It creates the current day’s folder on the server if it doesn’t exist, then uploads it. The RPi uses certificates so that it doesn’t require a password every time it uploads a photo.

Still Images settings

I set the RPi to save still images when it detects motion. I also set the filename to match what I have in my scripts.

Motion notification settings

I could have easily just used a web hook to interface with Pushover, however I wanted to have my own script, as I may redo this project using an ESP8266 and a camera module. The command here is

/root/motion.sh %H:%M Doors %Y-%m-%d

and the code inside motion.sh is

#!/bin/bash

DATE=$3
TIME=$1
CAMERA=$2

curl –data “token=REVOKED&user=REVOKED&message=$CAMERA&title=Motion Detected&url=https://EXTERNALDOMAIN/security/$CAMERA/$DATE/&sound=pushover” https://api.pushover.net/1/messages.json

This uses the API from Pushover, which is a paid app that lets you send yourself push notifications. I could have written my own app for this, however Pushover was quick and easy to use.

For a password protected link I used NGINX and its .htpassword support. A good tutorial on how to do that can be seen here.

The default folder browser for NGINX is ugly and doesn’t let you view the images easily. To make it look slightly prettier and easier to use I installed h5ai. Their website is a good place to start if you have never used it before.

This setup has been running well for a few years now, like I said. But I’d also like to redo it, using motion sensors and ESP8266’s. A setup like that would be cheaper and allow me to have cameras all around the house, not just the front door and driveway. If I ever get around to making a setup like that, I’ll make a new post! Thanks for reading.

4,059 thoughts on “Using a Raspberry Pi and MotionEyeOS To Create a Home Security Camera”

  1. Hi. I have checked your wyattmarks.com and i see you’ve got some duplicate content
    so probably it is the reason that you don’t rank hi in google.
    But you can fix this issue fast. There is a tool that creates content like human, just search in google:
    miftolo’s tools

  2. I like rock bands! I really do! And my favourite hard rock band is Hootie&Blowfish! All band members has came together to perform more than 50 concerts to their fans in 2019! To know more about Hootie & Blowfish in 2019 visit website Hootie and the Blowfish tour USA 2019. You won’t miss any concert this year if you visit the link!

  3. Good day!

    We advance

    Sending your message through the Contact us form which can be found on the sites in the contact section. Feedback forms are filled in by our software and the captcha is solved. The profit of this method is that messages sent through feedback forms are whitelisted. This technique increases the chances that your message will be read. Mailing is done in the same way as you received this message.
    Your message will be seen by millions of site administrators and those who have access to the sites!

    The cost of sending 1 million messages is $ 49 instead of $ 99. (you can select any country or country domain)
    All USA – (10 million messages sent) – $399 instead of $699
    All Europe (7 million messages sent)- $ 299 instead of $599
    All sites in the world (25 million messages sent) – $499 instead of $999

    Discounts are valid until April 20.
    Feedback and warranty!
    Delivery report!
    In the process of sending messages we don’t break the rules GDRP.

    This message is automatically generated to use our contacts for communication.

    Contact us.
    Telegram – @FeedbackFormEU
    Skype – FeedbackForm2019
    Email – FeedbackForm@make-success.com

    Thanks for reading.

  4. Woah! I’m really loving the template/theme of this site. It’s simple, yet effective.
    A lot of times it’s difficult to get that “perfect balance” between user friendliness and appearance.
    I must say you have done a superb job with this.
    Also, the blog loads extremely fast for me on Firefox. Superb
    Blog!

  5. Pingback: viagra for women
  6. Pingback: viagra for sale
  7. Pingback: viagra generic
  8. Pingback: viagra online
  9. Pingback: viagra pills
  10. Pingback: viagra prices
  11. Pingback: viagra sex
  12. Pingback: cialis prices 10mg
  13. Pingback: viagra vs cialis
  14. Pingback: cialis prices 20mg
  15. Pingback: cialis prices 5mg
  16. Pingback: buy cialis
  17. Pingback: sildenafil
  18. Pingback: sildenafil 100mg
  19. Pingback: buy cialis online
  20. Pingback: sildenafil 20 mg
  21. Pingback: sildenafil citrate
  22. Pingback: sildenafil coupons
  23. Pingback: sildenafil dosage
  24. Pingback: sildenafil generic
  25. Currently manufactured by two companies, Bayer Pharmaceuticals and GlaxoSmithKlein, Levitra uses a substance named vardenafil as its main component. viagra online The Government released its initial guidelines on treatment of impotence “to find a sensible balance between treating men with the distressing condition of impotence, and protecting the resources of the NHS to deal with other patients”.

  26. That is the appropriate weblog for anybody who desires to find out about this topic. You understand a lot its nearly arduous to argue with you (not that I really would need匟aHa). You undoubtedly put a new spin on a topic thats been written about for years. Nice stuff, simply great!

  27. An impressive share, I simply given this onto a colleague who was doing a bit of analysis on this. And he in reality purchased me breakfast as a result of I found it for him.. smile. So let me reword that: Thnx for the deal with! However yeah Thnkx for spending the time to discuss this, I really feel strongly about it and love reading extra on this topic. If doable, as you turn into experience, would you thoughts updating your blog with more details? It’s highly useful for me. Big thumb up for this blog submit!

  28. The trust was initially established with the objective of monitoring of the Black Rhino population in the Sinamatella area of Hwange National Park, in conjunction with the Zimbabwe Parks and Wildlife Management Authority and the SAVE the African Rhino Foundation of Australia. where to buy viagra V TV Commercials 2018-19 San Antonio Spurs Commercials H-E-B and the San Antonio Spurs are at it again with another round of comical television commercials, featuring playful performances by current and former Spurs players On December 1, 2017 By Fx In Television Tunes, TV Commercial Songs Victoria’s Secret – Holiday 2017 Commercial Ad Song “Holiday 2017” is basically a commercial ad of Victoria’s Secret that was launched in United State.