Door sensor web application for Raspberry Pi
Raspberry Pi runs nodejs web application serving a web page with information if the door is open (for example busy office toilet door). Toilet door state is sensed with reed switch or simple switch mounted to the door connected to GPIO. Optionally, RGB LED drived with three GPIO pins shows the current sensor state.
Node application monitors state of S1 switch connected to GPIO using shell command 'gpio'. Each change of switch state is broadcasted using websockets to client browsers. "Reserve" button allows to broadcast intention of visiting toilet.
After starting nodejs web application this is how the web interface looks like:
free | occupied | reserved |
---|---|---|
-
Upgrade nodejs to 4.0.0 or later
-
Perform following commands in raspberry pi home folder (/home/pi/):
git clone https://github.com/panjanek/RpiDoorSensor.git cd RpiDoorSensor npm install
4. Run the application
sudo nodejs app.js
5. In order to start the application at boot:
chmod +x doorstart.sh sudo contab -e
Add the following line in editor:
@reboot /home/pi/RpiDoorSensor/doorstart.sh &
Save and exit. After reboot the nodejs application will run forever.