Hello,
Im doing a project where I need to log temperatures into a file so that I can later make a model from it. This is my first time ever using Node Red/programming. Right now my flow produces the information I need and puts it in a .csv file, but it doesn't always put it in the right order. The correct order of things is the following picture:
This sometimes does happen, but it is inconsistent. Sometimes it shows temperature 4 first and then time and so on.
I've searched quite a bit and found something about msg.parts, though im not sure if this would help nor how it works since i know basically nothing about coding.
Im wondering if someone has a solution for my problem so that the data stays consistent. Following is a picture of my current flow:
[{"id":"3df14878.d252a8","type":"inject","z":"f2c9682d.170b58","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":240,"wires":[["41e561c7.8c85b","a3b74dd6.ce121","705db031.32cc","b0c0c50c.27b708","b1c75b0e.6da7c8"]]},{"id":"f42eebb5.255ff8","type":"file","z":"f2c9682d.170b58","name":"","filename":"/home/pi/Documents/temperatuur.csv","appendNewline":false,"createDir":false,"overwriteFile":"false","encoding":"none","x":1210,"y":400,"wires":[[]]},{"id":"41e561c7.8c85b","type":"sensor-ds18b20","z":"f2c9682d.170b58","name":"","topic":"","sensorid":"28-00000b6a22d2","timer":"1","repeat":false,"x":330,"y":340,"wires":[["a981cc06.ccafa"]]},{"id":"946d6118.f3616","type":"inject","z":"f2c9682d.170b58","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":100,"wires":[["42a9eb61.da3b04"]]},{"id":"42a9eb61.da3b04","type":"file","z":"f2c9682d.170b58","name":"","filename":"/home/pi/Documents/temperatuur.csv","appendNewline":true,"createDir":false,"overwriteFile":"delete","encoding":"none","x":440,"y":100,"wires":[[]]},{"id":"a981cc06.ccafa","type":"function","z":"f2c9682d.170b58","name":"temp_a22d2","func":"msg.topic = \"B-Temp1\"\npayload = msg.payload.temperature;\nmsg.payload = payload;\nreturn msg;","outputs":1,"noerr":0,"x":520,"y":340,"wires":[["117ce230.28395e"]]},{"id":"a3b74dd6.ce121","type":"sensor-ds18b20","z":"f2c9682d.170b58","name":"","topic":"","sensorid":"28-0300a279b846","timer":"1","repeat":false,"x":330,"y":380,"wires":[["b70f79d5.165f78"]]},{"id":"b70f79d5.165f78","type":"function","z":"f2c9682d.170b58","name":"temp_9b846","func":"msg.topic = \"C-Temp2\"\npayload = msg.payload.temperature;\nmsg.payload = payload;\nreturn msg;","outputs":1,"noerr":0,"x":521,"y":380,"wires":[["117ce230.28395e"]]},{"id":"117ce230.28395e","type":"join","z":"f2c9682d.170b58","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"5","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":750,"y":400,"wires":[["6665dc5b.c56b54","2e7bbdd4.104472"]]},{"id":"705db031.32cc","type":"function","z":"f2c9682d.170b58","name":"time","func":"msg.topic = \"A-tijd\"\nvar d = new Date();\nvar t = d.getTime();\npayload=t;\nmsg.payload=payload;\nreturn msg;","outputs":1,"noerr":0,"x":499,"y":300,"wires":[["117ce230.28395e"]]},{"id":"6665dc5b.c56b54","type":"csv","z":"f2c9682d.170b58","name":"","sep":",","hdrin":"","hdrout":"","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"x":970,"y":400,"wires":[["f42eebb5.255ff8"]]},{"id":"2e7bbdd4.104472","type":"debug","z":"f2c9682d.170b58","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":970,"y":340,"wires":[]},{"id":"b0c0c50c.27b708","type":"sensor-ds18b20","z":"f2c9682d.170b58","name":"","topic":"","sensorid":"28-00000b685e65","timer":"1","repeat":false,"x":330,"y":420,"wires":[["cf7ef99c.17f8d8"]]},{"id":"b1c75b0e.6da7c8","type":"sensor-ds18b20","z":"f2c9682d.170b58","name":"","topic":"","sensorid":"28-00000b68b38d","timer":"1","repeat":false,"x":330,"y":460,"wires":[["761561b5.82e8d"]]},{"id":"cf7ef99c.17f8d8","type":"function","z":"f2c9682d.170b58","name":"temp_85e65","func":"msg.topic = \"D-Temp3\"\npayload = msg.payload.temperature;\nmsg.payload = payload;\nreturn msg;","outputs":1,"noerr":0,"x":522,"y":420,"wires":[["117ce230.28395e"]]},{"id":"761561b5.82e8d","type":"function","z":"f2c9682d.170b58","name":"temp_8b38d","func":"msg.topic = \"E-Temp4\"\npayload = msg.payload.temperature;\nmsg.payload = payload;\nreturn msg;","outputs":1,"noerr":0,"x":523,"y":460,"wires":[["117ce230.28395e"]]}]