It all started with a snow problem.

I wanted to check remotely how much snow had fallen on my home in the mountains (I live in the French Alps), specially whether the snow removal machine had cleared the way.

So I started to tinker with the camera module of the Raspberry Pi (a low cost, Linux based, single board computer).

I quickly landed on Motion , a software package which provides real time camera feed into any web browser. So with running Motion on a Raspberry PI, I can remotely look at my garden from my smartphone (the feed is a few fps, with a one or two seconds delay, but good enough for that purpose).

Motion also provides some interesting additional features:

  • motion detection (yes, there is logic in the name) with picture and video creation, and alarm generations.

Motion is very customizable and you will find plenty of tutorials on the Internet. In this short article, I will focus on what I built around it to make it more user-friendly:

  • manage multiple cameras

The entire software is available on GitHub (python and bash). I typically use a small Raspberry PI Zero as a camera node

A camera node based on the Raspberry PI Zero. Includes a full Linux system !

The GUI was developed in Python using remi and is accessible from any web browser. There can be one or several camera nodes but only one runs the GUI.

The GUI allows to select one of the configured camera node, and read or set some key configuration parameters for that camera:

  • (Detection) Threshold. This is the number of pixels which need to change, from one frame to the next, for Motion to detect a “movement”. Think about it as the detection sensitivity. Setting it to zero or to a very high number will, in fact, disable movement detection. Detection generates notifications and emails which may be overwhelming if you are not interested in the surveillance of the system. Also bear in mind that detection is based on pixels changes, so , unlike others solutions such as PIR (Passive Infrared Sensors), it can be configured to be very sensitive but is also subject to changes in lightning conditions.
Example of a timelapse

If motion detection is configured and a motion detected, you will get a notification on your smartphone, as well as a email with a picture of the detection attached.

Example of a smartphone notification using Pushover

The URLs included in the smartphone notification are clickable, and point to a picture and a short video recorded at the time of the detection event. By looking at those you can see what happened.

Both the picture and the video are stored in a web server running on the camera node. They are available thru a simple photo gallery application.

This web server can be made available from outside your home network using standard NAT (network address translation) configuration.

Oops, a movement have been detected! The changed pixels are indicated by a red rectangle.

A menu on the GUI gives access to:

  • stream: this is a real time stream of the camera in your web browser.

The camera(s) status are also pushed on a regular basis (eg every 30mn) to your smartphone. Just to get reassured.

Finally, the GUI allows also to stop, reboot a camera node, and view/change passwords.

Holistic management of password was a key function I wanted to develop. It turned out to be not that easy. Each of the component ( Motion, the GUI, monit and the photo gallery) has a separate password. And each password is stored in a specific configuration file.

Now it is time for serious RPC (Remote Procedure Calls) and automatic edition of text files (sed and regex are my friends). This was the most painful part of the project, (or the most interesting, depending on how you view the world).

The system is now relatively well packaged (all key parameters are in json files) and can be duplicated easily.

As I keep offering it to my family and friends, some are interested in the surveillance feature, some in the garden monitoring, some just want to get rid of me …

Time for serious production

But I will have no rest until my two daughters tell me, yes Dad, we want one of your camera.

tinker with Raspberry PI, ESP32, solar, LIPO, sensors, zwave, energy harvesting, python, micropython, keras, tensorflow, tflite, TPU. Ex Intel and HP

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store