Skip to content

Presentation slides plus build at home docs. #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added IoT & Edge Analytics Home Setup.docx
Binary file not shown.
Binary file added Louis Frolio/DevNet Create IoT Presentation.pptx
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions Louis Frolio/create at home docs/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions Louis Frolio/scripts/nodered/fullsolution.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"id":"170f4113.a11aef","type":"tab","label":"Working Solution DevNet Create 2018","disabled":false,"info":""},{"id":"a0941111.6ca848","type":"mqtt in","z":"170f4113.a11aef","name":"dietpi-1 mqtt lux","topic":"cc2650/temp/546c0e53122d","qos":"0","broker":"8037e8c5.8bd49","x":140,"y":200,"wires":[["727a1a51.58f6dc","fbbcad8f.00ccf"]]},{"id":"da8854f9.b99ab8","type":"switch","z":"170f4113.a11aef","name":"Alarm Status","property":"payload.json_data.lux","propertyType":"msg","rules":[{"t":"gt","v":"150","vt":"str"},{"t":"btwn","v":"101","vt":"num","v2":"150","v2t":"num"},{"t":"lte","v":"100","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":670,"y":200,"wires":[["110040a6.1fc47f"],["6f0a713d.0e5e28"],["8470bff7.2e19e8"]]},{"id":"727a1a51.58f6dc","type":"json","z":"170f4113.a11aef","name":"","property":"payload","action":"obj","pretty":false,"x":290,"y":200,"wires":[["e3b7a99.7beeed8","c5bab3ab.9cee28","d3b3e3ae.d54bc8"]]},{"id":"110040a6.1fc47f","type":"exec","z":"170f4113.a11aef","command":"sudo python /home/pi//trafficlight.py red true","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Status: ALARM","x":860,"y":120,"wires":[["22fac8dc.fa6638"],["a4638830.1afa5"],[]]},{"id":"8470bff7.2e19e8","type":"exec","z":"170f4113.a11aef","command":"sudo python /home/pi//trafficlight.py green true","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Status: NORMAL","x":870,"y":280,"wires":[["da9a9d49.bbd768"],["cff89d7a.006238"],[]]},{"id":"22fac8dc.fa6638","type":"debug","z":"170f4113.a11aef","name":"redstdout","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1040,"y":60,"wires":[]},{"id":"a4638830.1afa5","type":"debug","z":"170f4113.a11aef","name":"redstderror","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1050,"y":100,"wires":[]},{"id":"da9a9d49.bbd768","type":"debug","z":"170f4113.a11aef","name":"greenstdout","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1050,"y":240,"wires":[]},{"id":"cff89d7a.006238","type":"debug","z":"170f4113.a11aef","name":"greenstderr","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1050,"y":280,"wires":[]},{"id":"314fdf39.d45118","type":"pythonshell in","z":"170f4113.a11aef","name":"","pyfile":"/home/pi/bluepy/bluepy/cc2650.py","virtualenv":"","continuous":true,"x":140,"y":100,"wires":[["232716f8.4e9b62"]]},{"id":"232716f8.4e9b62","type":"debug","z":"170f4113.a11aef","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":350,"y":100,"wires":[]},{"id":"e3b7a99.7beeed8","type":"function","z":"170f4113.a11aef","name":"Time Series Format","func":"var data = msg.payload;\n\nfunction generateRandomId() {\n return Math.round (Math.random()*(1000000 - 1)+1);\n}\n\nvar randomId = generateRandomId();\n\nmsg.payload = {\n id: randomId,\n tstamp: {$data:(new Date()).getTime()},\n json_data : {\n lux:data.lux,\n ambient_temp:data.ambient_temp,\n humidity:data.humidity\n }\n};\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":200,"wires":[["da8854f9.b99ab8","a26c3186.8456","8c61f407.61ffd8"]]},{"id":"6f0a713d.0e5e28","type":"exec","z":"170f4113.a11aef","command":"sudo python /home/pi//trafficlight.py yellow true","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Status: WARNING","x":870,"y":200,"wires":[["5e60abec.bad944"],["31f3890f.84504e"],[]]},{"id":"31f3890f.84504e","type":"debug","z":"170f4113.a11aef","name":"yellowstderr","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1050,"y":200,"wires":[]},{"id":"5e60abec.bad944","type":"debug","z":"170f4113.a11aef","name":"yellowstdout","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1050,"y":160,"wires":[]},{"id":"a26c3186.8456","type":"timeseries out","z":"170f4113.a11aef","timeseries":"d6bddfb6.0d3778","name":"","baseTimeSeriesTable":"sensor","x":750,"y":340,"wires":[]},{"id":"fbbcad8f.00ccf","type":"debug","z":"170f4113.a11aef","name":"Raw MQTT Data","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":150,"y":320,"wires":[]},{"id":"8c61f407.61ffd8","type":"debug","z":"170f4113.a11aef","name":"Time Series Formated Data","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":740,"y":380,"wires":[]},{"id":"c5bab3ab.9cee28","type":"debug","z":"170f4113.a11aef","name":"Raw Data","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.lux","x":380,"y":320,"wires":[]},{"id":"36c264e7.f69f3c","type":"cloudant out","z":"170f4113.a11aef","name":"Insert into Cloudant (Cloud)","cloudant":"27796c38.f5fc3c","database":"devnetcreate2018","service":"_ext_","payonly":false,"operation":"insert","x":1500,"y":820,"wires":[]},{"id":"874ea777.2ee5a8","type":"function","z":"170f4113.a11aef","name":"Lux: Z-Score","func":"//initialize a list that stores the last n values for the electric current by using the voltage parameter. In stream computing, this list is called a \"sliding window of fixed size.\" \nvar aggwindow = context.get('aggwindow')||[];\n\n//add values to that lis\naggwindow.push(msg.payload.lux); \n\n//Continue adding values to the list until we have exceeded 30 values, which defines the size of our sliding window. \nif (aggwindow.length> 3) {\n \n //To compute z-score, we need the mean and the standard deviation.\n sum = aggwindow.reduce((a,b)=>a+b,0);\n n = aggwindow.length;\n mean = sum/n;\n sd = Math.sqrt(aggwindow.map(x=>Math.pow(mean-x,2)).reduce((a,b)=>a+b,0));\n \n // get rid of the oldest element in the list, which resembles a LIFO. \n aggwindow.shift();\n \n //Perform Z-Score Calculation. Add a small value to standard deviation because the standard deviation can become zero, which is mathematically undefined\n msg.zscore = (mean-msg.payload.lux)/(sd+0.0001)\n}\n\n//store this list to a global context to preserve it over individual message lifetimes\ncontext.set('aggwindow',aggwindow);\n\n\n//output voltage and zscore\nmsg.payload = {\n [(\"zscore\")]:Math.abs(msg.zscore)\n }\n\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":440,"wires":[["c9a2c6cb.b5735","a7f099eb.0d99e","96d7b6d2.125578"]]},{"id":"c9a2c6cb.b5735","type":"debug","z":"170f4113.a11aef","name":"Z-Score","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.zscore","x":740,"y":440,"wires":[]},{"id":"fabdc6fd.2bb9f8","type":"debug","z":"170f4113.a11aef","name":"Average Lux","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.lux","x":750,"y":500,"wires":[]},{"id":"d3b3e3ae.d54bc8","type":"switch","z":"170f4113.a11aef","name":"","property":"topic","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":250,"y":440,"wires":[["5728dc9e.c64734","874ea777.2ee5a8","19f287b9.b2c73","3209e498.ac7844"]]},{"id":"5728dc9e.c64734","type":"debug","z":"170f4113.a11aef","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.lux","x":220,"y":520,"wires":[]},{"id":"19f287b9.b2c73","type":"smooth","z":"170f4113.a11aef","name":"Lux: Moving Mean","property":"payload.lux","action":"mean","count":"3","round":"","mult":"multi","x":490,"y":500,"wires":[["fabdc6fd.2bb9f8","f64d640e.c6bfa","f69a62a4.6d31b8"]]},{"id":"3209e498.ac7844","type":"smooth","z":"170f4113.a11aef","name":"Lux: Standard Deviation","property":"payload.lux","action":"sd","count":"3","round":"","mult":"multi","x":510,"y":560,"wires":[["b7c34b84.b5ad98","921f1569.889cb","b09d41ba.8ebfa8"]]},{"id":"b7c34b84.b5ad98","type":"debug","z":"170f4113.a11aef","name":"Standard Deviation","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.lux","x":770,"y":560,"wires":[]},{"id":"a7f099eb.0d99e","type":"function","z":"170f4113.a11aef","name":"Z-Score","func":"msg.ID = msg.payload; //a unique ID given by the creator of this message.\nmsg.topic=\"task1\";\nmsg.payload=msg.ID.zscore\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":720,"wires":[["b1747b8e.90a8f","31dda055.cc387"]]},{"id":"b1747b8e.90a8f","type":"debug","z":"170f4113.a11aef","name":"Z-Score Out","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1030,"y":540,"wires":[]},{"id":"f64d640e.c6bfa","type":"function","z":"170f4113.a11aef","name":"Moving Average","func":"msg.ID = msg.payload; //a unique ID given by the creator of this message.\nmsg.topic=\"task2\";\nmsg.payload=msg.ID.lux\nreturn msg;","outputs":1,"noerr":0,"x":720,"y":760,"wires":[["7e513995.4b7478","45f35553.ba77d4"]]},{"id":"7e513995.4b7478","type":"debug","z":"170f4113.a11aef","name":"Mean Out","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1020,"y":580,"wires":[]},{"id":"921f1569.889cb","type":"function","z":"170f4113.a11aef","name":"Standard Deviation","func":"msg.ID = msg.payload; //a unique ID given by the creator of this message.\nmsg.topic=\"task3\";\nmsg.payload=msg.ID.lux\nreturn msg;","outputs":1,"noerr":0,"x":730,"y":800,"wires":[["4dc8eac1.c9a3a4","ed2f0ff5.617d58"]]},{"id":"4dc8eac1.c9a3a4","type":"debug","z":"170f4113.a11aef","name":"Standard Deviation","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1050,"y":620,"wires":[]},{"id":"31dda055.cc387","type":"delay","z":"170f4113.a11aef","name":"Random delay","pauseType":"random","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"","rateUnits":"second","randomFirst":"0","randomLast":"6","randomUnits":"seconds","drop":false,"x":960,"y":720,"wires":[["f029dfa.6fab42","277a70d0.a8c7"]]},{"id":"45f35553.ba77d4","type":"delay","z":"170f4113.a11aef","name":"Random delay","pauseType":"random","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"","rateUnits":"second","randomFirst":"1","randomLast":"6","randomUnits":"seconds","drop":false,"x":960,"y":760,"wires":[["f029dfa.6fab42"]]},{"id":"ed2f0ff5.617d58","type":"delay","z":"170f4113.a11aef","name":"Random delay","pauseType":"random","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"","rateUnits":"second","randomFirst":"1","randomLast":"6","randomUnits":"seconds","drop":false,"x":960,"y":800,"wires":[["f029dfa.6fab42"]]},{"id":"f029dfa.6fab42","type":"function","z":"170f4113.a11aef","name":"Wait for all tasks to finish","func":"QueryID = msg.ID;\ncontext.data = context.data || {};\ncontext.data[QueryID] = context.data[QueryID] || {tstamp:(new Date()).getTime(), zscore : null, weighted_mean: null, standard_dev: null, piname: context.global.os.hostname()};\n\nswitch (msg.topic) {\n case \"task1\":\n context.data[QueryID].zscore = msg.payload;\n msg = null;\n break;\n case \"task2\":\n context.data[QueryID].weighted_mean = msg.payload;\n msg = null;\n break;\n case \"task3\":\n context.data[QueryID].standard_dev = msg.payload;\n msg = null;\n break;\n case \"task4\":\n context.data[QueryID].piname = msg.payload;\n msg = null;\n break;\n default:\n msg = null;\n \tbreak;\n\n}\n\nif(context.data[QueryID].zscore !== null && context.data[QueryID].weighted_mean !== null && context.data[QueryID].standard_dev !== null) {\n\tmsg2 = {};\n msg2 = context.data[QueryID];\n delete context.data[QueryID];\n\treturn msg2;\n} else return msg;","outputs":1,"noerr":0,"x":1230,"y":760,"wires":[["1852fb9a.94a904","36c264e7.f69f3c"]]},{"id":"277a70d0.a8c7","type":"debug","z":"170f4113.a11aef","name":"Z with Delay","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1170,"y":680,"wires":[]},{"id":"1852fb9a.94a904","type":"debug","z":"170f4113.a11aef","name":"Combined","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1450,"y":700,"wires":[]},{"id":"96d7b6d2.125578","type":"function","z":"170f4113.a11aef","name":"Z-Score to Guage","func":"var fields = {payload: msg.payload.zscore};\nreturn fields;","outputs":1,"noerr":0,"x":1030,"y":400,"wires":[["7433d1c.657abb"]]},{"id":"d430b725.22b5b8","type":"ui_chart","z":"170f4113.a11aef","name":"","group":"f7b54de6.2a21d8","order":0,"width":0,"height":0,"label":"Lux Mean Chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":1300,"y":440,"wires":[[],[]]},{"id":"f69a62a4.6d31b8","type":"function","z":"170f4113.a11aef","name":"Lux Mean","func":"var fields = {payload: msg.payload.lux};\nreturn fields;","outputs":1,"noerr":0,"x":1000,"y":440,"wires":[["d430b725.22b5b8"]]},{"id":"b09d41ba.8ebfa8","type":"function","z":"170f4113.a11aef","name":"Standard Deviation","func":"var fields = {payload: msg.payload.lux};\nreturn fields;","outputs":1,"noerr":0,"x":1030,"y":480,"wires":[["8a50fef7.eedad"]]},{"id":"8a50fef7.eedad","type":"ui_chart","z":"170f4113.a11aef","name":"","group":"f7b54de6.2a21d8","order":0,"width":0,"height":0,"label":"Lux Standard Deviation Chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":1350,"y":480,"wires":[[],[]]},{"id":"7433d1c.657abb","type":"ui_chart","z":"170f4113.a11aef","name":"","group":"f7b54de6.2a21d8","order":0,"width":0,"height":0,"label":"Z-Score Chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":1300,"y":400,"wires":[[],[]]},{"id":"8037e8c5.8bd49","type":"mqtt-broker","z":"","name":"dietpi-1","broker":"192.168.51.27","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""},{"id":"d6bddfb6.0d3778","type":"timeseries","z":"","hostname":"192.168.51.27","port":"27018","db":"iot","name":"Insert to Informax (Local)"},{"id":"27796c38.f5fc3c","type":"cloudant","z":"","host":"5017a47e-4beb-49a9-b221-56de06629f80-bluemix.cloudant.com","name":"devnetcreate2018-cloudantdb"},{"id":"f7b54de6.2a21d8","type":"ui_group","z":"","name":"Dashboard","tab":"b741cd9c.dbfe28","order":1,"disp":true,"width":"6","collapse":false},{"id":"b741cd9c.dbfe28","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":1}]
Loading