This was a project I created as part of my IoT class. It consists of a back end server with an API to control all the room functionality and a front-end that can be opened on any web browser to communicate with the raspberry pi server.
The core functionality of the back end exists in the roomServer.py file. This will run the flask app which specifies the following API routes:
This route will return the led status as a json object in the response body.
A get request to alarm-on will activate the alarm
A get request to the alarm-off will disarm the alarm
This will return wether or not the room is occupied as a json object in the response body.
This route allows the led to be turned on and the color to be set to RED, GREEN, or BLUE. This route expects a request with a 'color' field specified.
This route acts as a convenience function for turning the leds off.
- Install required libraries (See Below)
- Install roomServer.py, ledManager.py, and alarmManager.py all at the same location on the raspberry pi
- Connect, buzzer to D8 and ultrasonic ranger to D4, also connect LEDS to proper GPIO pins
- Run roomServer.py with root privileges (for leds)
- Install the code in Client run on any web server (i.e. Apache)
- Adjust urls in index.js file to reflect the raspberry pi IP address
- View the site in a web browser and control the room
GrovePi Adafruit Nanopixel Flask