Jakub SmejkalRosťa Kutěj
Published © Apache-2.0

Simple neural network on TOWER IoT Kit

This project serves as a starter guide on how to run a simple neural network on HARDWARIO TOWER IoT Kit Core Module.

IntermediateProtip3 hours225
Simple neural network on TOWER IoT Kit

Things used in this project

Hardware components

Core Module
HARDWARIO Core Module
×1
Radio Dongle
HARDWARIO Radio Dongle
×1
Humidity Tag
HARDWARIO Humidity Tag
×1
Battery Module
HARDWARIO Battery Module
OPTIONAL. Has a slot for the humidity tag but you can also put the tag into Core Module directly
×1

Software apps and online services

STM32CUBEPROG
STMicroelectronics STM32CUBEPROG
HARDWARIO Code
Playground
HARDWARIO Playground
TensorFlow
TensorFlow

Hand tools and fabrication machines

TensorFlow Lite
TensorFlow Lite

Story

Read more

Code

Data collection Node-RED flow

JSON
Flow for collecting data into file
[{"id":"765a1356.221fcc","type":"mqtt in","z":"c76a280d.4e5fc8","name":"","topic":"node/ai-data-collector:0/data","qos":"2","datatype":"auto","broker":"29fba84a.b2af58","x":260,"y":160,"wires":[["3b2b3f03.d93c8"]]},{"id":"c386f362.b5791","type":"debug","z":"c76a280d.4e5fc8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1070,"y":160,"wires":[]},{"id":"3b2b3f03.d93c8","type":"json","z":"c76a280d.4e5fc8","name":"","property":"payload","action":"","pretty":false,"x":450,"y":160,"wires":[["e3d951d6.6be5b"]]},{"id":"e3d951d6.6be5b","type":"json","z":"c76a280d.4e5fc8","name":"","property":"payload","action":"","pretty":false,"x":590,"y":160,"wires":[["612b0714.bee878"]]},{"id":"612b0714.bee878","type":"function","z":"c76a280d.4e5fc8","name":"Change format","func":"var utc = new Date().getTime();\nvar temperature = msg.payload.temperature;\nvar humidity = msg.payload.humidity;\n\ndata = {'UTC':utc,'Temperature':temperature,'Humidity':humidity};\n\nmsg.payload = data;\n\nreturn msg","outputs":1,"noerr":0,"x":740,"y":160,"wires":[["a9437682.096848"]]},{"id":"a9437682.096848","type":"csv","z":"c76a280d.4e5fc8","name":"","sep":",","hdrin":"","hdrout":false,"multi":"one","ret":"\\n","temp":"UTC,Temperature,Humidity","skip":"0","strings":true,"x":910,"y":160,"wires":[["c386f362.b5791","73dacf44.43c82"]]},{"id":"73dacf44.43c82","type":"file","z":"c76a280d.4e5fc8","name":"","filename":"/home/pi/toi/project/data.csv","appendNewline":false,"createDir":true,"overwriteFile":"false","encoding":"utf8","x":1020,"y":240,"wires":[[]]},{"id":"29fba84a.b2af58","type":"mqtt-broker","z":"","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""}]

Flow with the graphs

JSON
This flow will save both predicted and actual data and then plot them into the chart
[{"id":"765a1356.221fcc","type":"mqtt in","z":"c76a280d.4e5fc8","name":"","topic":"node/ai-data-predictor:0/data","qos":"2","datatype":"auto","broker":"29fba84a.b2af58","x":260,"y":160,"wires":[["3b2b3f03.d93c8"]]},{"id":"c386f362.b5791","type":"debug","z":"c76a280d.4e5fc8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1070,"y":160,"wires":[]},{"id":"3b2b3f03.d93c8","type":"json","z":"c76a280d.4e5fc8","name":"","property":"payload","action":"","pretty":false,"x":450,"y":160,"wires":[["e3d951d6.6be5b"]]},{"id":"e3d951d6.6be5b","type":"json","z":"c76a280d.4e5fc8","name":"","property":"payload","action":"","pretty":false,"x":590,"y":160,"wires":[["612b0714.bee878","7f14656c.775fac"]]},{"id":"612b0714.bee878","type":"function","z":"c76a280d.4e5fc8","name":"Change format","func":"var utc = new Date().getTime();\nvar temperature = msg.payload.temperature;\nvar humidity = msg.payload.humidity;\n\ndata = {'UTC':utc,'Temperature':temperature,'Humidity':humidity};\n\nmsg.payload = data;\n\nreturn msg","outputs":1,"noerr":0,"x":740,"y":160,"wires":[["a9437682.096848"]]},{"id":"a9437682.096848","type":"csv","z":"c76a280d.4e5fc8","name":"","sep":",","hdrin":"","hdrout":false,"multi":"one","ret":"\\n","temp":"UTC,Temperature,Humidity","skip":"0","strings":true,"x":910,"y":160,"wires":[["c386f362.b5791","73dacf44.43c82"]]},{"id":"73dacf44.43c82","type":"file","z":"c76a280d.4e5fc8","name":"","filename":"/home/pi/toi/project/data.csv","appendNewline":false,"createDir":true,"overwriteFile":"false","encoding":"utf8","x":1020,"y":240,"wires":[[]]},{"id":"943655d6.160648","type":"mqtt in","z":"c76a280d.4e5fc8","name":"","topic":"node/ai-data-predictor:0/predicted","qos":"2","datatype":"auto","broker":"29fba84a.b2af58","x":270,"y":380,"wires":[["8347fee2.6391a"]]},{"id":"8347fee2.6391a","type":"json","z":"c76a280d.4e5fc8","name":"","property":"payload","action":"","pretty":false,"x":490,"y":380,"wires":[["66cf06e4.167d88"]]},{"id":"66cf06e4.167d88","type":"json","z":"c76a280d.4e5fc8","name":"","property":"payload","action":"","pretty":false,"x":630,"y":380,"wires":[["469e9746.e59c98","e04bd08a.a9759","eeae2ae6.0bd9a8"]]},{"id":"469e9746.e59c98","type":"debug","z":"c76a280d.4e5fc8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":890,"y":380,"wires":[]},{"id":"e04bd08a.a9759","type":"change","z":"c76a280d.4e5fc8","name":"","rules":[{"t":"set","p":"predicted","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":560,"wires":[[]]},{"id":"7f14656c.775fac","type":"change","z":"c76a280d.4e5fc8","name":"","rules":[{"t":"set","p":"actual","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":260,"wires":[[]]},{"id":"eeae2ae6.0bd9a8","type":"delay","z":"c76a280d.4e5fc8","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":800,"y":480,"wires":[["8082f19d.df3e3","e7ebf7ac.a02688"]]},{"id":"8082f19d.df3e3","type":"function","z":"c76a280d.4e5fc8","name":"Temperature data","func":"var msgActual = {};\nvar msgPredicted = {};\n\nmsgActual.payload = flow.get('actual').temperature;\nmsgActual.topic = \"Actual\";\n\nmsgPredicted.payload = flow.get('predicted').p_temp;\nmsgPredicted.topic = \"Predicted\";\n\nreturn [msgActual, msgPredicted];","outputs":2,"noerr":0,"x":990,"y":480,"wires":[["ef91f9e9.d1c858"],["ef91f9e9.d1c858"]]},{"id":"ef91f9e9.d1c858","type":"ui_chart","z":"c76a280d.4e5fc8","name":"","group":"51d7c66c.70fd08","order":0,"width":0,"height":0,"label":"Temperatures","chartType":"line","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#ff0000","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1280,"y":480,"wires":[[]]},{"id":"e7ebf7ac.a02688","type":"function","z":"c76a280d.4e5fc8","name":"Humidity data","func":"var msgActual = {};\nvar msgPredicted = {};\n\nmsgActual.payload = flow.get('actual').humidity;\nmsgActual.topic = \"Actual\";\n\nmsgPredicted.payload = flow.get('predicted').p_hum;\nmsgPredicted.topic = \"Predicted\";\n\nreturn [msgActual, msgPredicted];","outputs":2,"noerr":0,"x":980,"y":520,"wires":[["ace06230.5855b"],["ace06230.5855b"]]},{"id":"ace06230.5855b","type":"ui_chart","z":"c76a280d.4e5fc8","name":"","group":"6160552f.cf7d9c","order":0,"width":0,"height":0,"label":"Humidities","chartType":"line","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#ff0000","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1270,"y":520,"wires":[[]]},{"id":"29fba84a.b2af58","type":"mqtt-broker","z":"","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"51d7c66c.70fd08","type":"ui_group","z":"","name":"Teplota","tab":"b68311bf.7dc2c","order":1,"disp":true,"width":"6","collapse":true},{"id":"6160552f.cf7d9c","type":"ui_group","z":"","name":"Tlak","tab":"2c9ae48.4458d1c","order":2,"disp":true,"width":"6","collapse":true},{"id":"b68311bf.7dc2c","type":"ui_tab","z":"","name":"Bathroom","icon":"dashboard","order":7,"disabled":false,"hidden":false},{"id":"2c9ae48.4458d1c","type":"ui_tab","z":"","name":"WorkShop","icon":"dashboard","order":6,"disabled":false,"hidden":false}]

Credits

Jakub Smejkal
79 projects • 14 followers
Contact
Rosťa Kutěj
0 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.