Heya!
First off I'm very new to Node Red and equally new to Javascript. Anyways, I have a modbus sensor here (soon to be 6), and have it up and running. After writing a couple registers I read a couple of registers and receive an array in which I take the 2nd part. This comes out as msg.payload : number.
Now....Ideally to begin I want to just get this going with one sensor and then expand from there. I'd like to write this value to a CSV file with a time since start in one column, and then the number read in the next. I'd read the sensor say 4 times in 1 second then drop down to the next row and have another 4 values.
Timing aside I am struggling to even get this number to a csv file. Using the whole array is no worries but once I split to a number it complains about not being the right format. I can't seem to change it to what I need for it to be logged into the CSV, let alone format the CSV properly!![]()
Any pro tips much appreciated, even specific reading material. I'm exhausted at this point. Have attached a screenshot and the node I'm stuck on.
Thanks!!![]()
[{"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":660,"y":460,"wires":[["ed72ec53.2ef5b","ed72baf.7f76548","36c0fcd1.3aff54"],]},{"id":"777665c0.38b99c","type":"inject","z":"fb27fd6.2ca3f","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":340,"y":460,"wires":[["b38adfe9.8ee28"]]},{"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":500,"y":460,"wires":[["305daf6e.650b5"]]},{"id":"ed72ec53.2ef5b","type":"modbus-response","z":"fb27fd6.2ca3f","name":"","registerShowMax":20,"x":890,"y":500,"wires":},{"id":"36c0fcd1.3aff54","type":"debug","z":"fb27fd6.2ca3f","name":"","active":true,"console":"false","complete":"payload","x":870,"y":460,"wires":},{"id":"2fb7ea7f.9467e6","type":"comment","z":"fb27fd6.2ca3f","name":"Read UV Range Registers","info":"","x":270,"y":420,"wires":},{"id":"a317912c.af168","type":"debug","z":"fb27fd6.2ca3f","name":"","active":true,"console":"false","complete":"payload","x":970,"y":660,"wires":},{"id":"ac70728e.37ff4","type":"debug","z":"fb27fd6.2ca3f","name":"","active":true,"console":"false","complete":"true","x":950,"y":620,"wires":},{"id":"ed72baf.7f76548","type":"split","z":"fb27fd6.2ca3f","name":"","splt":"\n","x":650,"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","outputs":2,"x":810,"y":640,"wires":[["ac70728e.37ff4"],["a317912c.af168"]]},{"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":"1","commandDelay":"1","clientTimeout":"1000","reconnectTimeout":"1000"}]
