Send values to an array, write to CSV when full

Heya folks

I have a project underway which will read sensor values and write to a CSV file. So far with 1 sensor I managed to add a timestamp and value to the file in CSV format with each read. I think in order to be most efficient it would be best to red all 6 sensors consecutively (modbus), update an array, write to CSV, repeat. This needs to be done as fast as possible. Essentially 1 timestamp and then the 6 sensor values comma seperated. Have only added 2 sensors at the moment

I suck and am a complete Noob at java script. Any push in the right direction would be of great help. What I've done so far is prob quite easy to understand, so hoping someone could have a quick look.

Thanks!

[{"id":"4d95c064.56bc5","type":"modbus-flex-getter","z":"fb27fd6.2ca3f","name":"test","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"daab589a.cd8e08","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":650,"y":340,"wires":[["511817c3.98bf08"],[]]},{"id":"5fca0e71.449cb","type":"function","z":"fb27fd6.2ca3f","name":"function","func":"msg.payload = { \n    'fc': 4, \n    'unitid': 1, \n    'address': 1010, \n    'quantity': 2 \n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":500,"y":340,"wires":[["4d95c064.56bc5"]]},{"id":"511817c3.98bf08","type":"modbus-response","z":"fb27fd6.2ca3f","name":"","registerShowMax":20,"x":890,"y":380,"wires":[]},{"id":"46ee83e8.c042ac","type":"debug","z":"fb27fd6.2ca3f","name":"","active":true,"console":"false","complete":"payload","x":870,"y":340,"wires":[]},{"id":"5673c892.5d8d58","type":"function","z":"fb27fd6.2ca3f","name":"payload","func":"msg.payload = { value: 0 , 'fc': 6, 'unitid': 1, 'address': 1010 , 'quantity': 1 }; return msg","outputs":1,"noerr":0,"x":500,"y":100,"wires":[["3ffcdcbb.fa5c44"]]},{"id":"3ffcdcbb.fa5c44","type":"modbus-flex-write","z":"fb27fd6.2ca3f","name":"Auto Range Off","showStatusActivities":false,"showErrors":false,"server":"daab589a.cd8e08","x":680,"y":100,"wires":[["be36ee78.71b1e"],[]]},{"id":"be36ee78.71b1e","type":"modbus-response","z":"fb27fd6.2ca3f","name":"","registerShowMax":20,"x":890,"y":100,"wires":[]},{"id":"7ee1a410.aae57c","type":"comment","z":"fb27fd6.2ca3f","name":"Set Auto Range To Off","info":"Specifies whether automatic range selection is used\n0 – the measurement range written to the RangeRegister is used for UV value\nacquirement\n1 – the sensor selects the measurement range automatically. If set, the RangeRegister\nwill be read only. After starting the sensor the AutoRangeRegister is set to 1.´ ","x":260,"y":60,"wires":[]},{"id":"a864fe69.12a84","type":"function","z":"fb27fd6.2ca3f","name":"payload","func":"msg.payload = { value: 4 , 'fc': 6, 'unitid': 1, 'address': 1011 , 'quantity': 1 }; return msg","outputs":1,"noerr":0,"x":500,"y":220,"wires":[["47d8297e.06e058"]]},{"id":"47d8297e.06e058","type":"modbus-flex-write","z":"fb27fd6.2ca3f","name":"Set Range","showStatusActivities":false,"showErrors":false,"server":"daab589a.cd8e08","x":670,"y":220,"wires":[["2ceec987.77e3e6"],[]]},{"id":"2ceec987.77e3e6","type":"modbus-response","z":"fb27fd6.2ca3f","name":"","registerShowMax":20,"x":890,"y":220,"wires":[]},{"id":"c057ae0f.ebe7a","type":"comment","z":"fb27fd6.2ca3f","name":"Set Range Register To Pre-defined Range","info":"Second Number:\n0 – reserved\n1 – range 1 (highest sensitivity)\n2 – range 2\n3 – range 3\n4 – range 4\n…","x":320,"y":180,"wires":[]},{"id":"a1d6ac1d.b4436","type":"comment","z":"fb27fd6.2ca3f","name":"Read Range Register Settings","info":"First Number:\n0 = Custom setting written in following node\n1 = Auto - Sensor selects\n\nSecond Number:\n0 – reserved\n1 – range 1 (highest sensitivity)\n2 – range 2\n3 – range 3\n4 – range 4\n…","x":280,"y":300,"wires":[]},{"id":"305daf6e.650b5","type":"modbus-flex-getter","z":"fb27fd6.2ca3f","name":"Get UV","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"daab589a.cd8e08","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":640,"y":520,"wires":[["ed72ec53.2ef5b","ed72baf.7f76548","36c0fcd1.3aff54"],["1fd33e83.bba581"]]},{"id":"777665c0.38b99c","type":"inject","z":"fb27fd6.2ca3f","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":320,"y":520,"wires":[["b38adfe9.8ee28","a180f114.be998"]]},{"id":"b38adfe9.8ee28","type":"function","z":"fb27fd6.2ca3f","name":"function","func":"msg.payload = { \n    'fc': 3, \n    'unitid': 1, \n    'address': 1000, \n    'quantity': 2 \n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":480,"y":520,"wires":[["305daf6e.650b5"]]},{"id":"ed72ec53.2ef5b","type":"modbus-response","z":"fb27fd6.2ca3f","name":"","registerShowMax":20,"x":870,"y":560,"wires":[]},{"id":"36c0fcd1.3aff54","type":"debug","z":"fb27fd6.2ca3f","name":"","active":true,"console":"false","complete":"payload","x":850,"y":520,"wires":[]},{"id":"2fb7ea7f.9467e6","type":"comment","z":"fb27fd6.2ca3f","name":"Read UV Range Registers","info":"","x":270,"y":420,"wires":[]},{"id":"65c0f113.6a59a","type":"inject","z":"fb27fd6.2ca3f","name":"","topic":"Startup","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"x":130,"y":100,"wires":[["6e81187b.4de8e8"]]},{"id":"3f3d1804.6bf9c8","type":"delay","z":"fb27fd6.2ca3f","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":330,"y":220,"wires":[["a864fe69.12a84","d88af0de.d7ce5"]]},{"id":"d88af0de.d7ce5","type":"delay","z":"fb27fd6.2ca3f","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":330,"y":340,"wires":[["5fca0e71.449cb"]]},{"id":"6e81187b.4de8e8","type":"delay","z":"fb27fd6.2ca3f","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":330,"y":100,"wires":[["5673c892.5d8d58","3f3d1804.6bf9c8"]]},{"id":"ed72baf.7f76548","type":"split","z":"fb27fd6.2ca3f","name":"","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":470,"y":640,"wires":[["41c5b592.1698cc"]]},{"id":"41c5b592.1698cc","type":"switch","z":"fb27fd6.2ca3f","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":590,"y":640,"wires":[[],["ebfc77e0.ea0c18"]]},{"id":"7fd901bc.d02f6","type":"csv","z":"fb27fd6.2ca3f","name":"","sep":",","hdrin":true,"hdrout":false,"multi":"mult","ret":"\\n","temp":"time, payload","skip":"0","x":1030,"y":640,"wires":[["c9135c11.57caf"]]},{"id":"ebfc77e0.ea0c18","type":"change","z":"fb27fd6.2ca3f","name":"","rules":[{"t":"set","p":"object","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":640,"wires":[["af39f313.4f3ff"]]},{"id":"c9135c11.57caf","type":"file","z":"fb27fd6.2ca3f","name":"\\log.csv","filename":"log.csv","appendNewline":false,"createDir":true,"overwriteFile":"false","x":1160,"y":640,"wires":[[]]},{"id":"af39f313.4f3ff","type":"function","z":"fb27fd6.2ca3f","name":"javascript","func":"var date;\ndate = new Date();\ndate = (date.getFullYear() + '-' + ('00' + (date.getMonth()+1)).slice(-2) + '-' + ('00' + date.getDate()).slice(-2) + ' ' + ('00' + date.getHours()).slice(-2) + ':' + ('00' + date.getMinutes()).slice(-2) + ':' + ('00' + date.getSeconds()).slice(-2));\npayload = {\"time\":date, \"payload\":msg.object};\nmsg.payload=payload;\nreturn msg;","outputs":1,"noerr":0,"x":900,"y":640,"wires":[["7fd901bc.d02f6","38098473.1125bc"]]},{"id":"38098473.1125bc","type":"debug","z":"fb27fd6.2ca3f","name":"","active":true,"console":"false","complete":"payload","x":1070,"y":580,"wires":[]},{"id":"1e95de21.ba8032","type":"function","z":"fb27fd6.2ca3f","name":"function","func":"msg.payload = { \n    'fc': 3, \n    'unitid': 2, \n    'address': 1000, \n    'quantity': 2 \n} ;\nreturn msg;\n","outputs":1,"noerr":0,"x":480,"y":740,"wires":[["d444efbe.8f1"]]},{"id":"a180f114.be998","type":"delay","z":"fb27fd6.2ca3f","name":"","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":330,"y":740,"wires":[["1e95de21.ba8032"]]},{"id":"d444efbe.8f1","type":"modbus-flex-getter","z":"fb27fd6.2ca3f","name":"Get UV","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"daab589a.cd8e08","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":640,"y":740,"wires":[["d224553f.7df358","c7366315.74594","6dd70ef6.9477f"],[]]},{"id":"8f5ba873.372ab8","type":"change","z":"fb27fd6.2ca3f","name":"","rules":[{"t":"set","p":"object","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":840,"wires":[[]]},{"id":"c2d7d067.01bcb","type":"switch","z":"fb27fd6.2ca3f","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":590,"y":840,"wires":[[],["8f5ba873.372ab8"]]},{"id":"d224553f.7df358","type":"split","z":"fb27fd6.2ca3f","name":"","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":470,"y":840,"wires":[["c2d7d067.01bcb"]]},{"id":"c7366315.74594","type":"debug","z":"fb27fd6.2ca3f","name":"","active":true,"console":"false","complete":"payload","x":850,"y":740,"wires":[]},{"id":"6dd70ef6.9477f","type":"modbus-response","z":"fb27fd6.2ca3f","name":"","registerShowMax":20,"x":870,"y":780,"wires":[]},{"id":"1fd33e83.bba581","type":"debug","z":"fb27fd6.2ca3f","name":"","active":true,"console":"false","complete":"payload","x":1170,"y":480,"wires":[]},{"id":"710889.f0c52778","type":"comment","z":"fb27fd6.2ca3f","name":"Change Function node to set Unit-ID. Leave Unit-ID blank in server setup","info":"","x":440,"y":460,"wires":[]},{"id":"a90a598a.3eecc8","type":"comment","z":"fb27fd6.2ca3f","name":"Next try to add values of sensor 2 into the CSV file.. See how fast can be written. OR read all 6 sensors, write to array then update CSV with 1 timestamp","info":"testing testing","x":660,"y":940,"wires":[]},{"id":"daab589a.cd8e08","type":"modbus-client","z":"","name":"modbus","clienttype":"serial","bufferCommands":false,"stateLogEnabled":false,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyS2","serialType":"RTU-BUFFERD","serialBaudrate":"19200","serialDatabits":"8","serialStopbits":"1","serialParity":"even","serialConnectionDelay":"1","unit_id":"","commandDelay":"1","clientTimeout":"1000","reconnectTimeout":"1000"}]

edit your post and use:

3 backticks: `

your code

end with 3 backticks: `

Think I did it....Doesn't appear to have changed

You didn't.

(edited it for you... the backticks need to be on a separate line)

This sounds like a perfect job for a join node set to create an array and send the message once you've received 100 elements.

edit: like so:

[{"id":"edce42b4.209a2","type":"inject","z":"5936699f.67912","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":220,"wires":[["300a7ece.66fcba"]]},{"id":"300a7ece.66fcba","type":"join","z":"5936699f.67912","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"100","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":290,"y":220,"wires":[["e08afffe.ac5288"]]},{"id":"e08afffe.ac5288","type":"csv","z":"5936699f.67912","name":"","sep":",","hdrin":"","hdrout":"","multi":"one","ret":"\\n","temp":"","skip":"0","x":410,"y":220,"wires":[["4e0ff03d.ca3f4"]]},{"id":"4e0ff03d.ca3f4","type":"file","z":"5936699f.67912","name":"","filename":"","appendNewline":true,"createDir":false,"overwriteFile":"false","x":530,"y":220,"wires":[[]]}]

Indeed, sounds a straightforward approach.

Considering that the output of the modbus node already gives you an array of all 6 sensors then all you will need is to insert the timestamp as the first element of this array. You can modify the function node that generates the timestamp adding one line of code as below:

var date;
date = new Date();
date = (date.getFullYear() + '-' + ('00' + (date.getMonth()+1)).slice(-2) + '-' + ('00' + date.getDate()).slice(-2) + ' ' + ('00' + date.getHours()).slice(-2) + ':' + ('00' + date.getMinutes()).slice(-2) + ':' + ('00' + date.getSeconds()).slice(-2));

msg.payload.unshift(date);
return msg;

The function node would need to be connected between the modbus node that reads the values and the CSV node.

Each line of the generated CSV file will look like (reading two values (3 and 4) in this example:

2019-05-14 10:57:36,3,4

Sorry for the late reply but boy am I busy. About to try your suggestions. Thanks all who helped out....I'll be sure to remember the 3 back ticks :slight_smile:

Heya folks. So I seem to have managed to get an array of 6 values and update the csv file.

I'm wondering if it's possible to create a loop so the sensors are continuously read after say a switch is switched on the dashboard. I managed to create a button with message pass through and that worked, however a switch that could be turned on and off is what I want. When using a switch it doesn't seem to loop and only reads the sensors once.

Hey look, all the boys are here....Can I get the final code?
I have high speed sensors and I want to add a button to capture when I start a test run.
Here is how far I've gotten.

[{"id":"64790db0.313854","type":"serial in","z":"ff00b690.4e7c68","name":"Pressure Sensor","serial":"6bd65ea6.e09bb","x":100,"y":860,"wires":[["51c57ee2.7609e8","fb869ad3.8b11b8"]]},{"id":"c285cb2f.a9e978","type":"serial in","z":"ff00b690.4e7c68","name":"Pressure Sensor","serial":"2c0b7c2c.56bcf4","x":100,"y":920,"wires":[["a61a1c9a.108c4","fb869ad3.8b11b8"]]},{"id":"15e9f167.1c32f7","type":"debug","z":"ff00b690.4e7c68","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":930,"y":860,"wires":[]},{"id":"fb869ad3.8b11b8","type":"function","z":"ff00b690.4e7c68","name":"IEEE-754 to float","func":"var buf = Buffer.from([0x0,0x0,0x0,0x0,0x0,0x0]);\nbuf = msg.payload;\nmsg.payload = buf.readFloatLE(2);\nreturn msg","outputs":1,"noerr":0,"x":390,"y":860,"wires":[["7f9d9fd1.41be8"]]},{"id":"7f9d9fd1.41be8","type":"buffer-array","z":"ff00b690.4e7c68","name":"","bufferLen":"256","startWhenFilled":true,"x":570,"y":860,"wires":[["b366d155.ec238"]]},{"id":"b366d155.ec238","type":"file","z":"ff00b690.4e7c68","name":"","filename":"/home/pi/pressure.txt","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":760,"y":860,"wires":[["15e9f167.1c32f7"]]},{"id":"6bd65ea6.e09bb","type":"serial-port","z":"","serialport":"/dev/ttyUSB0","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","waitfor":"0xAA","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"6","bin":"bin","out":"count","addchar":"","responsetimeout":"10000"},{"id":"2c0b7c2c.56bcf4","type":"serial-port","z":"","serialport":"/dev/ttyUSB1","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","waitfor":"0xAA","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"6","bin":"bin","out":"count","addchar":"","responsetimeout":"10000"}]

Lots to do.

  1. Add timestamp column 1
  2. Add start/stop button
  3. separate sensor data into column 2 and column 3
  4. Get newline working in the file. The 256 values are coma separated in between

Have it a little further. Added switch and used gate node. I like gate node.... :yum:

[{"id":"762a2056.5d3d98","type":"serial in","z":"9698e3e6.4cacc","name":"Pressure Sensor","serial":"6bd65ea6.e09bb","x":120,"y":300,"wires":[["c69c4644.1062"]]},{"id":"d5decb78.470218","type":"serial in","z":"9698e3e6.4cacc","name":"Pressure Sensor","serial":"2c0b7c2c.56bcf4","x":120,"y":360,"wires":[["c69c4644.1062"]]},{"id":"df539f28.90048","type":"debug","z":"9698e3e6.4cacc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1350,"y":300,"wires":[]},{"id":"c69c4644.1062","type":"function","z":"9698e3e6.4cacc","name":"IEEE-754 to float","func":"var buf = Buffer.from([0x0,0x0,0x0,0x0,0x0,0x0]);\nbuf = msg.payload;\nmsg.payload = buf.readFloatLE(2);\nreturn msg","outputs":1,"noerr":0,"x":330,"y":360,"wires":[["5e5f696c.62bb28"]]},{"id":"5e5f696c.62bb28","type":"buffer-array","z":"9698e3e6.4cacc","name":"","bufferLen":"256","startWhenFilled":true,"x":510,"y":360,"wires":[["189cc774.5d2609"]]},{"id":"bd279580.31be98","type":"file","z":"9698e3e6.4cacc","name":"","filename":"/home/pi/pressure.txt","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":1140,"y":360,"wires":[["df539f28.90048"]]},{"id":"189cc774.5d2609","type":"gate","z":"9698e3e6.4cacc","name":"","controlTopic":"control","defaultState":"closed","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":970,"y":360,"wires":[["bd279580.31be98"]]},{"id":"9d0d60fd.7c12a","type":"mqtt in","z":"9698e3e6.4cacc","name":"Reset","topic":"Reset","qos":"2","datatype":"auto","broker":"6b8f56d7.82af78","x":290,"y":300,"wires":[["e52d831d.250e5"]]},{"id":"d6d39f8.06241e","type":"function","z":"9698e3e6.4cacc","name":"Push Button","func":"var state = context.get(\"STATE\")||0;\n\n//  Look for a !X message to get values.\nif (msg.payload != \"X\")     //Do this if the message is NOT \"X\"\n{\n    //\n    //  Background colours first.\n    //\n    context.set(\"ABGC\", msg.colourA);\n    context.set(\"BBGC\", msg.colourB);\n    //\n    //  Now do text.\n    //\n    context.set(\"Atxt\", msg.txtA);\n    context.set(\"Btxt\", msg.txtB);\n    //\n    //  Font colours.\n    //\n    context.set(\"AFC\",msg.txtclrA);\n    context.set(\"BFC\",msg.txtclrB);\n    //\n    //  Payloads.\n    //\n    context.set(\"PayloadA\", msg.payloadA);\n    context.set(\"PayloadB\", msg.payloadB);\n    //\n    //  Icons.\n    //\n    context.set(\"icon_on\", msg.icon_on);\n    context.set(\"icon_off\", msg.icon_off);\n    //\n    //  Topic.\n    //\n    if (msg.topicSET !== null)\n    {\n        context.set(\"Topic\",msg.topicSET);\n    } else\n    {\n        context.set(\"Topic\",\"~\");\n    }\n    return;\n}\n//      Now on to the real stuff.\nif (msg.payload == \"X\")\n{\n    state = (state + 1)% 2;\n    //node.warn(state);\n    context.set(\"STATE\",state);\n}\nif (state === 0)\n{\n    //  Condition A\n    msg.payload = context.get(\"PayloadA\");\n    msg.colour = context.get(\"ABGC\");\n    msg.txt = context.get(\"icon_off\")+context.get(\"Atxt\");\n    msg.fontclr = context.get(\"AFC\");\n    msg.icon = context.get(\"icon_off\");\n} else\n{\n    //  Condition B\n    msg.payload = context.get(\"PayloadB\");\n    msg.colour = context.get(\"BBGC\");\n    msg.txt = context.get(\"icon_on\")+context.get(\"Btxt\");\n    msg.fontclr = context.get(\"BFC\");\n    msg.icon = context.get(\"icon_on\");\n}\nif (context.get(\"Topic\") == \"~\")\n{\n    msg.topic = \"\";\n} else\n{\n    msg.topic = context.get(\"Topic\");\n}\nreturn msg;\n","outputs":1,"noerr":0,"x":590,"y":260,"wires":[["ec9fddbb.d983f8"]]},{"id":"ec9fddbb.d983f8","type":"ui_button","z":"9698e3e6.4cacc","name":"Log to File","group":"3bbd2a48.7b1926","order":3,"width":3,"height":3,"passthru":false,"label":"{{msg.txt}}","tooltip":"","color":"{{msg.fontclr}}","bgcolor":"{{msg.colour}}","icon":"","payload":"X","payloadType":"str","topic":"","x":590,"y":300,"wires":[["d6d39f8.06241e","4d0d45ba.cd4f14"]]},{"id":"e52d831d.250e5","type":"function","z":"9698e3e6.4cacc","name":"Setup","func":"msg = {\n    \"colourA\": \"red\",\n    \"colourB\": \"green\",\n    \"txtA\": \"Off\",\n    \"txtB\": \"On\",\n    \"txtclrA\": \"black\",\n    \"txtclrB\": \"white\",\n    \"payloadA\": \"0\",\n    \"payloadB\": \"1\",\n    \"icon_off\": '<i class=\"fa fa-2x fa-toggle-off\"></i> ',\n    \"icon_on\": '<i class=\"fa fa-2x fa-toggle-on\"></i> ',\n    \"topicSET\": \"Control\"\n}\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":300,"wires":[["d6d39f8.06241e"]]},{"id":"4d0d45ba.cd4f14","type":"change","z":"9698e3e6.4cacc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"toggle","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":300,"wires":[["189cc774.5d2609","df539f28.90048"]]},{"id":"6bd65ea6.e09bb","type":"serial-port","z":"","serialport":"/dev/ttyUSB0","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","waitfor":"0xAA","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"6","bin":"bin","out":"count","addchar":"","responsetimeout":"10000"},{"id":"2c0b7c2c.56bcf4","type":"serial-port","z":"","serialport":"/dev/ttyUSB1","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","waitfor":"0xAA","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"6","bin":"bin","out":"count","addchar":"","responsetimeout":"10000"},{"id":"6b8f56d7.82af78","type":"mqtt-broker","z":"","name":"PI","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"home/temperature","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"3bbd2a48.7b1926","type":"ui_group","z":"","name":"Recipe","tab":"659e4ebd.42aa68","order":1,"disp":true,"width":21,"collapse":false},{"id":"659e4ebd.42aa68","type":"ui_tab","z":"","name":"Pump Control Recipe","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

OK, I have both sensors logging correctly.

[{"id":"62d42c2c.7c7a2c","type":"serial in","z":"ba2f6d7c.cf6ba8","name":"Pressure Sensor","serial":"6bd65ea6.e09bb","x":140,"y":100,"wires":[["9070f54a.1947b8"]]},{"id":"6a8624d6.72b2b4","type":"serial in","z":"ba2f6d7c.cf6ba8","name":"Pressure Sensor","serial":"2c0b7c2c.56bcf4","x":140,"y":160,"wires":[["9070f54a.1947b8"]]},{"id":"1e5d3fab.6a7a3","type":"debug","z":"ba2f6d7c.cf6ba8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1090,"y":120,"wires":[]},{"id":"9070f54a.1947b8","type":"function","z":"ba2f6d7c.cf6ba8","name":"IEEE-754 to float","func":"var buf = Buffer.from([0x0,0x0,0x0,0x0,0x0,0x0]);\nbuf = msg.payload;\nmsg.pressure = buf.readFloatLE(2);\nreturn msg","outputs":1,"noerr":0,"x":350,"y":160,"wires":[["dbe7820.01115"]]},{"id":"c17f79f6.5f9dc8","type":"file","z":"ba2f6d7c.cf6ba8","name":"","filename":"/home/pi/pressure.txt","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":1320,"y":160,"wires":[[]]},{"id":"dbe7820.01115","type":"gate","z":"ba2f6d7c.cf6ba8","name":"","controlTopic":"control","defaultState":"closed","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":590,"y":160,"wires":[["d3f6403d.5aa938"]]},{"id":"39053e45.aff052","type":"mqtt in","z":"ba2f6d7c.cf6ba8","name":"Reset","topic":"Reset","qos":"2","datatype":"auto","broker":"6b8f56d7.82af78","x":310,"y":100,"wires":[["81b0937a.36d388"]]},{"id":"1ddc50d3.89a467","type":"function","z":"ba2f6d7c.cf6ba8","name":"Push Button","func":"var state = context.get(\"STATE\")||0;\n\n//  Look for a !X message to get values.\nif (msg.payload != \"X\")     //Do this if the message is NOT \"X\"\n{\n    //\n    //  Background colours first.\n    //\n    context.set(\"ABGC\", msg.colourA);\n    context.set(\"BBGC\", msg.colourB);\n    //\n    //  Now do text.\n    //\n    context.set(\"Atxt\", msg.txtA);\n    context.set(\"Btxt\", msg.txtB);\n    //\n    //  Font colours.\n    //\n    context.set(\"AFC\",msg.txtclrA);\n    context.set(\"BFC\",msg.txtclrB);\n    //\n    //  Payloads.\n    //\n    context.set(\"PayloadA\", msg.payloadA);\n    context.set(\"PayloadB\", msg.payloadB);\n    //\n    //  Icons.\n    //\n    context.set(\"icon_on\", msg.icon_on);\n    context.set(\"icon_off\", msg.icon_off);\n    //\n    //  Topic.\n    //\n    if (msg.topicSET !== null)\n    {\n        context.set(\"Topic\",msg.topicSET);\n    } else\n    {\n        context.set(\"Topic\",\"~\");\n    }\n    return;\n}\n//      Now on to the real stuff.\nif (msg.payload == \"X\")\n{\n    state = (state + 1)% 2;\n    //node.warn(state);\n    context.set(\"STATE\",state);\n}\nif (state === 0)\n{\n    //  Condition A\n    msg.payload = context.get(\"PayloadA\");\n    msg.colour = context.get(\"ABGC\");\n    msg.txt = context.get(\"icon_off\")+context.get(\"Atxt\");\n    msg.fontclr = context.get(\"AFC\");\n    msg.icon = context.get(\"icon_off\");\n} else\n{\n    //  Condition B\n    msg.payload = context.get(\"PayloadB\");\n    msg.colour = context.get(\"BBGC\");\n    msg.txt = context.get(\"icon_on\")+context.get(\"Btxt\");\n    msg.fontclr = context.get(\"BFC\");\n    msg.icon = context.get(\"icon_on\");\n}\nif (context.get(\"Topic\") == \"~\")\n{\n    msg.topic = \"\";\n} else\n{\n    msg.topic = context.get(\"Topic\");\n}\nreturn msg;\n","outputs":1,"noerr":0,"x":610,"y":60,"wires":[["2ad6b882.a366a8"]]},{"id":"2ad6b882.a366a8","type":"ui_button","z":"ba2f6d7c.cf6ba8","name":"Log to File","group":"3bbd2a48.7b1926","order":3,"width":3,"height":3,"passthru":false,"label":"{{msg.txt}}","tooltip":"","color":"{{msg.fontclr}}","bgcolor":"{{msg.colour}}","icon":"","payload":"X","payloadType":"str","topic":"","x":610,"y":100,"wires":[["1ddc50d3.89a467","154447f1.a99278"]]},{"id":"81b0937a.36d388","type":"function","z":"ba2f6d7c.cf6ba8","name":"Setup","func":"msg = {\n    \"colourA\": \"red\",\n    \"colourB\": \"green\",\n    \"txtA\": \"Off\",\n    \"txtB\": \"On\",\n    \"txtclrA\": \"black\",\n    \"txtclrB\": \"white\",\n    \"payloadA\": \"0\",\n    \"payloadB\": \"1\",\n    \"icon_off\": '<i class=\"fa fa-2x fa-toggle-off\"></i> ',\n    \"icon_on\": '<i class=\"fa fa-2x fa-toggle-on\"></i> ',\n    \"topicSET\": \"Control\"\n}\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":100,"wires":[["1ddc50d3.89a467"]]},{"id":"154447f1.a99278","type":"change","z":"ba2f6d7c.cf6ba8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"toggle","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":100,"wires":[["dbe7820.01115"]]},{"id":"d3f6403d.5aa938","type":"function","z":"ba2f6d7c.cf6ba8","name":"javascript","func":"var date;\ndate = new Date();\ndate = (date.getFullYear() + '-' + ('00' + (date.getMonth()+1)).slice(-2) + '-' + ('00' + date.getDate()).slice(-2) + ' ' + ('00' + date.getHours()).slice(-2) + ':' + ('00' + date.getMinutes()).slice(-2) + ':' + ('00' + date.getSeconds()).slice(-2) + ':' + ('00' + date.getMilliseconds()).slice(-2));\npayload = {\"time\":date, \"port\":msg.port, \"pressure\":msg.pressure};\nmsg.payload=payload;\nreturn msg;","outputs":1,"noerr":0,"x":840,"y":160,"wires":[["c91bcc31.79ed78","1e5d3fab.6a7a3"]]},{"id":"c91bcc31.79ed78","type":"csv","z":"ba2f6d7c.cf6ba8","name":"","sep":",","hdrin":true,"hdrout":false,"multi":"mult","ret":"\\n","temp":"time,port,pressure","skip":"0","strings":false,"x":1090,"y":160,"wires":[["c17f79f6.5f9dc8"]]},{"id":"6bd65ea6.e09bb","type":"serial-port","z":"","serialport":"/dev/ttyUSB0","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","waitfor":"0xAA","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"6","bin":"bin","out":"count","addchar":"","responsetimeout":"10000"},{"id":"2c0b7c2c.56bcf4","type":"serial-port","z":"","serialport":"/dev/ttyUSB1","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","waitfor":"0xAA","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"6","bin":"bin","out":"count","addchar":"","responsetimeout":"10000"},{"id":"6b8f56d7.82af78","type":"mqtt-broker","z":"","name":"PI","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"home/temperature","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"3bbd2a48.7b1926","type":"ui_group","z":"","name":"Recipe","tab":"659e4ebd.42aa68","order":1,"disp":true,"width":21,"collapse":false},{"id":"659e4ebd.42aa68","type":"ui_tab","z":"","name":"Pump Control Recipe","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

Thank You for the flow and the time stamp...I added milliseconds because the sensors do overlap.

Reset is a system wide reset after the first 15 seconds so that no valves or other devices are in a quasi-state. It acts as the shutdown/stop button

2020-07-06 20:32:15:70,/dev/ttyUSB1,14.888545036315918
2020-07-06 20:32:15:84,/dev/ttyUSB0,13.991262435913086
2020-07-06 20:32:15:85,/dev/ttyUSB1,14.837444305419922
2020-07-06 20:32:15:02,/dev/ttyUSB0,14.04310417175293
2020-07-06 20:32:15:02,/dev/ttyUSB1,14.97156047821045