Project Description
‘Home de Manage’ – This is a low cost and effective home management system project that uses Raspberry pi, a few sensors, matt protocol and gmail’s SMTP server to take care of your home. I made this project because when I am not at home, I will be alerted when there is a fire in my kitchen, read room temperature on my phone and water my plants from anywhere in the world. I found out that MQTT is a better solution and decided to use it in this IoT project.
Step 1: Hardware and Software RequiredHardware:
Raspberry Pi or Arduino Uno (If you are using arduino, then check out how to get started with Node-RED and arduino boards at www.node-red.org and make sure your arduino has internet connectivity)
Female to Female Jumper wires - 9
SD card with Rasbian OS (not required when using arduino)
Relay Module
Temperature Sensor
Sofware:
Node-RED with NPM
MQTT dashboard app on the mobile phone
Email access
Step 2: Connection to InternetConnect your pi to the internet (via Wi-Fi or Ethernet) and install Node-RED (V O. 1 8. 4 is best) and npm on the pi by entering the following on the terminal:
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install nodered npm
Step 3: Pinoutraspberry pi
pin 11 -- fire alarm sensor
pin 12 -- relay module
pin 13 -- temperature sensor module
Step 4: The Node-RED Flow[{"id":"8216f9d2.1709a8", "type":"tab", "label":"home_management", "disabled":false, "info":"A simple flow for home management"}, {"id":"da69b5ce.11bd28", "type":"mqtt in", "z":"8216f9d2.1709a8", "name":"relay/nodered", "topic":"relay/nodered", "qos":"1", "broker":"57b749c7.b462e8", "x":135.07400512695312, "y":231.4940185546875, "wires":[["724c1dc1.e368e4"]]}, {"id":"724c1dc1.e368e4", "type":"rpi-gpio out", "z":"8216f9d2.1709a8", "name":"relay_board", "pin":"12", "set":"", "level":"0", "freq":"", "out":"out", "x":404, "y":224, "wires":[]}, {"id":"1a6cab93.46bfb4", "type":"function", "z":"8216f9d2.1709a8", "name":"temperature", "func":"msg.payload = msg.payload * 32 + 5 / 9 % 1 + ' degrees C';\nreturn msg;\n", "outputs":1, "noerr":0, "x":547, "y":406, "wires":[["6b181e17.c868b", "5b0dfcb1.d17284"]]}, {"id":"d7d6320e.7cdcc", "type":"rpi-gpio in", "z":"8216f9d2.1709a8", "name":"temperature_sensor", "pin":"13", "intype":"tri", "debounce":"500", "read":true, "x":142, "y":338, "wires":[["7b4e3908.d8cc78"]]}, {"id":"6b181e17.c868b", "type":"mqtt out", "z":"8216f9d2.1709a8", "name":"temp/nodered", "topic":"temp/nodered", "qos":"1", "retain":"", "broker":"57b749c7.b462e8", "x":749, "y":356, "wires":[]}, {"id":"5b0dfcb1.d17284", "type":"debug", "z":"8216f9d2.1709a8", "name":"", "active":true, "tosidebar":true, "console":false, "tostatus":false, "complete":"false", "x":744, "y":434, "wires":[]}, {"id":"7b4e3908.d8cc78", "type":"trigger", "z":"8216f9d2.1709a8", "op1":"true", "op2":"false", "op1type":"bool", "op2type":"bool", "duration":"-5", "extend":false, "units":"s", "reset":"", "bytopic":"all", "name":"", "x":343, "y":379, "wires":[["1a6cab93.46bfb4"]]}, {"id":"457e4ce7.6c4a94", "type":"rpi-gpio in", "z":"8216f9d2.1709a8", "name":"fire_alarm", "pin":"11", "intype":"tri", "debounce":"25", "read":false, "x":202.00799560546875, "y":104.98699951171875, "wires":[["1883c317.5a452d", "be1558c5.88eab8"]]}, {"id":"be1558c5.88eab8", "type":"e-mail", "z":"8216f9d2.1709a8", "server":"smtp.gmail.com", "port":"587", "secure":false, "name":"jonathangerard538@yahoo.com", "dname":"fire_alarm", "x":646, "y":97, "wires":[]}, {"id":"1883c317.5a452d", "type":"mqtt out", "z":"8216f9d2.1709a8", "name":"alarm/nodered", "topic":"alarm/nodered", "qos":"1", "retain":"", "broker":"57b749c7.b462e8", "x":602, "y":163, "wires":[]}, {"id":"57b749c7.b462e8", "type":"mqtt-broker", "z":"", "name":"", "broker":"test.mosquitto.org", "port":"1883", "clientid":"1354u27", "usetls":false, "compatmode":true, "keepalive":"60", "cleansession":true, "willTopic":"", "willQos":"0", "willPayload":"", "birthTopic":"", "birthQos":"0", "birthPayload":""}]
Copy and paste the above JSON code into your flow(import the flow using Node-RED clip board)
Step 5: AppsDownload the MQTT dashboard app on your mobile phone and for quick access to your email, its better to download the gmail to yahoo mail app.
Step 6: Final TouchNow you are all set.
Just select deploy button at the top right corner of the node-red. Open the debug console. You will see temperature messaged being displayed every 5 seconds. The readings can also been in the dashboard’s ‘subscribe’ tab. Use the topic temp/nodered the connect and use test mosquitto.org:1883 as the broker. You can change the device ID by double clicking on the MQTT nodes. Do not forget to change your email credentials in the email node. Use topic alarm / nodered to get the state. If state is 1, it means the kitchen is on fire. Plants can be watered by connecting a sprinkler or water pump to the relay module. Add a switch to your ‘publish’ tab in your MQTT dashboard. Use topic relay/nodered and use on-payload as 1 and off-payload 0.
Comments