{"id":13989918,"url":"https://github.com/orosandrei/Home-Monitoring-Raspberry-Pi-Node","last_synced_at":"2025-07-22T11:32:13.955Z","repository":{"id":82004475,"uuid":"42272830","full_name":"orosandrei/Home-Monitoring-Raspberry-Pi-Node","owner":"orosandrei","description":"Raspberry Pi \u0026 Node.js diy Home Monitoring \u0026 Intruder Alert system","archived":false,"fork":false,"pushed_at":"2016-08-11T12:04:55.000Z","size":1186,"stargazers_count":50,"open_issues_count":1,"forks_count":22,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-08-09T13:16:44.414Z","etag":null,"topics":["alarm","iot","monitoring","nodejs","pir-sensor","raspberry-pi","video-stream","webcam"],"latest_commit_sha":null,"homepage":"http://orosandrei.github.io/Home-Monitoring-Raspberry-Pi-Node","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/orosandrei.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-09-10T21:57:58.000Z","updated_at":"2024-04-22T13:31:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"738ffd3c-78f1-47a6-bd29-d90f7b81cd81","html_url":"https://github.com/orosandrei/Home-Monitoring-Raspberry-Pi-Node","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orosandrei%2FHome-Monitoring-Raspberry-Pi-Node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orosandrei%2FHome-Monitoring-Raspberry-Pi-Node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orosandrei%2FHome-Monitoring-Raspberry-Pi-Node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orosandrei%2FHome-Monitoring-Raspberry-Pi-Node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orosandrei","download_url":"https://codeload.github.com/orosandrei/Home-Monitoring-Raspberry-Pi-Node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227089473,"owners_count":17729471,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alarm","iot","monitoring","nodejs","pir-sensor","raspberry-pi","video-stream","webcam"],"created_at":"2024-08-09T13:02:10.161Z","updated_at":"2024-11-29T09:30:36.605Z","avatar_url":"https://github.com/orosandrei.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Home Monitoring with Raspberry Pi and Node.js\n \n![Alt text](https://github.com/orosandrei/Home-Monitoring-Raspberry-Pi-Node/raw/master/screenshots/system.jpg?raw=true \"Home Monitoring with Raspberry Pi and Node.js\")\n \n## Description  \n \nThe project is designed as a end to end solution for a DIY **Home Monitoring \u0026 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*.\n \nIf 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.  \n \nActivation / Deactivation of the *Alarm Mode* can be done in 2 ways:  \n 1. from the Web Client user interface \n 2. with a Button - for convenience reasons: it is faster than connecting from your phone / pc \u0026 toggling the Alert Mode checkbox \n    - there is a 10 seconds customizable delay which allows you to move out of the PIR sensor range \n    - a Led indicates the Alarm Mode enabled/disabled status \n \nIn order to avoid false positives from the PIR motion sensor, extra checks were added - a detection counter \u0026 detection interval. The Alarm gets triggered when the sensor detects movement 3 times in 5 seconds (both values configurable in code).\n \n## Technology \n \nThe project was developed using: \n- [Raspberry Pi](http://raspberrypi.org) - [raspbian](https://www.raspbian.org/), brick button \u0026 led, Pir sensor\n- [Node.js](https://nodejs.org/en/) - for the main application \n- [Mjpg_streamer](http://sourceforge.net/projects/mjpg-streamer/) - to generate the video stream \n- Shell scripting - for easy application start (interactive \u0026 background) \n- Htms/Css/Javascript + [Bootstrap](http://getbootstrap.com/) - the web client  \n \n## Project components \n \n### Hardware \n![Alt text](https://github.com/orosandrei/Home-Monitoring-Raspberry-Pi-Node/raw/master/screenshots/diagram.PNG?raw=true \"Pir Button Led RaspberryPi Gpio\")\n```javascript\nthis.Gpio = require('pi-gpio');\nthis.Hardware = { MotionSensor : 8, Led : 26, Button : 12 };\n```\n- Raspberry Pi \n  - I used *Model B Revision 2* with *Raspbian* - any model should be Ok, just be careful with the Gpio configuration pin mappings, they can differ \n  - Generic USB webcam (compatible with Raspberry Pi \u0026 Raspbian) \n  - You can find a comprehensive list here http://elinux.org/RPi_USB_Webcams  \n  - I used a very old 2MP one which seems to work out of the box with the generic drivers \n- Led \u0026 Button  \n![Alt text](https://github.com/orosandrei/Home-Monitoring-Raspberry-Pi-Node/raw/master/screenshots/button-led-brick.png?raw=true \"Brick Button Led\")\n- PIR motion sensor \n\n![Alt text](https://github.com/orosandrei/Home-Monitoring-Raspberry-Pi-Node/raw/master/screenshots/pir.jpg?raw=true \"PIR sensor\")\n  - The one I used is available here https://www.sparkfun.com/products/13285  \n  - It normally connects to Analog Input (ex. on Arduino); however you can use it with Digital as well if you connect a 10K resistor between VCC \u0026 Signal  \n![Alt text](https://github.com/orosandrei/Home-Monitoring-Raspberry-Pi-Node/raw/master/screenshots/pir-10k-resistor.jpg?raw=true \"PIR resistor\") \n  - To make things easier you can purchase this sensor https://www.adafruit.com/products/189 and skip the soldering part (+ this one has configurable sensitivity built-in, so you might be able to skip the one implemented in the code)    \n \n### Node application \n \n#### Dependencies \n- express: ^4.12.3 \n- ftp: ^0.3.10 \n- http-auth: ^2.2.8 \n- ini: ^1.3.4 \n- pi-gpio: 0.0.7 \n- socket.io: ^1.3.5 \n- twilio: ^2.3.0 \n \nThe dependencies you install with NPM: \n```\nnpm install module --save\n```\n \n#### Generic ```Application.js```\nIt is the basic application object, defined to be reusable in other projects \nContains the basic server code, generic config file read/write operations, generic Init \u0026 Execute \u0026 Exit methods implementations \n \n#### Home Monitoring ```ApplicationHM.js``` \n- config.ini file \n  - default video quality \u0026 alert mode settings\n  - Twilio sms Api *Sid*, *Token*, *To* number, *From* number \n  - Ftp settings\n- Authentication (digest http authentication) - defaults are **admin** \u0026 **password** :) \n  - You can change them from the ```htdigest``` file (nice helper tool here http://websistent.com/tools/htdigest-generator-tool/ ) \n  ```\n  admin:Private:6982db7f1ddc36a0b47b5f8427dc3526\n  ```\n\n- Web Client application\n  - Accessible from anywhere via [port forwarding](https://en.wikipedia.org/wiki/Port_forwarding)\n  - Available also on mobile (responsive web client) \n- Monitoring - gets video from [Mjpg_streamer](http://sourceforge.net/projects/mjpg-streamer/) server and sends it to the connected app clients \n- [Mjpg_streamer](http://sourceforge.net/projects/mjpg-streamer/) was used as server, but if you prefer another tool like ffmpeg, you can easily replace it because of the loose integration via the ```start-webcam.sh``` script \n\n#### Alarm mode \n- Monitoring - via PIR sensor \n- Alarm - Sms notification (implemented with the help of [Twilio](https://www.twilio.com/sms)   text messaging API - very cool service, offers great Trial account for development \n- Alarm - Snapshots upload to server via Ftp \n \n### Web Client - responsive\n \nThe client application was designed to be accessible on all platforms (pc / tablet / mobile). \n\n![Alt text](https://github.com/orosandrei/Home-Monitoring-Raspberry-Pi-Node/raw/master/screenshots/client.PNG?raw=true \"Web Client\")  \n\n#### Video streaming quality settings \nBy default the 480p at 25fps is enabled (initial settings are loaded from the ```config.ini``` file) \n\nMy webcam is a low-end 5+ years old 2mp device, but for those of you with better webcams I also added 720p \u0026 1080p \n\nVideo resolutions \u0026 fps can be configured from the ```/static/js/script.js``` file \n```javascript\n\tui.quality480p.change(function(){ ConfigUpdateQuality(\"640x480\",25); });\n\tui.quality720p.change(function(){ ConfigUpdateQuality(\"1280x720\",15); });\n\tui.quality1080p.change(function(){ ConfigUpdateQuality(\"1920x1080\",5); });\t\n```\n \n#### Alert Mode \n- initial state is loaded from the ```config.ini``` file \n- You can enable/disable monitoring from checkbox button in the UI \n- The state of the Alert Mode is shown both in the UI (the checkbox) but also by the LED \n- The physical Button can be also used to toggle the Alert Mode \n- All state changes are sent to all connected clients \n- If an Alarm is triggered, the UI checkbox button background will be changed to Red \n![Alt text](https://github.com/orosandrei/Home-Monitoring-Raspberry-Pi-Node/raw/master/screenshots/alarm.PNG?raw=true \"Alarm\")  \n\n \n#### Connected Clients \nThe dropdown shows a list of all connected clients (connection timestamp \u0026 IP) that are currently viewing the video stream  \n![Alt text](https://github.com/orosandrei/Home-Monitoring-Raspberry-Pi-Node/raw/master/screenshots/clients-list.PNG?raw=true \"Connected Clients List\")  \n\n \n### Shell Scripts \n \n**start-app.sh**\n- You can start the application in 2 modes: \n  - Interactive (for dev / testing): ```./start-app.sh```\n  - Background: ```./start-app.sh -background```\n```shell\n#!/bin/bash\n# application start in interactive or background mode\n#arguments:  [-background]\n\ncd /home/pi/Desktop/rpiWorkspace/Node/HomeMonitoring/\n\nif [ \"$1\" = \"-background\" ]; then\n\tsudo nohup node ./App-home-monitoring.js \u0026\u003elog.txt \u0026\nelse\n\tsudo node ./App-home-monitoring.js \nfi\n```\n  \n**start-webcam.sh**\n- Used by the application to enable/disable video streaming when clients are connected or when an Alarm is triggered by the PIR sensor. \n```shell\n#!/bin/bash\n# webcam video stream\n# arguments:  [resolution] [port] [fps]\n\npkill mjpg_streamer\n\nsudo 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\" \u0026\n```\n\n## Application Execution Session example\n![Alt text](https://github.com/orosandrei/Home-Monitoring-Raspberry-Pi-Node/raw/master/screenshots/session.PNG?raw=true \"Application Execution Session example\")  \n\n---\n \n**TO DO** \n- Port the application to Windows 10 Iot on Raspberry Pi 2 \n- Support for uploading snapshots to cloud (OneDrive / Dropbox) when an Alarm is triggered \n \n**References** \n- Raspberry Pi https://www.raspberrypi.org/  \n- Node - https://nodejs.org/en/  \n- Mjpg_streamer http://sourceforge.net/projects/mjpg-streamer/  \n- SMS Api - Twilio - https://www.twilio.com/sms  \n- Bootstrap http://getbootstrap.com/ \n- App Webcam Icon - https://www.iconfinder.com/icons/71274/webcam_icon#size=128  \n\n\n---\n**Links**\n- Blog post about project [Home Monitoring with Raspberry Pi \u0026 Node](http://andreioros.com/blog/home-monitoring-raspberry-pi-node/%20)\n- [Hackster.io project page](https://www.hackster.io/andreioros) \n- twitter [@orosandrei](https://twitter.com/orosandrei)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forosandrei%2FHome-Monitoring-Raspberry-Pi-Node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forosandrei%2FHome-Monitoring-Raspberry-Pi-Node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forosandrei%2FHome-Monitoring-Raspberry-Pi-Node/lists"}