Garage Door Monitor and Opener
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
You are viewing an older revision! See the latest version
Homepage
This project is intended to work on the DISCO-L475VG-IOT01A from ST Microelectronics It implements a simple actuator to drive a relay to simulate pushing the "open" button on older style garage doors which do not use a rolling code interface.
The system is designed to be mounted over the door so that the on board time of flight sensor can be used to detect if the door is open or closed.
The system also monitors temperature, humidity and barometric pressure.
Prerequisites: DISCO-L475G-IOT01A https://os.mbed.com/platforms/ST-Discovery-L475E-IOT01A/
Seeed Studio Grove Relay module https://www.seeedstudio.com/Grove-Relay.html
Seeed Studio Grove cable, I used this one: https://www.seeedstudio.com/Grove-4-pin-Male-Jumper-to-Grove-4-pin-Conversion-Cable-5-PCs-per-Pack.html
You will also need a Pelion developers account.
I suggest you first use the Pelion quick state to become familiar with Pelion Device Management.
For my web interface I am running node-red under Ubuntu in an EC2 instance on AWS. This can run for 12 month within the constraints of their free tier. There are good tutorials for installing node-red on AWS.
You will also need to install: sudo npm -g node-red-dashboard sudo npm -g node-red-contrib-mbed-cloud sudo npm -g node-red-contrib-moment
After starting node-red import this flow as a starting point: [{"id":"f6c24bc1.997098","type":"tab","label":"Garage Monitor","disabled":false,"info":""},{"id":"efeb3c0a.b8775","type":"list-devices","z":"f6c24bc1.997098","config":"e02cb4da.ec7828","state":"registered","stateEq":"$eq","x":190,"y":140,"wires":"3826b720.0ba9a8","c840e5a7.1c4fb8"},{"id":"3826b720.0ba9a8","type":"function","z":"f6c24bc1.997098","name":"Get list of devices to use in node-red-dashboard+","func":"msg.options = new Array(msg.payload.data.length);\nvar numConnectedDevices = 0;\nfor(var i = 0; i < msg.options.length; i++ ){\n msg.options[i] = msg.payload.data[i].id;\n msg.serialNumber[i] = msg.payload.data[i].serialNumber;\n numConnectedDevices++;\n}\nglobal.set(\"numConnectedDevices\", numConnectedDevices);\nreturn msg;","outputs":1,"noerr":0,"x":301.7301025390625,"y":201.68252563476562,"wires":"e4e0f96.26ae608"},{"id":"3dbd9f37.08aad","type":"function","z":"f6c24bc1.997098","name":"Set base num of faulty devices","func":"global.set(\"numFaultydevices\",0);\nreturn msg;","outputs":1,"noerr":0,"x":501.61900329589844,"y":63.52384090423584,"wires":]]},{"id":"f9698ccc.ca36b","type":"change","z":"f6c24bc1.997098","name":"","rules":[{"t":"set","p":"deviceId","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"deviceId","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":340,"wires":[["a02e47f4.955208","d9cc4692.caa818","2c2849e6.18c6d6","f97e4284.6e99c","1154584c.eebe08","e1e16918.9f6a28"},{"id":"e4e0f96.26ae608","type":"ui_dropdown","z":"f6c24bc1.997098","name":"","label":"","tooltip":"","place":"Select option","group":"86661654.040028","order":2,"width":"5","height":"1","passthru":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":164.555419921875,"y":264.3810119628906,"wires":"f9698ccc.ca36b"},{"id":"547aa547.66406c","type":"ui_button","z":"f6c24bc1.997098","name":"","group":"86661654.040028","order":1,"width":"1","height":"1","passthru":false,"label":"Find","tooltip":"","color":"","bgcolor":"","icon":"","payload":"123456","payloadType":"str","topic":"","x":146.11898040771484,"y":65.23809432983398,"wires":"3dbd9f37.08aad","efeb3c0a.b8775"},{"id":"a02e47f4.955208","type":"change","z":"f6c24bc1.997098","name":"Get Humidity resource","rules":[{"t":"set","p":"resourceURI","pt":"msg","to":"/3304/0/5700","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":807.2655563354492,"y":146.5234375,"wires":"198fa1dc.9ce32e","5ee489cf.2b81d8"},{"id":"198fa1dc.9ce32e","type":"add-resource-subscription","z":"f6c24bc1.997098","config":"e02cb4da.ec7828","deviceId":"","resourceURI":"","x":1067.0276260375977,"y":122.33298015594482,"wires":"ac23813a.c343a","ce7abd12.54f28"},{"id":"5ee489cf.2b81d8","type":"get-resource-value","z":"f6c24bc1.997098","config":"e02cb4da.ec7828","deviceId":"","resourceURI":"","x":1043.0275039672852,"y":178.33292865753174,"wires":"ac23813a.c343a","ce7abd12.54f28"},{"id":"ce7abd12.54f28","type":"ui_gauge","z":"f6c24bc1.997098","name":"","group":"86661654.040028","order":8,"width":"2","height":"3","gtype":"gage","title":"Humidity","label":"%","format":"","min":0,"max":"100","colors":["#ff0000","#e6e600","#00ff80"],"seg1":"10","seg2":"40","x":1332.6941776275635,"y":174.6662654876709,"wires":[]},{"id":"d9cc4692.caa818","type":"change","z":"f6c24bc1.997098","name":"Get Temperature Resource","rules":[{"t":"set","p":"resourceURI","pt":"msg","to":"/3303/0/5700","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":788.2575988769531,"y":240.5117678642273,"wires":"d4def37e.3cffd","8674d9c1.da7868"},{"id":"b21a6f4b.a723d","type":"ui_chart","z":"f6c24bc1.997098","name":"","group":"86661654.040028","order":7,"width":"4","height":"3","label":"","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"7","removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1327.4959831237793,"y":263.27369260787964,"wires":]]},{"id":"d4def37e.3cffd","type":"add-resource-subscription","z":"f6c24bc1.997098","config":"e02cb4da.ec7828","deviceId":"","resourceURI":"","x":1056.4957656860352,"y":219.94032192230225,"wires":[["b21a6f4b.a723d","b760f3cb.de7f1"},{"id":"8674d9c1.da7868","type":"get-resource-value","z":"f6c24bc1.997098","config":"e02cb4da.ec7828","deviceId":"","resourceURI":"","x":1033.4124603271484,"y":266.6903190612793,"wires":"b21a6f4b.a723d","b760f3cb.de7f1"},{"id":"b760f3cb.de7f1","type":"ui_gauge","z":"f6c24bc1.997098","name":"","group":"86661654.040028","order":6,"width":"2","height":"3","gtype":"gage","title":"Temperature","label":"C","format":"","min":0,"max":"45","colors":["#4295fb","#00d000","#ca3838"],"seg1":"15","seg2":"30","x":1347.3289413452148,"y":220.41211128234863,"wires":[]},{"id":"ac23813a.c343a","type":"ui_chart","z":"f6c24bc1.997098","name":"","group":"86661654.040028","order":9,"width":"4","height":"3","label":"","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"7","removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1310,"y":120,"wires":]]},{"id":"f97e4284.6e99c","type":"change","z":"f6c24bc1.997098","name":"Get Pressure Resource","rules":[{"t":"set","p":"resourceURI","pt":"msg","to":"/3323/0/5700","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":500,"wires":[["9662e4f1.5423c8","8a1835ca.7f2fe8"},{"id":"9662e4f1.5423c8","type":"add-resource-subscription","z":"f6c24bc1.997098","config":"e02cb4da.ec7828","deviceId":"","resourceURI":"","x":1130,"y":480,"wires":"e2417d7a.b65fa","d5153793.0abc28"},{"id":"8a1835ca.7f2fe8","type":"get-resource-value","z":"f6c24bc1.997098","config":"e02cb4da.ec7828","deviceId":"","resourceURI":"","x":1105.1548614501953,"y":526.178551197052,"wires":"e2417d7a.b65fa","d5153793.0abc28"},{"id":"d5153793.0abc28","type":"ui_gauge","z":"f6c24bc1.997098","name":"","group":"86661654.040028","order":10,"width":"2","height":"3","gtype":"gage","title":"Pressure","label":"mb","format":"","min":"900","max":"1020","colors":["#ff0000","#00ff00","#ffff80"],"seg1":"1007","seg2":"1014","x":1404.0081157684326,"y":527.6783652305603,"wires":[]},{"id":"e2417d7a.b65fa","type":"ui_chart","z":"f6c24bc1.997098","name":"","group":"86661654.040028","order":11,"width":"4","height":"3","label":"","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"30","removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1394.8969535827637,"y":479.4560127258301,"wires":]]},{"id":"1154584c.eebe08","type":"change","z":"f6c24bc1.997098","name":"Get Distance Resource","rules":[{"t":"set","p":"resourceURI","pt":"msg","to":"/3330/0/5700","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":600,"wires":[["f42aa00e.8bcec","43f4db4d.d0ae34","4f71dc94.336aa4"},{"id":"f42aa00e.8bcec","type":"add-resource-subscription","z":"f6c24bc1.997098","config":"e02cb4da.ec7828","deviceId":"","resourceURI":"","x":1127.2461166381836,"y":574.1068844795227,"wires":"b96f3555.61cd28","501679d0.409c68","26bd4b5.bc58cb4"},{"id":"43f4db4d.d0ae34","type":"get-resource-value","z":"f6c24bc1.997098","config":"e02cb4da.ec7828","deviceId":"","resourceURI":"","x":1104.1628112792969,"y":620.8568816184998,"wires":"b96f3555.61cd28","501679d0.409c68","26bd4b5.bc58cb4"},{"id":"501679d0.409c68","type":"ui_gauge","z":"f6c24bc1.997098","name":"","group":"86661654.040028","order":12,"width":"2","height":"3","gtype":"gage","title":"Distance","label":"mm","format":"","min":"30","max":"2000","colors":["#ff0000","#00ff00","#ffff80"],"seg1":"500","seg2":"1000","x":1540,"y":620,"wires":[]},{"id":"b96f3555.61cd28","type":"ui_chart","z":"f6c24bc1.997098","name":"","group":"86661654.040028","order":13,"width":"4","height":"3","label":"","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"30","ymax":"2000","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1490,"y":580,"wires":]]},{"id":"4b20967f.a08b08","type":"ui_text_input","z":"f6c24bc1.997098","name":"","label":"Password","tooltip":"","group":"86661654.040028","order":3,"width":"6","height":"1","passthru":true,"mode":"password","delay":"0","topic":"","x":960,"y":400,"wires":[["f62a00e8.42fa2"},{"id":"95aac770.56a318","type":"set-resource-value","z":"f6c24bc1.997098","config":"e02cb4da.ec7828","deviceId":"","resourceURI":"","payload":"","x":1390,"y":380,"wires":]]},{"id":"2c2849e6.18c6d6","type":"change","z":"f6c24bc1.997098","name":"Set Password URI","rules":[{"t":"set","p":"resourceURI","pt":"msg","to":"/3201/0/5853","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":340,"wires":[["ae1e9a2f.8a7238"},{"id":"ae1e9a2f.8a7238","type":"function","z":"f6c24bc1.997098","name":"password flow set","func":"flow.set(\"polluri\", msg.resourceURI);\nflow.set(\"deviceId\", msg.deviceId);\nreturn msg;","outputs":1,"noerr":0,"x":990,"y":340,"wires":"f62a00e8.42fa2"},{"id":"f62a00e8.42fa2","type":"function","z":"f6c24bc1.997098","name":"pge2","func":"msg.resourceURI = flow.get(\"polluri\");\nmsg.deviceId = flow.get(\"deviceId\");\nif(msg.deviceId != msg.payload)\nreturn msg;","outputs":1,"noerr":0,"x":1190,"y":380,"wires":"95aac770.56a318"},{"id":"26bd4b5.bc58cb4","type":"function","z":"f6c24bc1.997098","name":"","func":"dis = msg.payload;\nif(dis < 800)\n msg.payload = \"OPEN\"\n else\n msg.payload = \"CLOSED\"; \n\nreturn msg;","outputs":1,"noerr":0,"x":1330,"y":680,"wires":"3b58bb9e.f6d304"},{"id":"3b58bb9e.f6d304","type":"ui_text","z":"f6c24bc1.997098","group":"86661654.040028","order":4,"width":"3","height":"1","name":"","label":"","format":"","layout":"row-left","x":1470,"y":680,"wires":[]},{"id":"273c54d1.093a0c","type":"ui_text","z":"f6c24bc1.997098","group":"86661654.040028","order":5,"width":"3","height":"1","name":"","label":"","format":"","layout":"row-spread","x":1750,"y":740,"wires":[]},{"id":"4f71dc94.336aa4","type":"change","z":"f6c24bc1.997098","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$now()","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1160,"y":740,"wires":"f5a2cf3b.e943c"},{"id":"f5a2cf3b.e943c","type":"moment","z":"f6c24bc1.997098","name":"","topic":"","input":"payload","inputType":"msg","inTz":"ETC/GMT","adjAmount":"8","adjType":"hours","adjDir":"subtract","format":"object","locale":"C","output":"payload","outputType":"msg","outTz":"ETC/GMT","x":1400,"y":740,"wires":"213bf538.b03b9a","86f783bd.ee492","ccae8cf1.d3f58"},{"id":"213bf538.b03b9a","type":"function","z":"f6c24bc1.997098","name":"","func":"tmp = msg.payload;\nif(tmp.minutes > 9)\nmout = tmp.hours + \":\" + tmp.minutes;\nelse\nmout = tmp.hours + \":0\" + tmp.minutes;\nmsg.payload = mout;\nreturn msg;","outputs":1,"noerr":0,"x":1590,"y":740,"wires":"273c54d1.093a0c"},{"id":"e1e16918.9f6a28","type":"change","z":"f6c24bc1.997098","name":"Get Serial Number","rules":[{"t":"set","p":"resourceURI","pt":"msg","to":"/3/0/2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":920,"wires":"173f1a0a.057826"},{"id":"173f1a0a.057826","type":"get-resource-value","z":"f6c24bc1.997098","config":"e02cb4da.ec7828","deviceId":"","resourceURI":"","x":950,"y":920,"wires":"374ecb83.ea3924"},{"id":"374ecb83.ea3924","type":"ui_text","z":"f6c24bc1.997098","group":"86661654.040028","order":14,"width":0,"height":0,"name":"","label":"SN:","format":"","layout":"row-spread","x":1180,"y":920,"wires":[]},{"id":"86f783bd.ee492","type":"delay","z":"f6c24bc1.997098","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1420,"y":840,"wires":"4f71dc94.336aa4"},{"id":"c840e5a7.1c4fb8","type":"debug","z":"f6c24bc1.997098","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":430,"y":140,"wires":[]},{"id":"ccae8cf1.d3f58","type":"debug","z":"f6c24bc1.997098","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1610,"y":700,"wires":[]},{"id":"e02cb4da.ec7828","type":"cloud-config","z":"","host":"https://api.us-east-1.mbedcloud.com"},{"id":"86661654.040028","type":"ui_group","z":"","name":"Device Info","tab":"5ea569ba.7a6a98","order":1,"disp":true,"width":"6","collapse":false},{"id":"5ea569ba.7a6a98","type":"ui_tab","z":"","name":"Garage Monitor","icon":"dashboard","order":1,"disabled":false,"hidden":false}]