Record/store/graph temperature of device
Temperature is measured by executing the command: /usr/bin/vcgencmd measure_temp
1 hour of temperature recordings are input into a live graph.
Temperature recordings are also stored in a filing system. A new file is created every 3 hours with the following format: YYYY-MM-DD-Time:HH.txt
The file browser provides the functionality to select from a library of files and visualise the files as a graph.
An inject node will trigger the following command every 24 hours: find //home/pi/temperatureDataLogs/ -mtime +7 -exec rm -rf {} ;
This command will delete temperature recordings that are older than 7 days.
[{"id":"b1f8573292e191fd","type":"tab","label":"Main Dashboard","disabled":false,"info":"","env":[]},{"id":"f1efa6c74df1b7b2","type":"tab","label":"File Browser","disabled":false,"info":"","env":[]},{"id":"6867ecfbb9900254","type":"ui_tab","name":"File Browser","icon":"dashboard","order":2,"disabled":false,"hidden":false},{"id":"6ad39ee7744af6ec","type":"ui_base","theme":{"name":"theme-light","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#097479","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"themeState":{"base-color":{"default":"#0094CE","value":"#0094CE","edited":false},"page-titlebar-backgroundColor":{"value":"#0094CE","edited":false},"page-backgroundColor":{"value":"#fafafa","edited":false},"page-sidebar-backgroundColor":{"value":"#ffffff","edited":false},"group-textColor":{"value":"#1bbfff","edited":false},"group-borderColor":{"value":"#ffffff","edited":false},"group-backgroundColor":{"value":"#ffffff","edited":false},"widget-textColor":{"value":"#111111","edited":false},"widget-backgroundColor":{"value":"#0094ce","edited":false},"widget-borderColor":{"value":"#ffffff","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey","palette":"light"}},"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"19f4c416402b658a","type":"ui_group","name":"Input","tab":"6867ecfbb9900254","order":2,"disp":true,"width":28,"collapse":false},{"id":"b63d1f91.68095","type":"ui_tab","name":"Files","icon":"dashboard","order":3,"disabled":false,"hidden":false},{"id":"1c25415d.b8427f","type":"sqlitedb","db":"/home/pi/sqlite/nodered"},{"id":"bd903d6.d9fc7c","type":"ui_group","name":"Report","tab":"1e3fe400.0baf5c","order":2,"disp":true,"width":"18"},{"id":"1e17cd0b.862863","type":"ui_group","name":"Selection","tab":"1e3fe400.0baf5c","order":1,"disp":true,"width":"5"},{"id":"156af96f.f8fd27","type":"ui_tab","name":"Home","icon":"home","order":4},{"id":"1e3fe400.0baf5c","type":"ui_tab","name":"Reports","icon":"dashboard","order":7},{"id":"d7901f40.2659d","type":"ui_tab","name":"Charts","icon":"dashboard","order":5},{"id":"44d9222c.07961c","type":"ui_group","name":"Charts","tab":"f779dd92.cf698","order":2,"disp":false,"width":"6"},{"id":"ef33233b.dd28f","type":"ui_group","name":"Group 3","tab":"f779dd92.cf698","order":3,"disp":false,"width":"6"},{"id":"f779dd92.cf698","type":"ui_tab","name":"Charts","icon":"dashboard","order":6},{"id":"35d63e9aafcfec39","type":"ui_tab","name":"Main Dashboard","icon":"dashboard","order":1,"disabled":false,"hidden":false},{"id":"4e82e936944a5310","type":"ui_group","name":"Temperature","tab":"35d63e9aafcfec39","order":1,"disp":true,"width":16,"collapse":false},{"id":"3f0c164f30c675f7","type":"ui_spacer","z":"f1efa6c74df1b7b2","name":"spacer","group":"19f4c416402b658a","order":1,"width":28,"height":1},{"id":"e1708c5b419b0eaa","type":"inject","z":"b1f8573292e191fd","name":"Inject 15s","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"15","crontab":"","once":true,"onceDelay":"2","topic":"","payload":"","payloadType":"date","x":1410,"y":1280,"wires":[["3610aff3de05cd23"]]},{"id":"3610aff3de05cd23","type":"exec","z":"b1f8573292e191fd","command":"/usr/bin/vcgencmd measure_temp","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"Temp","x":1570,"y":1420,"wires":[["0bfc6e9069859533"],[],[]]},{"id":"72e85ed14e868f6e","type":"ui_chart","z":"b1f8573292e191fd","name":"Temperature","group":"4e82e936944a5310","order":1,"width":16,"height":10,"label":"Temperature (last hour)","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":1990,"y":1500,"wires":[[]]},{"id":"04dbbb7501627244","type":"smooth","z":"b1f8573292e191fd","name":"","property":"payload","action":"mean","count":"5","round":"","mult":"single","reduce":false,"x":1800,"y":1420,"wires":[["72e85ed14e868f6e","300321ac1eb6acd0"]]},{"id":"0bfc6e9069859533","type":"string","z":"b1f8573292e191fd","name":"","methods":[{"name":"delLeftMost","params":[{"type":"str","value":"="}]},{"name":"delRightMost","params":[{"type":"str","value":"'"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":1690,"y":1280,"wires":[["04dbbb7501627244"]]},{"id":"e390863e3fb125a4","type":"file","z":"b1f8573292e191fd","name":"Add data to file","filename":"msg.filePath","filenameType":"msg","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"none","x":2500,"y":1420,"wires":[[]]},{"id":"300321ac1eb6acd0","type":"string","z":"b1f8573292e191fd","name":"","methods":[{"name":"toFloat","params":[{"type":"num","value":"2"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":1930,"y":1280,"wires":[["fbeb88c40e318170","8567653e219324cb"]]},{"id":"fbeb88c40e318170","type":"debug","z":"b1f8573292e191fd","name":"debug 1","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":2020,"y":1180,"wires":[]},{"id":"8567653e219324cb","type":"function","z":"b1f8573292e191fd","name":"Add date to message","func":"msg.payload = new Date() + \",\" + msg.payload;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2100,"y":1420,"wires":[["2ab7a56349f0b52e","9b147ed68f0a8793"]]},{"id":"2ab7a56349f0b52e","type":"debug","z":"b1f8573292e191fd","name":"debug 4","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":2320,"y":1480,"wires":[]},{"id":"9b147ed68f0a8793","type":"function","z":"b1f8573292e191fd","name":"Filename generator","func":"// Get the current time and convert it to text\nvar now = new Date();\nvar yyyy = now.getFullYear();\nvar mm = now.getMonth() < 9 ? \"0\" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\nvar dd = now.getDate() < 10 ? \"0\" + now.getDate() : now.getDate();\nvar hh = now.getHours() < 10 ? \"0\" + now.getHours() : now.getHours();\n\nif(hh == \"00\" || hh <\"03\"){\n hh = \"00\";\n} else if (hh == \"03\" || hh < \"06\") {\n hh = \"03\";\n} else if (hh == \"06\" || hh < \"09\") {\n hh = \"06\";\n} else if (hh == \"09\" || hh < \"12\") {\n hh = \"09\";\n} else if (hh == \"12\" || hh < \"15\") {\n hh = \"12\";\n} else if (hh == \"15\" || hh < \"18\") {\n hh = \"15\";\n} else if (hh == \"18\" || hh < \"21\") {\n hh = \"18\";\n} else if (hh == \"21\" || hh < \"00\") {\n hh = \"21\";\n}\n\n// Generate out file name pattern\nvar fileName = \"temperature_\" + yyyy + \"-\" + mm + \"_\" + dd + \"_Time:\" + hh + \".txt\";\n// Full filename with path for the file node later\nmsg.filePath = \"/home/pi/temperatureDataLogs/\" + fileName;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2310,"y":1280,"wires":[["e390863e3fb125a4"]]},{"id":"e0688354983f7f31","type":"inject","z":"b1f8573292e191fd","name":"Inject 24h","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"86400","crontab":"","once":true,"onceDelay":"60","topic":"","payload":"","payloadType":"date","x":1410,"y":1720,"wires":[["2b70cad70268cbd8"]]},{"id":"2b70cad70268cbd8","type":"exec","z":"b1f8573292e191fd","command":"find //home/pi/temperatureDataLogs/ -mtime +7 -exec rm -rf {} \\;","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"Remove old files","x":1670,"y":1720,"wires":[[],[],[]]},{"id":"43cbc90716bff0ae","type":"split","z":"f1efa6c74df1b7b2","name":"Split text into n messages","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":650,"y":1480,"wires":[["12cd420f92a6cc47","722fed2dcfc3f9ce"]]},{"id":"722fed2dcfc3f9ce","type":"function","z":"f1efa6c74df1b7b2","name":"Split message into array","func":"var splitArr = msg.payload.toString().split(\",\", 2);;\n\nvar date = new Date(splitArr[0]);\nvar epoch = Number(date)\nsplitArr[0] = epoch;\n\nsplitArr[1] = Number(splitArr[1]);\n\nvar returnArr = {\n \"x\": splitArr[0],\n \"y\": splitArr[1]\n};\n\nmsg.payload = returnArr;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":1600,"wires":[["33ce08b41dde7ed6","a4061a437da9c118"]]},{"id":"12cd420f92a6cc47","type":"debug","z":"f1efa6c74df1b7b2","name":"debug 5","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":840,"y":1400,"wires":[]},{"id":"33ce08b41dde7ed6","type":"debug","z":"f1efa6c74df1b7b2","name":"debug 6","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1000,"y":1700,"wires":[]},{"id":"a4061a437da9c118","type":"join","z":"f1efa6c74df1b7b2","name":"Join messages as array of arrays","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1060,"y":1500,"wires":[["16bc795919ab1874","c86865e0ca02f413"]]},{"id":"16bc795919ab1874","type":"debug","z":"f1efa6c74df1b7b2","name":"debug 7","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1180,"y":1400,"wires":[]},{"id":"c86865e0ca02f413","type":"function","z":"f1efa6c74df1b7b2","name":"Chart format","func":"var chart = [{\n \"series\": [\"Temperature\"],\n \"data\": [msg.payload],\n \"labels\": [\"\"]\n}];\n\nmsg.payload = chart;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1310,"y":1600,"wires":[["83bf1ef5d16a0a86","df37ad9c1a7d57fc"]]},{"id":"df37ad9c1a7d57fc","type":"ui_chart","z":"f1efa6c74df1b7b2","name":"","group":"19f4c416402b658a","order":2,"width":15,"height":11,"label":"Temperature (3 hours)","chartType":"line","legend":"false","xformat":"auto","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"3","removeOlderPoints":"720","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":1520,"y":1480,"wires":[[]]},{"id":"83bf1ef5d16a0a86","type":"debug","z":"f1efa6c74df1b7b2","name":"debug 8","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1460,"y":1700,"wires":[]},{"id":"58b8b9cf4b574d32","type":"ui_button","z":"f1efa6c74df1b7b2","name":"Clear","group":"19f4c416402b658a","order":5,"width":7,"height":2,"passthru":false,"label":"Clear","tooltip":"","color":"","bgcolor":"","icon":"","payload":"[]","payloadType":"json","topic":"topic","topicType":"msg","x":1370,"y":1400,"wires":[["df37ad9c1a7d57fc"]]},{"id":"0eb1b39bc39ce2a5","type":"fs-file-lister","z":"f1efa6c74df1b7b2","name":"Files","start":"/home/pi//temperatureDataLogs","pattern":"*.*","folders":"*","hidden":false,"lstype":"files","path":true,"single":true,"depth":0,"stat":true,"showWarnings":false,"x":590,"y":980,"wires":[["184ebda940f46a38","ce4a8102c17786d1"]]},{"id":"f3d8638ea73b20f4","type":"ui_dropdown","z":"f1efa6c74df1b7b2","name":"File Selector","label":"Select file:","tooltip":"","place":"","group":"19f4c416402b658a","order":3,"width":13,"height":13,"passthru":true,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"payload","topicType":"msg","x":950,"y":1000,"wires":[["7746ed734b26463b","d856cac80289dcf0"]]},{"id":"fbccb2c928af7fb2","type":"ui_button","z":"f1efa6c74df1b7b2","name":"","group":"19f4c416402b658a","order":4,"width":8,"height":2,"passthru":false,"label":"Graph","tooltip":"","color":"","bgcolor":"","icon":"show_chart","payload":"","payloadType":"str","topic":"","topicType":"str","x":350,"y":1260,"wires":[["7e32a2f84b2c5a13"]]},{"id":"7e32a2f84b2c5a13","type":"function","z":"f1efa6c74df1b7b2","name":"Get filename","func":"// Get the filename from the flow context\nvar filename = flow.get(\"fileselected\");\n\n// check, if the filename is undefined that means it does not exist yet, nothing is selected yet\n// return: do not output anything\nif (filename===undefined) {\n return;\n}\n\n// return the filename to the file-in node to delete\nmsg.filename = filename;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":570,"y":1260,"wires":[["2d880ce5a0311b9a"]]},{"id":"2d880ce5a0311b9a","type":"file in","z":"f1efa6c74df1b7b2","name":"","filename":"filename","filenameType":"msg","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":380,"y":1480,"wires":[["43cbc90716bff0ae"]]},{"id":"7746ed734b26463b","type":"change","z":"f1efa6c74df1b7b2","name":"Save selection","rules":[{"t":"set","p":"fileselected","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1100,"y":900,"wires":[[]]},{"id":"7abb03b864d08795","type":"inject","z":"f1efa6c74df1b7b2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":470,"y":860,"wires":[["0eb1b39bc39ce2a5"]]},{"id":"d856cac80289dcf0","type":"debug","z":"f1efa6c74df1b7b2","name":"debug 9","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1100,"y":1100,"wires":[]},{"id":"184ebda940f46a38","type":"debug","z":"f1efa6c74df1b7b2","name":"debug 11","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":1100,"wires":[]},{"id":"ce4a8102c17786d1","type":"function","z":"f1efa6c74df1b7b2","name":"Format for dropdown","func":"msg.options = new Array();\n\nfor(var i = 0; i < msg.payload.length; i++){\n \n msg.options[i] = msg.payload[i].name;\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":900,"wires":[["f3d8638ea73b20f4"]]}]