Updated for 2019 China-US Young Maker Competition
The Remote Home Monitor will encourage you to upgrade your home to a smarter and more secure one, offering safety measures, protection, monitoring and key indicators for later improvement using the Nova Cellular USB Modem and a Raspberry Pi.
This project is not about just turning ON/OFF a light from a smart phone. It is focused on integrating a network of sensors, nicely presenting the data in a dashboard, monitoring and controlling all the features with a simple and friendly user interface, accessible from a web browser or a touch screen console at home.
How it worksSimple!. An array of sensors are connected to the Raspberry Pi, data is collected and stored in the cloud using the NOVA, the most recent data is re-routed to a Webhook that will help presenting the data nicely on a web page. Also, the system is capable of sending email alerts on critical events, like basement flooding risk.
Advantages
- Low initial cost: each component or sensor can be made or bought for a low cost, avoiding the need of expensive "smart appliances".
- Flexibility: nodes and sensors compatible with Arduino will work, and can be tuned to your needs. You are not limited only to the features I have provided. Also the web app can be easily expanded with more Widgets.
- Reliability: with the Nova Cellular USB Modem and the Raspberry Pi paired together with a rechargeable battery implementation, an impressive up-time and an extra redundancy layer can be added making this a reliable and independent monitoring system when Internet is not working, during power outages and so on.
- Low maintenance cost: data sent is lightweight and the frequency at which is triggered can be adjusted, which makes this inexpensive to maintain.
The current implementation is very simple and tries to explain how easy it is to build a remote monitoring system like this.
The features included in this project:
- Tracks the power consumption of your most important appliances like HVAC, Oven, etc. Implemented with a non-invasive current sensor attached to a power cord.
- Monitors the stove status: using the same current sensor, have peace of mind knowing you didn't leave the stove ON.
- Sump water level meter: water level is measured with an ultrasonic distance sensor (HC-SR05), measuring the distance between transceiver and the fluid. I used the same concept in the Smart Watering System.
- Sends an email alert when the Sump Water Level is critical.
- Sensor's data can be monitored using a web browser -compatible with most web browsers-.
- See all the sensor's data in a Touch Display at home using Chromium web browser on the Raspberry Pi 3.
- The web browser doesn't need to be refreshed to see the latest data in the Dashboard (this is acomplished using jQuery, Javascript and CSS)
Three simple widgets were designed for the dashboard which visually change depending on their status and were easily adapted using jQuery, JavaScript and CSS.
Stove Widget
Displays the apparent power consumption and the status of the Stove. When it is detected to be ON
, the stove will be visualized a "little hot" with a status in red.
Data for this widget is simulated with the CT sensor connected to a power cord connected to an appliance. Due to local regulations, I can't tap the stove or electric main panel.
Sump
Water level changes color according to its level. Also displays the status of the sump pump.
Pump status (ON/OFF) is simulated in the circuit with a push-button.
Temperature
Displays the room temperature in °F and °C. Temperature color changes gradually from blue to red (cool to warm), also the thermometer will adjust its thread level according to the temperature.
The temperature color change was accomplished changing the font-color
with a function in JavaScript that does color mixing gradually.
Step 1: Configure your raspberry PiWe'll assume that you already have a Raspberry Pi working and connected to the internet, so the first thing required is to update your software in Raspbian.
Open a terminal and run the following commands
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
Install the python Dev libraries
sudo apt-get install python-dev python-pip
Upgrade the GPIO and PIP libraries to the latest version
sudo pip install --upgrade RPi.GPIO
sudo pip install pip --upgrade
Install the Hologram SDK and make sure the NOVA works by following these instructions.
curl -L hologram.io/python-install | bash
Step 2: Build the hardwareBuild the circuit as shown in the Fritzing diagram (attached in PDF too).
Important things to consider:
- For demo purposes, a Raspberry Pi 3 was used with a touch display (optional).
- the Red jumper wires in the diagram, represent the 5V connections.
- the Orange jumper wires in the diagram represent the 3.3V connections.
- There are two voltage dividers that will convert 5V outputs from the sensors to 3.3V.
- A 3.3k ohm resistor was used as a Burden Resistor in order to maximize the sensibility of the CT sensor.
The Burden Resistor value must be adjusted in relation to the maximum AC current value expected.Step 3: Programming the Raspberry Pi
Paste the Python script to a file home_monitor.py
on your Raspberry Pi and make it executable
$ chmod +x home_monitor.py
$ ls -l home_monitor.py
-rwxr-xr-x 1 pi pi 8908 Jan 5 21:29 home_monitor.py
Test the script with variable DEBUG = 1
, it should print all the readings of the sensors without sending the data
sudo ./home_monitor.py
If everything is correct, the sensors' data is displayed in the console output, including the Payload that will be sent to the Hologram Cloud in JSON format.
We are now ready to send the data to the Hologram Cloud, first on the python script, change the debug variable to DEBUG = 0
and save the changes, plug in the NOVA, wait for the blinking lights and run the program again.
This time, the only output from the console should be a "Message sent successfully".
Data should now be visible in the Hologram console in JSON format:
{
"dtUTC":"2018-01-09T00:47:37.235216Z",
"iRMS":0.01,
"apparentPower":1.21,
"stoveStatus":"OFF",
"sumpLevel":69,
"sumpPump":"OFF",
"tempC":25.0,
"tempF":77.0
}
Step 4: Create a Route for the Dashboard dataA home monitor is not complete without a dashboard, right?. In that order, we'll use the Hologram Data Router, to re-send the data collected by the Hologram Cloud, to a webhook that will keep the most recent data and will present it nicely using PHP
/HTML
/CSS
and jQuery
.
Create a new route, select Custom Webhook URL (Your Own App)
, select the topic power-usage
, assign a ROUTE NICKNAME
and a WEBHOOK KEY
of your choice. Type the Destination URL
where you plan to put the webhook receiver PHP <script attached>.
The topics
can be personalized in the phyton script home_monitor.py
by changing the parameters of the sendMessage
function that sends the main JSON values:
response_code = hologram.sendMessage(json, topics = ["power-usage"])
With some minor adjustments to the webhook receiver PHP script, the Advanced Webhook Builder may also be used to send the data to be published in the dashboard.Step 5: Deploy the Dashboard files
This may not be an easy step for some as this requires a PHP web server, but source files are provided anyway with enough documentation and instructions.
Dashboard
The home monitor dashboard displays the status of the different sensors connected to the Remote Home Monitor in a nice and friendly way. It gets the information published in JSON format using jQuery.
The dashboard code requires the Dashboard external CSS
file. PHP is not mandatory for the dashboard to work -the php code could be removed-.
The address of the script that delivers the Hologram Payload in JSON format should be adjusted in case it is placed in a different path
$.get( "./publish_payload_json.php?t=t", function( data ) {
Webhook Receiver
Receives the webhook data from the Hologram Router
and stores the payload in a .txt
file in its original format.
Copy the same WEBHOOK KEY
assigned to the route in the Hologram router to the $hologram_wh_Key
variable in the PHP script.
$hologram_wh_Key = "webhookkey1234567890"; // Hologram Webhook key
Publish payload in JSON
Decodes Hologram payload previously saved in a .txt
file and publishes it in JSON format. JSON data is later used by the Dashboard to present the data with jQuery.
We don't want to let our basement flood right?. What if the Hologram Cloud sends an email when the sump water level is critical?, lets say 90% or more?. We will use this time the Hologram Email Data Router:
Create a new route, select Email
, select or type the topic email-sump-level
, fill in the ROUTE NICKNAME
, SUBJECT
and EMAIL RECIPIENTS
of your choice, then type the following in the EMAIL MESSAGE
field:
Sump water level is at <<decdata.sumpLevel>>%, sump pump is <<decdata.sumpPump>>
Things should look similar to the image below
If everything is working correctly, when the sump water level is 90% or more, the python script should show a message with the topic name:
email-sump-level: Message sent successfully
and we should see a message in the Hologram Message Console
with the same topic name: email-sump-level
and the email route triggered:
{
"dtUTC":"2018-01-09T01:12:16.419195Z",
"sumpLevel":92,
"sumpPump":"OFF"
}
and an email from the Hologram Cloud
:
The email topic
can be personalized in the phyton script home_monitor.py
by changing the parameters of the sendMessage
function that sends the jsonEmail data
response_code = hologram.sendMessage(jsonEmail, topics = ["email-sump-level"])
Step 7 (optional): Enjoy a Touch Display dashboardTo enjoy the Remote Home Monitor Dashboard on a nice Touch Display, Chromium web browser is required, since it is one of the few capable of handling the adjustments in the CSS styles I've used.
Select the Add / Remove Software
Then type "Chromium" in the search, once found, select it and click the OK button to proceed with the installation.
Once the Chromium web browser is installed, Create a shortcut in the desktop pointing to the Home Monitor Dashboard by creating a new text file called home_monitor.desktop
in the /home/pi/Desktop/
directory.
It should contain the following (assign the correct web address to your dashboard):
[Desktop Entry]
Name=HomeMonitor Dashboard
TryExec=/usr/bin/x-www-browser
Exec=x-www-browser http://luislab.com/path/dashboard.php
Icon=rpi
Terminal=false
Type=Application
Categories=Application;Network;
StartupNotify=true
Comment[en_US]=Remote Home Monitor with Hologram Nova
the shortcut should be visible in the desktop, and enjoy...
The Home Remote Monitoring could be expanded with many more features, here are some ideas:
- Monitoring status of doors: find when your doors are open/close (main door, garage, back door).
- Home surveillance / Intruder alert: cameras, motion detectors, vibration, noise and pressure sensors.
- Water flow sensor: allows to detect a water leak -very useful when not at home-.
- Other Sensors: smoke/fire.
- Video door bell.
- Control of relays/switches: to activate/deactivate blinds, fans, lights, home appliances, etc.
- Control of valves: to activate/deactivate an irrigation system.
- Save/visualize important information -like he power consumption- this is very helpful analyze trends, to add automatic features and to save money.
- Send Important alerts: via email, text message and other methods.
Comments