Home Hub
This project is a home hub that utilises MQTT technology by IBM to allow multiple smart alarm clocks to be automatically added and subsequently controlled by a web application. The smart alarm clocks makes use of light, temperature and humidity sensors to monitor the surrounding environment in real time as well as functioning as a working alarm clock.
Hardware Required (per Device)
- 3 LEDs (preferably in different colours)
- 3 Buttons (preferably in the same colours as the LEDs)
- 1 LCD
- 1 Buzzer
- 8 Resistors
- 25 Male-Male wires
- 4 Male-Female wires
- 1 light sensor
- 1 temperature/humidity sensor
- 1 ADC (preferable not bronze)
- 1 Breadboard
- 1 T-Cobbler
- 1 Raspberry Pi
Raspberry Pi Setup
The setup is flexible and will work as long as you have all the required sensors, LEDs and buttons connected
Note: to turn off the alarm, you have to repeat the randomly-generated pattern shown by the LEDs, by clicking on the buttons associated with that colour in the correct sequence
What the Web Application Will Look Like
Control panels will be automatically added whenever a device is successfully connected
You will be able to:
- View real-time sensor data
- Control the LEDs and buzzer
- Add, activate, deactivate and delete alarms
Install the Necessary Libraries in Each Device
Install the necessary libraries by running these commands in the terminal:
- sudo pip install ibmiotf
- sudo pip install eventlet
- sudo pip install pymongo
-
sudo pip install gpiozero
-
sudo pip install flask-socketio
-
sudo pip install Flask
Setup IBM Bluemix
1. Create a Bluemix account
2. Create a cloud foundry app
3. Go to the internet of things dashboard
4. Go to devices
5. Create a device type
6. Add as many devices as you need
7. Generate an API key for the web server application
8. Take note of all the credentials so you can use them in your devices and application
Setup Local MongoDB
1. Enter the mongo shell by running the $ mongo command in the terminal
2. Once you are in the shell, you will have to create a database called “db” by running the > use db command
3. Create a collection called “alarms” by running the > db.createCollection(‘alarms’) command
Code
web.py
- the application that runs on the web server (a dedicated rpi)
- you will have to add in your own Bleumix credentials
program.py
- the application that runs on all alarm clocks/devices
- you will have to change the pins to fit each device
- you will also have to add in your own Bluemix credentials
index.html
- the web interface (saved as a text file due to upload restrictions)
Changelog
23/8/2017 - Updated the program files to allow devices with no alarms set, tweaked other sections to provide more details