-
1Install Raspbian, boot Pi, and download files for this project to your Pi
Download Raspbian, and use Balena Etcher or equivalent to get Raspberry Pi runnning. Once it is running, go and download the files for this project. Create a folder on the Desktop called "HMS", and place all of the files in "Python Programs" into this folder. This is so that the paths for the files will align with the ones that I used for running the cron jobs/ in the rc.local file. If you know what you are doing as far as running cron jobs, or editing the etc rc.local file then putting the files in the desktop folder is unnecessary.
-
2Attach the BME680 Sensor
This task required soldering female headers to the BME680, and then connecting wires from these headers to their appropriate pins on the Raspberry Pi. In order, these pins are 1,3,5, 7, and 9. These specific pins were selected as they provide the sensor both power and I2C communication with the Raspberry Pi.
-
3Test BME680
Run a program to be sure the sensor is outputting data correctly. Google to find programs from the manufacturer of the product to test it.
-
4Attach UPS HAT
To monitor for power outages, an uninterruptable power supply (UPS) was added to the Raspberry Pi. Due to the UPS being what is known as a HAT, it connects to the Raspberry Pi via the GPIO pins without disturbing their capabilities.
-
5Use MySQL to create databases
If you are unfamiliar with MySQL, as I was, there are a multitude of resources online for how to create databases using MySQL. The reason we are creating databases is to have a place to store the information from the BME680 as well as the information from the UPS, and light usage. You WILL need to edit the python programs to reflect the databases and passwords you have created.
-
6Install Apache Server
run the following command
sudo apt install apache2 -y
then run:
hostname -I
This should give you the ip address of your device. Go to the ip address listed using a webbrowser, and you should see the apache default page. The file for this page (apache server index file) is what we will replace with the one I have included in the downloads section of this project.
-
7Attach a light switch and relay to the system
Use a light switch, and run one side of it to GND, and another to input 20 on the Pi. Then attach a relay to GPIO 21.
The idea in the code is that the light switch signals the pi that it has been switched, and this causes the Pi to flip the relay causing the lights to turn on. Through this methodology we can start a timer when the switch is flipped in order to determine how long the lights are on. This information is then sent to a MySQL database.
-
8Attach Smoke Alarm
Attach the smoke sensor to input 26 on the Pi's GPIO. The relay used to turn on the lights when the light switch is flipped is further utilized by the code for the fire alarm. It overrides whatever state the light switch is in, in order to turn on the lights if smoke is detected. It also changes the status of GPIO 12 which causes the door to unlock.
-
9Attach electromagnetic lock to relay
This system, upon reflection, would likely benefit from using a deadbolt lock that runs with a motor instead of an electromagnetic lock, due to the electromagnetic lock requiring a consistent power source in order to remain engaged.
However, for its current configuration, this step includes running the electromagnetic lock to one of the solid state relays. The relay being attached to GPIO 12.
-
10Test the included python programs
It is likely that you will need to add or change some information in the included python programs so that they match your specific set up. Such as the mysql tables the information pulled from the sensors are being placed into.
You will also need to put your phone number as well as the necessary email information for achieving the text message alerts. Inside the code there are comments that will aid you in doing this properly.
****Note, when this project was completed, gmail was still allowing this method for using a gmail account to send texts through. This no longer seems to be the case, so it is likely you will need to create an email account through a different provider and change the code accordingly.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.