Home-monitoring-raspberry-pi-node

DIY Home Monitoring & Intruder Alert system

View the Project on GitHub orosandrei/Home-Monitoring-Raspberry-Pi-Node

Home Monitoring with Raspberry Pi and Node.js

Alt text

Description

The project is designed as a end to end solution for a DIY Home Monitoring & Intruder Alert system. Besides offering a live video stream on any device (web responsive client), it also actively monitors for movement with the help of a PIR sensor.

If an Alarm is triggered, you get a SMS notification on your phone and the snapshots taken during the Alarm time span (customizable - default is 1 minute) are uploaded via FTP to your server.

Activation / Deactivation of the Alarm Mode can be done in 2 ways:

  1. from the Web Client user interface
  2. with a Button - for convenience reasons: it is faster than connecting from your phone / pc & toggling the Alert Mode checkbox
    • there is a 10 seconds customizable delay which allows you to move out of the PIR sensor range
    • a Led indicates the Alarm Mode enabled/disabled status

In order to avoid false positives from the PIR motion sensor, extra checks were added - a detection counter & detection interval. The Alarm gets triggered when the sensor detects movement 3 times in 5 seconds (both values configurable in code).

Technology

The project was developed using:

Project components

Hardware

Alt text

this.Gpio = require('pi-gpio');
this.Hardware = { MotionSensor : 8, Led : 26, Button : 12 };

Alt text

Node application

Dependencies

The dependencies you install with NPM:

npm install module --save

Generic Application.js

It is the basic application object, defined to be reusable in other projects Contains the basic server code, generic config file read/write operations, generic Init & Execute & Exit methods implementations

Home Monitoring ApplicationHM.js

Alarm mode

Web Client - responsive

The client application was designed to be accessible on all platforms (pc / tablet / mobile).

Alt text

Video streaming quality settings

By default the 480p at 25fps is enabled (initial settings are loaded from the config.ini file)

My webcam is a low-end 5+ years old 2mp device, but for those of you with better webcams I also added 720p & 1080p

Video resolutions & fps can be configured from the /static/js/script.js file

//only check quality settings
if(ui.quality480p.prop('checked')) {
    appConfig.monitoring.quality = "640x480";
    appConfig.monitoring.fps = 25;
}
if(ui.quality720p.prop('checked')) { 
    appConfig.monitoring.quality = "1280x720";          
    appConfig.monitoring.fps = 25;
}
if(ui.quality1080p.prop('checked')) { 
    appConfig.monitoring.quality = "1920x1080";         
    appConfig.monitoring.fps = 25;
}

//send to server new config settings
socket.emit('update config quality', appConfig);

Alert Mode

Connected Clients

The dropdown shows a list of all connected clients (connection timestamp & IP) that are currently viewing the video stream
Alt text

Shell Scripts

start-app.sh

#!/bin/bash
# application start in interactive or background mode
#arguments:  [-background]

cd /home/pi/Desktop/rpiWorkspace/Node/HomeMonitoring/

if [ "$1" = "-background" ]; then
    sudo nohup node ./App-home-monitoring.js &>log.txt &
else
    sudo node ./App-home-monitoring.js 
fi

start-webcam.sh

#!/bin/bash
# webcam video stream
# arguments:  [resolution] [port] [fps]

pkill mjpg_streamer

sudo nohup ./mjpg-streamer/mjpg_streamer -i "./mjpg-streamer/input_uvc.so -y -r $1 -f $3 -q 75" -o "./mjpg-streamer/output_http.so -n -p $2" &

Application Execution Session example

Alt text


TO DO

References


Links