Is it Possible to Collect Datas with Visualizing with Nodered


#1

I done something with dsm node and when the device shut down and up it is showing in dashboard.

My question is this is it possible to any statistic showing with nodered like acronis dashboard pict below?


#2

It is possible to do entirely within dashboard using the template node, but it'd be up to you to write the necessary javascript to get it looking just like this. If you need statistical analysis and visualization that you can navigate on demand, I'd recommend using Node-red to feed the data to some sort of database that can then be used by a visualization tool like grafana or graphite.


#3

Dear @JayDickson coluld you please share with me if you have database and javascript code examples. Now I dont have enogh experince and I dont know how can I create DB and feed it and then visualizing it


#4

That much background assistance is really getting outside the scope of this forum. My experience in doing javascript dashboard template based widgets is also extremely limited. If you're looking to build up some basic historical analysis and visualization skills you may be well served by doing some research/reading on the TIG stack, and once you get more comfortable with the base tools start experimenting with using node-red to feed it data and drive rule-based actions.


#5

Break the problem down into pieces and you will get through it in no time. Start by working out what data you need to capture in order to build up your dashboard. Then you will need to choose a database. SQLite is good for small-ish amounts of data or even just dumping some JSON to a file. But once you start to consider extended amounts of data, you need a management system and should look at MariaDB (for tabular type data), MongoDB or similar for JSON type data or InfluxDB for timeseries data.

InfluxDB is especially good for working with the Graphana dashboard tool as they work closely together.


#6

SO one more question, iit possible to make some maths in node red, for example plus / minus / times, or any other formulas can make it ?


#7

Yes, in a Function node you have full access to the javascript language to do anything like this you want. Also if all you want to do is scale and/or offset a value then you can use the Range node.


#8

Thank you very much for your reply.


#9

JSONata can also be used in conjunction with the change node.


#10

I need one more information, Is it possible to logging data ( temp and humidity) with time and hours. Also saving in RPI 3 sd card ?

It should save in .txt or csv file

like

Temp : 26C 17.10.2018- 21.33.22
Humidity : 48% 17.10.2018- 21.33.22

Lazer 1 : Down 17.10.2018- 21.33.22
Lazer 1 : UP 17.10.2018- 21.35.40

Thanks for your advance


#11

You can write to a file using the file out node in append mode.


#12

Dear @Colin I already did it but the data saving format is so long and complicated.
I just want to basic log files which is like I said before my post.


#13

The file node will write whatever you have in msg.payload to the file. If you want a particular format, you should get it into that format before passing to the file node.

Depending on your requirements, you could use a Function node, Template node, or maybe the CSV node.


#14

My node is this

[{"id":"4d41326.b19a5cc","type":"rpi-gpio in","z":"21cd0d76.58b4c2","name":"","pin":"40","intype":"tri","debounce":"25","read":false,"x":192.5,"y":43,"wires":[["87014208.fe969"]]},{"id":"87014208.fe969","type":"dsm","z":"21cd0d76.58b4c2","name":"DSM","sm_config":"{\n    \"triggerInput\": \"payload\",\n    \"currentState\": \"running\",\n    \"states\": {\n        \"stopped\": {\n            \"0\": \"running\"\n        },\n        \"running\": {\n            \"1\": \"stopped\"\n        }\n    },\n    \"methods\": {\n        \"onBeforeTransition\": \"msg.pyload = msg.payload.toString();\",\n        \"0\": \"sta.fill='green';msg.background='green';msg.label='Lazer 1 Çalışıyor';\",\n        \"1\": \"sta.fill='red';msg.background='red';msg.label='Lazer 1 Arızalı!!!';\"\n    }\n}","x":358.5,"y":44,"wires":[["56a1f1b0.29ade"]]},{"id":"56a1f1b0.29ade","type":"ui_button","z":"21cd0d76.58b4c2","name":"Lazer 1","group":"31462797.454d08","order":0,"width":"6","height":"1","passthru":false,"label":"{{msg.label}}","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"date","topic":"","x":527.5,"y":44,"wires":[[]]},{"id":"c6dd9e15.51aa","type":"rpi-gpio in","z":"21cd0d76.58b4c2","name":"","pin":"38","intype":"tri","debounce":"25","read":false,"x":195,"y":88,"wires":[["b60728a8.434258"]]},{"id":"b60728a8.434258","type":"dsm","z":"21cd0d76.58b4c2","name":"DSM","sm_config":"{\n    \"triggerInput\": \"payload\",\n    \"currentState\": \"running\",\n    \"states\": {\n        \"stopped\": {\n            \"0\": \"running\"\n        },\n        \"running\": {\n            \"1\": \"stopped\"\n        }\n    },\n    \"methods\": {\n        \"onBeforeTransition\": \"msg.pyload = msg.payload.toString();\",\n        \"0\": \"sta.fill='green';msg.background='green';msg.label='Lazer 2 Çalışıyor';\",\n        \"1\": \"sta.fill='red';msg.background='red';msg.label='Lazer 2 Arızalı!!!';\"\n    }\n}","x":361,"y":89,"wires":[["7a7ea53.8f4495c"]]},{"id":"7a7ea53.8f4495c","type":"ui_button","z":"21cd0d76.58b4c2","name":"Lazer 2","group":"31462797.454d08","order":0,"width":"6","height":"1","passthru":false,"label":"{{msg.label}}","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":530,"y":89,"wires":[[]]},{"id":"a1a2894c.6a74b8","type":"rpi-gpio in","z":"21cd0d76.58b4c2","name":"","pin":"37","intype":"tri","debounce":"25","read":false,"x":193,"y":126,"wires":[["680c1e13.8aa17"]]},{"id":"680c1e13.8aa17","type":"dsm","z":"21cd0d76.58b4c2","name":"DSM","sm_config":"{\n    \"triggerInput\": \"payload\",\n    \"currentState\": \"running\",\n    \"states\": {\n        \"stopped\": {\n            \"0\": \"running\"\n        },\n        \"running\": {\n            \"1\": \"stopped\"\n        }\n    },\n    \"methods\": {\n        \"onBeforeTransition\": \"msg.pyload = msg.payload.toString();\",\n        \"0\": \"sta.fill='green';msg.background='green';msg.label='Lazer 3 Çalışıyor';\",\n        \"1\": \"sta.fill='red';msg.background='red';msg.label='Lazer 3 Arızalı!!!';\"\n    }\n}","x":359,"y":127,"wires":[["220c3375.4107dc"]]},{"id":"220c3375.4107dc","type":"ui_button","z":"21cd0d76.58b4c2","name":"Lazer 3","group":"31462797.454d08","order":0,"width":"6","height":"1","passthru":false,"label":"{{msg.label}}","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":528,"y":127,"wires":[[]]},{"id":"6956815.dc08d8","type":"rpi-gpio in","z":"21cd0d76.58b4c2","name":"","pin":"36","intype":"tri","debounce":"25","read":false,"x":191,"y":161,"wires":[["af3cc48f.88f988"]]},{"id":"af3cc48f.88f988","type":"dsm","z":"21cd0d76.58b4c2","name":"DSM","sm_config":"{\n    \"triggerInput\": \"payload\",\n    \"currentState\": \"running\",\n    \"states\": {\n        \"stopped\": {\n            \"0\": \"running\"\n        },\n        \"running\": {\n            \"1\": \"stopped\"\n        }\n    },\n    \"methods\": {\n        \"onBeforeTransition\": \"msg.pyload = msg.payload.toString();\",\n        \"0\": \"sta.fill='green';msg.background='green';msg.label='Lazer 4 Çalışıyor';\",\n        \"1\": \"sta.fill='red';msg.background='red';msg.label='Lazer 4 Arızalı!!!';\"\n    }\n}","x":357,"y":162,"wires":[["3efe00d5.6d938"]]},{"id":"3efe00d5.6d938","type":"ui_button","z":"21cd0d76.58b4c2","name":"Lazer 4","group":"31462797.454d08","order":0,"width":"6","height":"1","passthru":false,"label":"{{msg.label}}","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":526,"y":162,"wires":[[]]},{"id":"9e7211ec.5284a","type":"rpi-gpio in","z":"21cd0d76.58b4c2","name":"","pin":"35","intype":"tri","debounce":"25","read":false,"x":194,"y":199,"wires":[["fe45fc3d.f6d65"]]},{"id":"fe45fc3d.f6d65","type":"dsm","z":"21cd0d76.58b4c2","name":"DSM","sm_config":"{\n    \"triggerInput\": \"payload\",\n    \"currentState\": \"running\",\n    \"states\": {\n        \"stopped\": {\n            \"0\": \"running\"\n        },\n        \"running\": {\n            \"1\": \"stopped\"\n        }\n    },\n    \"methods\": {\n        \"onBeforeTransition\": \"msg.pyload = msg.payload.toString();\",\n        \"0\": \"sta.fill='green';msg.background='green';msg.label='Lazer 5 Çalışıyor';\",\n        \"1\": \"sta.fill='red';msg.background='red';msg.label='Lazer 5 Arızalı!!!';\"\n    }\n}","x":360,"y":200,"wires":[["b5168542.d94388"]]},{"id":"b5168542.d94388","type":"ui_button","z":"21cd0d76.58b4c2","name":"Lazer 5","group":"31462797.454d08","order":0,"width":"6","height":"1","passthru":false,"label":"{{msg.label}}","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":529,"y":200,"wires":[[]]},{"id":"f2bc90af.f7e3b","type":"rpi-gpio in","z":"21cd0d76.58b4c2","name":"","pin":"33","intype":"tri","debounce":"25","read":false,"x":193,"y":236,"wires":[["3dc2e801.9f8d78"]]},{"id":"3dc2e801.9f8d78","type":"dsm","z":"21cd0d76.58b4c2","name":"DSM","sm_config":"{\n    \"triggerInput\": \"payload\",\n    \"currentState\": \"running\",\n    \"states\": {\n        \"stopped\": {\n            \"0\": \"running\"\n        },\n        \"running\": {\n            \"1\": \"stopped\"\n        }\n    },\n    \"methods\": {\n        \"onBeforeTransition\": \"msg.pyload = msg.payload.toString();\",\n        \"0\": \"sta.fill='green';msg.background='green';msg.label='Lazer 6 Çalışıyor';\",\n        \"1\": \"sta.fill='red';msg.background='red';msg.label='Lazer 6 Arızalı!!!';\"\n    }\n}","x":359,"y":237,"wires":[["382ec9e2.c998f6"]]},{"id":"382ec9e2.c998f6","type":"ui_button","z":"21cd0d76.58b4c2","name":"Lazer 6","group":"31462797.454d08","order":0,"width":"6","height":"1","passthru":false,"label":"{{msg.label}}","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":528,"y":237,"wires":[[]]},{"id":"c57d4905.4685d8","type":"rpi-dht22","z":"21cd0d76.58b4c2","name":"","topic":"Dht11","dht":"11","pintype":"0","pin":4,"x":373.5,"y":452,"wires":[["64b07a62.7fd784","364a02f0.de262e","558d8401.c906dc"]]},{"id":"64b07a62.7fd784","type":"debug","z":"21cd0d76.58b4c2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":604,"y":417,"wires":[]},{"id":"a0242bfd.c9fe18","type":"rpi-gpio in","z":"21cd0d76.58b4c2","name":"","pin":"7","intype":"tri","debounce":"25","read":false,"x":180.5,"y":456,"wires":[["c57d4905.4685d8"]]},{"id":"a90ef1a9.d0e2f","type":"inject","z":"21cd0d76.58b4c2","name":"","topic":"","payload":"","payloadType":"date","repeat":"30","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":422,"wires":[["c57d4905.4685d8"]]},{"id":"41c8816b.93176","type":"ui_chart","z":"21cd0d76.58b4c2","name":"","group":"8c43dcb3.40b64","order":0,"width":0,"height":0,"label":"Kabin İçi Nem","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"100","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":692.5,"y":509,"wires":[[],[]]},{"id":"970bd401.f11db8","type":"ui_chart","z":"21cd0d76.58b4c2","name":"","group":"8c43dcb3.40b64","order":0,"width":0,"height":0,"label":"Kabin İçi Sıcaklığı","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"60","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":669.5,"y":353,"wires":[[],[]]},{"id":"558d8401.c906dc","type":"function","z":"21cd0d76.58b4c2","name":"Sıcaklık","func":"msg.payload = msg.payload\nreturn msg;","outputs":1,"noerr":0,"x":494.5,"y":356,"wires":[["970bd401.f11db8","92648a3e.0a99c8","2722de5a.9641f2"]]},{"id":"364a02f0.de262e","type":"function","z":"21cd0d76.58b4c2","name":"Nem","func":"msg.payload = msg.humidity\nreturn msg;","outputs":1,"noerr":0,"x":511.5,"y":486,"wires":[["41c8816b.93176","f9d557f9.2885a8","2722de5a.9641f2"]]},{"id":"92648a3e.0a99c8","type":"ui_gauge","z":"21cd0d76.58b4c2","name":"","group":"91e2c0f.7b7494","order":0,"width":0,"height":0,"gtype":"gage","title":"","label":"C","format":"{{value}}","min":0,"max":"50","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":662.5,"y":315,"wires":[]},{"id":"f9d557f9.2885a8","type":"ui_gauge","z":"21cd0d76.58b4c2","name":"","group":"8c43dcb3.40b64","order":0,"width":0,"height":0,"gtype":"gage","title":"","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":663.5,"y":475,"wires":[]},{"id":"2722de5a.9641f2","type":"file","z":"21cd0d76.58b4c2","name":"","filename":"Deneme","appendNewline":true,"createDir":true,"overwriteFile":"false","x":955,"y":396,"wires":[[]]},{"id":"31462797.454d08","type":"ui_group","z":"","name":"Lazer Markalama Tesisi","tab":"30a9b4bc.f7640c","disp":true,"width":"6","collapse":false},{"id":"8c43dcb3.40b64","type":"ui_group","z":"","name":"Lazer Markalama Tesisi ","tab":"30a9b4bc.f7640c","disp":true,"width":"6","collapse":false},{"id":"91e2c0f.7b7494","type":"ui_group","z":"","name":"Lazer Markalama Tesisi  ","tab":"30a9b4bc.f7640c","disp":true,"width":"6","collapse":false},{"id":"30a9b4bc.f7640c","type":"ui_tab","z":"","name":"Montaj Bantları","icon":"dashboard"}]

and it is saving data like only this

25.00
48.00
25.00
48.00
25.00
48.00
25.00
48.00


#15

Well looking at your flow, all you are sending to the file is the temperature and humidity values. If you want it to be something like
Temp : 26C
then in your function 'Sıcaklık' you will have to create that string sometning like this

msg.payload = "Temp : " + msg.payload;
return msg;

#16

Dear @zenofmud I Need just time after my sensors value. Just it is showing value in text file
I need to log it like this. Thanks for your advance..

26C 17.10.2018-08.22
47% 17.10.2018-08.22


#17

One small thing for when you work this out. You will be a lot better off using an ISO/RFC format to store your date/time values. That will make them a lot easier to consume again.

2018-10-17 17:10 would be a better format or a full format like 2018-10-17T17:10:00Z is even better for processing though not quite so good for human viewing without processing. These formats are sortable and unambiguous. They can also be processed using standard JavaScript functions.


#18

Thanks for your advance.
How can I store my datas which is you are showing me, what kind of node or script code I have to use ?

help me please ?


#19

That depends on what you want to do with the data. If you want to draw historical graphs then I highly recommend using Influxdb to store the data and Grafana to display it. There is an influxdb node that allows saving the data very easily.
If you want to do this then first google for influxdb and grafana and spend some time reading about how they work. By some time I mean hours at least. Then look at the influxdb node to see how to store the values.


#20

Ok, because of the way you have your flow setup (i.e. you send the values to graphs AND the log) you are going to have to make a choice of how you want to add the time/date to the msg.payload.

First off, there is no reason to have the function node 'Sıcaklık' since all it does is set msg.payload = msg.payload; and you could use a change node in place of the 'Nem' function node.

BUT since you have them, you could expand them to return two msg's one containing just the value to send to the graphs and another where you add the timestamp after the value to send to the log.

You should read the documentation (https://nodered.org/docs/writing-functions) and read about how to get the data/time in javascript (https://www.w3schools.com/js/js_dates.asp) and how to work with javascript string operators (https://www.w3schools.com/js/js_operators.asp)

Once you understand all that, you should have no problem solving your issue your self and have increased your knowledge base.