DIY Home Monitoring & Intruder Alert system
View the Project on GitHub orosandrei/Home-Monitoring-Raspberry-Pi-Node
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:
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).
The project was developed using:
this.Gpio = require('pi-gpio');
this.Hardware = { MotionSensor : 8, Led : 26, Button : 12 };
The dependencies you install with NPM:
npm install module --save
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
ApplicationHM.js
Authentication (digest http authentication) - defaults are admin & password :)
htdigest
file (nice helper tool here http://websistent.com/tools/htdigest-generator-tool/ ) admin:Private:6982db7f1ddc36a0b47b5f8427dc3526
Web Client application
start-webcam.sh
script The client application was designed to be accessible on all platforms (pc / tablet / mobile).
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);
config.ini
file The dropdown shows a list of all connected clients (connection timestamp & IP) that are currently viewing the video stream
start-app.sh
./start-app.sh
./start-app.sh -background
#!/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" &
TO DO
References
Links