Raspberry Pi-based Home Security System

DRAFT - I AM WORKING ON THIS - IT IS NOT FINISHED

This project uses a Raspberry Pi and sensors to create Phase 1 of a home security system.

Main Features:

    • Send security alerts to a mobile phone

    • No monthly fees - self-monitored security system

    • Provide a simple, secure website for remote or local access to check or arm the system

A Raspberry Pi 3B+ or RaspberryPi 4 is required.

A self-monitored system eliminates monthly costs. In addition, if a security monitoring company calls the police and nothing is wrong, then the homeowner must pay a false alert fee. With a self-monitored system, the homeowner decides if a call to the police is warranted.

Security alerts are audible in the home, and are sent to one or more mobile phones.


This phase of the security system will only cover sensors: windows, doors, garage door and motion.

I don't want to use or replace batteries. So this project uses wired sensors.

Required Parts:

    • PoE Switch

    • Raspberry Pi

Step 1. Create a Plan

I created the image at the beginning to serve as a guide for the Security System's functionality. The website should show most functionality, but there will be items not shown in the website.

Then I created a detailed To Do list, which I keep in the DRAFT version in its own text box. A snippet is shown below.

Step 2. Setup Raspberry Pi

In Step 2, I am not putting the Raspberry Pi in a case. I am putting the Raspberry Pi in steel security case.

Since the code is in python and not dependent on the OS, the latest version of Raspbian can be installed

This application runs headless, which means it does not have a display or a desktop. So, use the Raspbian Lite download

After set up, you should know

♣raspberry-pi-ip-address♣

♣hostname♣

♣raspberry-pi-password♣

Step 3: Raspberry Pi Mounting

Measure, measure, measure, ...

I am putting the Raspberry Pi (RPi) inside a metal box.

Since it is inside a grounded metal box, the Raspberry Pi needs an ethernet cable, and the RPi needs power. I am using PoE. So, I only need an ethernet cable to the PoE switch, which supplies both an internet connection and power to teh Raspberry Pi.

I took the front cover off the box to drill the holes (image above). I used a 3/32" metal drill bit. The RPi has M2.5 mounting holes. #/32 ~= M2.5.

Mount the RPi using 4x M2.5 nuts, offsets (hex nut with bolt) and bolts.

Step 9. Create a Wire Frame

The old school way to design a website is to create a wire frame. I am not creating an html or css wire frame, but just a sketch of how I want it to work. There are a lot of tools for this. I use PowerPoint. The image at the beginning was done in PowerPoint.

I was a lot of time designing websites. I am not good at it, and I don't do it very often. So, I relearn html and css each time. I rely heavily on W3schools.

*** STOPPED HERE ***

To Do List:

  • Skipped Required Parts - go back and add everything required

  • Website

      • Home Page, Vacation Page, Schedule Page

          • Pressing Center Knob changes page (Home, Vacation, Schedule)

          • Browser's controls should all work (Back, Refresh, etc)

      • Use aspect ratio of 16:9 (width = 1.778 x height)

      • Vacation Page with Vacation Command and Dates

      • Schedule Page with Schedule command and Times

      • Make text on buttons look engraved

      • Need multiple buttons: put black dial ring around buttons that are not pressed - should only be green or red if pushed or active

      • background color rgb: 32, 29, 46 (or amazon echo background color) #201D2E

      • text color: 150, 143, 175. #968FAF


  • MAKE WITHOUT THE DSC System

      • how many volts do each of the DSC sensors use/require

      • may need to relay block like in garage door opener

      • start new git hub project for security

      • Add sensors for backdoor, front door, gates, garage, garage door

      • Number of unique sensors: 19 + fire, + garage door

      • 26 gpio pins

  • Other Stuff

      • use systemd to start and restart script - don't use crontab (user rpi-echo.service)

      • Add hardening

      • port scripts to python3 - shell scripts should use python3 and not python

      • send text message process dies or power is lost

      • add something to periodically restart and delete the log file

      • Add commands to change start stop time for day

      • Vacation from and to dates, like schedule

      • sensors only indicate if the door/window is closed, and not if it is locked

          • Add August door lock and MyQ to security system (might not need garage door sensor)

  • Check which smtp tool comes installed by default on raspbian - modify stpe 7 accordingly

  • Check step 8 and the packages beign installed (use python, html and css rather than php ...)

  • Database Schema

      • Drop zones

      • DB should use room-name (family room, master bedroom, etc.) and sensor-type (window, door, garage, garage door)

  • Add UPS like like used in Kodi setup did

  • Replace DSC control panels with ???

      • Add control panel by back door

      • can I power/have 3x displays from the main Pi?

  • Improve Echo Control

      • start new GitHub for faux - use just fauxmo ???

      • echo turn on security - enables sleep mode

      • echo turn off security - disables alarm and sleep mode

  • Enhanced Monitoring

      • python script complete, parts need to be added to website

*** STOPPED HERE ***

Step 10. Convert the Wire Frame to a Responsive Dynamic Design

red buttons need to be larger

S & V need to come down a bit

need red, green, blue ? and black buttons - red and green signify active

add text to buttons

Active page: H, S or V needs to be brighter, and arrow needs to move to active page

Fix top black smudge on dial

fix bottom of ring around dial where it is pixelated

remove excess HTML

split into CSS and HTML

THIS IS CRAP

Again, there are a lot of tools for creating a responsive dynamic design. I used Justinmind. Justinmind is probably not the best choice. It generates a lot of garbage html; obfuscates the names of files; and generally, makes a mess of things. But it works!

Next I edit the Justinmind auto-generated files fluff until I am down to a minimal set of functioning css and html.

Great tool: https://www.tutorialspoint.com/online_html_editor.php

Step 11. Create a Favorite Icon

A Favorite Icon appears next to the website name in the tab. It isn't really necessary to create a favorite icon, but it seems to show completeness.

A Favorite Icon is 128x128 pixels. Create a png file using your favorite paint tool. I use Paint X, which I downloaded for free from Apple's App Store.

The png file must be converted to ico format. There are several on-line tools to do this. I use icoconvert. Just follow the directions.

*** Add wget to download security.ico file ***

Step 11. Get a Web Page running

Create webpage using html, css, php and sqlite3 WITH MINIMAL PHP

create wireframe for location of buttons and links

use standard web directory structure: images, css, cgi

use https://www.w3schools.com/w3css/default.asp

<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">

need to add stats page

need a bunch of steps to explain, test voltage levels, and hook up sensors

Step 11. Download the Scripts and Change privileges

Step 12. Add systemd service to ensure script is running and restarts

Step 13. Python script that automatically arms and disarms the security system using a schedule

Step 14. Check that website is working