Home-made Raspberry Pi based Home Security System

A home made security solution that can be customized and expanded as needed

Project Image
Project Owner:

John N. G. Samarasinghe

Project End Date:


Project tags:

Raspberry Pi, Project, Home Security

Dive in to details

For the past couple of years the economic status of my country has been deteriorating by the day. The problems faced by an average person seem to be ever increasing and people are becoming desperate. So desperate in fact that the number of break-ins in my quiet neighbourhood have increased drastically. In addition to adding some security measures, I wanted to try out my own security system with features customized to my needs so that I have full control of every situation that I will come across.

I will be using my Raspberry 3B as the main brains of the operation. The system will be stand-alone and not directly connected to internet unless external communication is needed.

Camera System

My house is already equipped with a number of security cameras which monitor the area in and around my house. These are hard-wired cameras which connect to a DVR inside the house. The DVR has a capability of very basic motion detection which captures any change in pixels and sends the image to a registered email. Although this method helps capture movement from the cameras, about 70% of the movement is from animals, trees moving in the wind, rain, and movement of shadows.

With the objective of filtering out the suspicious activity of moving vehicles and people outside the house, I let the camera system run for 2 weeks and collected a library of 8,000 images per camera of different scenarios. After the a very - very long time of classifying the suspicious movement from the rest and building a randomized array of 4000+ training images, I created a deep convolutional neural network on Google Colab to classify the 2 scenarios resulting in to more very - very long and painful period of trial and error to narrow down on a suitable neural network architecture based on similar successful neural networks such as VGG-16.

The ideal classification method after many trial and error cycles was to initially convert the images to black and white to eliminate the differences due to day and night and then build a neural network with below architecture in Keras

cnn = Sequential()
cnn.add(Conv1D(64, (3), activation='relu', padding='same', kernel_initializer='random_normal', input_shape=(288, 352)))
cnn.add(MaxPooling1D(pool_size = (2)))
cnn.add(Conv1D(64, kernel_size = (3), activation = 'relu', kernel_initializer='random_normal'))
cnn.add(MaxPooling1D(pool_size = (2)))
cnn.add(Conv1D(64, kernel_size = (3), activation = 'relu', kernel_initializer='random_normal'))
cnn.add(MaxPooling1D(pool_size = (2)))
cnn.add(Dense(64, activation='relu'))
cnn.add(Dense(32, activation='relu'))
cnn.add(Dense(8, activation='relu'))
cnn.add(Dense(1, activation='sigmoid'))

opt = Adam()
cnn.compile(optimizer=opt, loss='binary_crossentropy', metrics=['accuracy'])

Although the classification accuracy is high for the training set the loss values are considerably large as there are a number of images where it is very difficult to determine if there is any suspicious activity. For example when only a small part of the body like a foot is captured in the security camera. This can be filtered out by identifying the images classified with probabilities above 95%

iamJohnnySam Security System iamJohnnySam Security System

Once the neural network is adequately trained, I converted the neural network model to a tensorflow lite (tflite) model which can be implemented on a raspberry pi and wrote a simple python code to
1. Download images sent from my CCTV system
2. Classify the images using the tflite model to identify suspicious behaviour
3. Send suspicious images to my phone via pushbullet
4. Send suspicious to my email address every 1 hour if the pushbullet service is down

This code can be found on my github

iamJohnnySam Security System

Gas Detection System & Extensible mesh network for DIY security devices

Now that the cameras were taken care of I wanted to a few more things around the house starting with a gas detection system for the kitchen in case someone leaves the stove on while we are not in the house.

To do this I bought a 12V power supply used for CCTV camera systems so that I can use it as a Power supply + as an enclosure for my projects. In to this I built a ESP8266, 12V to 5V buck power converter and a MQ LPG detection sensor. For the ESP8266 I wrote a program to broadcast the status of the gas sensor every couple of minutes.

iamJohnnySam Security System

iamJohnnySam Security System

Since devices similar to this will be spread all throughout the house I am not able to guarantee that the Wi-Fi will reach all the devices. As such a created a Wi-Fi mesh network using the ESP8266 devices and the PainlessMesh library

Using similar devices I have set up motion detection and suspicious activity detection system around the house which communicate any activity to my phone so that I am able to take action.

Similar Posts

See other projects and posts in the same category as this post

blog item Creating a Personal Assistant to automate my lifestyle
Designing, Building and Programming a personal assistant to automate my lifestyle.
python, machine learning, programming, smart home 2024-01-13 | Read More....
blog item DIY Raspberry Pi based Media Box
My effort at creating a system to unify the media around my house
raspberry pi, ssh, media 2023-07-08 | Read More....
blog item Home-made Raspberry Pi based Home Security System
A home made security solution that can be customized and expanded as needed
Raspberry Pi, Project, Home Security 2022-02-25 | Read More....
blog item Home-made Raspberry Pi based Media Center
A homemade solution for a networked media storage and madia playback
Raspberry Pi, Kodi, LibreELEC, Samba, Network Storage 2020-10-30 | Read More....
Comment Box is loading comments...