Raspberry Pi – Home Monitoring System

Using multiple Raspberry Pis, I’ve put together a small system to monitor my home when away.

In order to maintain my own privacy, I’ve set up a system which detects when myself or my partner is home by periodically pinging our phones IP addresses on the local WiFi network and disables recording/monitoring when either of us has been home withing a defined time period.

There are two main programs involved, the listener and the sender.

Source Code:

Shared Files:  https://github.com/comeradealexi/RaspberryPiShared
Sender: https://github.com/comeradealexi/RaspberryPiNetworkRecordSend
Listener: https://github.com/comeradealexi/RaspberryPiNetworkRecordListen


The sender is a really simple little program, all it does it listen for a change on a specified GPIO port and then sends the status of the door to all clients listed in a text file.

In my case, the sender is hooked up to a little magnetic switch to the front door of my flat. When the status of the switch changes, it sends this change to all listeners on the network.

In theory the device running the sender could also run a listener program if a camera to record was also hooked up to it.


This is where the bulk of the project is contained. The listener has a number of components working together:

LANNetworkCheck: This class periodically pings multiple ip addresses on the LAN to detect if anyone is home. Currently this is just hard coded for my purposes, but would work nicely if lifted into being loaded from a file. That way multiple listeners could in theory have different rules about who it should record. Say for instance you didn’t want anyone coming into your office, you could set it only detect your phones ip address.

So in the event of a signal being received by a sender that a door has been opened, the program will then check if a valid ip was detected within the last 10 minutes. If so, the status change is ignored. I set it to 10 minutes to give adequate time for phones to conenct to the wifi network when entering the home.

If however a valid ip has not been detected in the last 10 minutes, the recording process beings. It starts off by taking a still picture with the camera and emailing the image to the specified email address. It will then start recording video indefinitely until a valid ip is connected.

Additionally, to handle situations where the door may have been opened but the phone not conencted to the wifi and recording has started, if a valid ip is connected within the first 10 minutes of recording, it’ll delete the recording.

Another feature for peace of mind is a simple status update where if a valid ip has not been detected for more than x hours, it’ll take and email a picture to a specified email address. This feature isn’t really necessary for day to day use but is nice if you are away on holiday for example.

My Setup:

I’ve got a Pi Zero hooked up to the front door running the sender program.

Then a Pi 3 and another Pi Zero both with cameras running the Listener program.

External Programs Used:

To take/record from the camera raspivid and raspistill were used.

To send emails with attachments, mutt was used.

Improvements TODO:

This was a fairly small project but the following features would make it much better if implemented, but it would require a lot of extra work which I don’t currently have the time to implement:

  • Ability to remotely trigger picture/video taking and sending to email address. Ideally I was trying to come up with a system which would work 100% of the time, since I don’t have a static IP address on my home network, I would have to devise some sort of system where each Pi communicates with my remote server and only receive commands from it.
  • A remote and secure website to stream video footage from cameras. I started working on something to this effect but it proved quite difficult to get it to stream reliably so this feature was parked.
  • When a door open event is detected and video recording occurs, it would be good to have this sent to an email address or accessible via some sort of server remotely.