Node-RED – Voorbeeld – Modbus uitlezen en visualiseren (multisensor)
Voorbeelden voor het uitlezen van onze multisensors op node-red Multisensor HW v1.10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
var temp1 = parseFloat(msg.payload[0] + "." + msg.payload[1]); var temp2 = parseFloat(msg.payload[2] + "." + msg.payload[3]); var temp3 = parseFloat(msg.payload[4] + "." + msg.payload[5]); var hum = parseFloat(msg.payload[6] + "." + msg.payload[7]); var bar = parseFloat(msg.payload[8] + "." + msg.payload[9]); var co2 = parseFloat(msg.payload[10]); var lux = parseFloat(msg.payload[11]); var hw = msg.payload[15] + "." + msg.payload[16]; var mod = msg.payload[17]; var fw = msg.payload[18] + "." + msg.payload[19]; var msg1 = {payload:temp1}; var msg2 = {payload:temp2}; var msg3 = {payload:temp3}; var msg4 = {payload:hum}; var msg5 = {payload:bar}; var msg6 = {payload:co2}; var msg7 = {payload:lux}; var msg8 = {payload:hw}; var msg9 = {payload:mod}; var msg10 = {payload:fw}; return [msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9,msg10]; |
1 |
[{"id":"8e4709da.ff3438","type":"function","z":"72ca7ddb.f1fef4","name":"Array Parser","func":"var temp1 = parseFloat(msg.payload[0] + \".\" + msg.payload[1]);\nvar temp2 = parseFloat(msg.payload[2] + \".\" + msg.payload[3]);\nvar temp3 = parseFloat(msg.payload[4] + \".\" + msg.payload[5]);\nvar hum = parseFloat(msg.payload[6] + \".\" + msg.payload[7]);\nvar bar = parseFloat(msg.payload[8] + \".\" + msg.payload[9]);\nvar co2 = parseFloat(msg.payload[10]);\nvar lux = parseFloat(msg.payload[11]);\nvar hw = msg.payload[15] + \".\" + msg.payload[16];\nvar mod = msg.payload[17];\nvar fw = msg.payload[18] + \".\" + msg.payload[19];\n\nvar msg1 = {payload:temp1};\nvar msg2 = {payload:temp2};\nvar msg3 = {payload:temp3};\nvar msg4 = {payload:hum};\nvar msg5 = {payload:bar};\nvar msg6 = {payload:co2};\nvar msg7 = {payload:lux};\nvar msg8 = {payload:hw};\nvar msg9 = {payload:mod};\nvar msg10 = {payload:fw};\n\nreturn [msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9,msg10];","outputs":10,"noerr":0,"x":430,"y":340,"wires":[["74fad254.999e6c","9d30a15.79e5d6"],["3f6f89ca.9744d6","fd4a3cd3.a7826"],["cd157f85.13fde","7a5a8d32.dbfb14"],["8f42bf2b.987a8","10e05759.2d4e19"],["b8539fae.022d1","29a8885c.b0a468"],["2212dc2a.a66964","dc972f2.7ce30d"],["89f376c0.1fdeb8","d62073dc.3188c"],["7b7790ab.9c1e3"],["aa1a0305.03ba2"],["82ddd3da.7db21"]],"inputLabels":["msg"],"outputLabels":["temp","","","","","","","","",""]},{"id":"74fad254.999e6c","type":"ui_gauge","z":"72ca7ddb.f1fef4","name":"Temp DS18B20","group":"fab0db25.fb55b8","order":3,"width":0,"height":0,"gtype":"gage","title":"Temp DS18B20","label":"Graden C","format":"{{value}}","min":"5","max":"40","colors":["#00b500","#e6e600","#ca3838"],"seg1":"15","seg2":"30","x":760,"y":60,"wires":[]},{"id":"91d6bdd6.ab9f4","type":"modbus-read","z":"72ca7ddb.f1fef4","name":"MODBUS LEZEN","topic":"","showStatusActivities":false,"showErrors":false,"unitid":"1","dataType":"HoldingRegister","adr":"0","quantity":"24","rate":"2","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"5dffa21.0a6fe5c","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":170,"y":260,"wires":[["8e4709da.ff3438","92a24fc7.f32b8"],[]]},{"id":"92a24fc7.f32b8","type":"debug","z":"72ca7ddb.f1fef4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":430,"y":200,"wires":[]},{"id":"9d30a15.79e5d6","type":"ui_chart","z":"72ca7ddb.f1fef4","name":"Temp DS18B20 chart","group":"fab0db25.fb55b8","order":4,"width":0,"height":0,"label":"","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"5","ymax":"40","removeOlder":"2","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":780,"y":100,"wires":[[],[]]},{"id":"10e05759.2d4e19","type":"ui_chart","z":"72ca7ddb.f1fef4","name":"HumChart","group":"ed5e1c9c.66396","order":2,"width":0,"height":0,"label":"","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"20","ymax":"100","removeOlder":"2","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":750,"y":400,"wires":[[],[]]},{"id":"8f42bf2b.987a8","type":"ui_gauge","z":"72ca7ddb.f1fef4","name":"HumMeter","group":"ed5e1c9c.66396","order":1,"width":0,"height":0,"gtype":"gage","title":"Luchtvochtigheid","label":"%","format":"{{value}}","min":"20","max":"100","colors":["#0080ff","#0000ff","#0000a0"],"seg1":"40","seg2":"80","x":750,"y":360,"wires":[]},{"id":"29a8885c.b0a468","type":"ui_chart","z":"72ca7ddb.f1fef4","name":"BarChart","group":"81c9e14d.0b0e","order":2,"width":0,"height":0,"label":"","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"950","ymax":"1080","removeOlder":"2","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":740,"y":500,"wires":[[],[]]},{"id":"b8539fae.022d1","type":"ui_gauge","z":"72ca7ddb.f1fef4","name":"BarMeter","group":"81c9e14d.0b0e","order":1,"width":"5","height":"4","gtype":"gage","title":"Luchtdruk","label":"hPa","format":"{{value}}","min":"950","max":"1080","colors":["#0080ff","#0080ff","#0080ff"],"seg1":"","seg2":"","x":740,"y":460,"wires":[]},{"id":"dc972f2.7ce30d","type":"ui_chart","z":"72ca7ddb.f1fef4","name":"CO2Chart","group":"763642a9.9cd5fc","order":2,"width":0,"height":0,"label":"","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"410","ymax":"5000","removeOlder":"2","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":740,"y":600,"wires":[[],[]]},{"id":"2212dc2a.a66964","type":"ui_gauge","z":"72ca7ddb.f1fef4","name":"CO2Meter","group":"763642a9.9cd5fc","order":1,"width":"0","height":"0","gtype":"gage","title":"CO2","label":"PPM","format":"{{value}}","min":"410","max":"5000","colors":["#00b500","#e6e600","#ca3838"],"seg1":"1000","seg2":"2500","x":750,"y":560,"wires":[]},{"id":"82ddd3da.7db21","type":"ui_text","z":"72ca7ddb.f1fef4","group":"763642a9.9cd5fc","order":5,"width":0,"height":0,"name":"Firmware","label":"Firmware:","format":"{{msg.payload}}","layout":"row-spread","x":740,"y":840,"wires":[]},{"id":"aa1a0305.03ba2","type":"ui_text","z":"72ca7ddb.f1fef4","group":"763642a9.9cd5fc","order":4,"width":0,"height":0,"name":"Model","label":"Model:","format":"{{msg.payload}}","layout":"row-spread","x":730,"y":800,"wires":[]},{"id":"7b7790ab.9c1e3","type":"ui_text","z":"72ca7ddb.f1fef4","group":"763642a9.9cd5fc","order":3,"width":0,"height":0,"name":"Hardware","label":"Hardware:","format":"{{msg.payload}}","layout":"row-spread","x":740,"y":760,"wires":[]},{"id":"3f6f89ca.9744d6","type":"ui_gauge","z":"72ca7ddb.f1fef4","name":"Temp BME280","group":"ed5e1c9c.66396","order":3,"width":0,"height":0,"gtype":"gage","title":"Temp BME280","label":"Graden C","format":"{{value}}","min":"5","max":"40","colors":["#00b500","#e6e600","#ca3838"],"seg1":"15","seg2":"30","x":760,"y":160,"wires":[]},{"id":"fd4a3cd3.a7826","type":"ui_chart","z":"72ca7ddb.f1fef4","name":"Temp BME280 chart","group":"ed5e1c9c.66396","order":4,"width":0,"height":0,"label":"","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"5","ymax":"40","removeOlder":"2","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":780,"y":200,"wires":[[],[]]},{"id":"cd157f85.13fde","type":"ui_gauge","z":"72ca7ddb.f1fef4","name":"Temp GEM","group":"fab0db25.fb55b8","order":1,"width":0,"height":0,"gtype":"gage","title":"Temp GEM","label":"Graden C","format":"{{value}}","min":"5","max":"40","colors":["#00b500","#e6e600","#ca3838"],"seg1":"15","seg2":"30","x":750,"y":260,"wires":[]},{"id":"7a5a8d32.dbfb14","type":"ui_chart","z":"72ca7ddb.f1fef4","name":"Temp GEM chart","group":"fab0db25.fb55b8","order":2,"width":0,"height":0,"label":"","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"5","ymax":"40","removeOlder":"2","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":770,"y":300,"wires":[[],[]]},{"id":"d62073dc.3188c","type":"ui_chart","z":"72ca7ddb.f1fef4","name":"LUXChart","group":"81c9e14d.0b0e","order":4,"width":0,"height":0,"label":"","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"5","ymax":"3000","removeOlder":"2","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":740,"y":700,"wires":[[],[]]},{"id":"89f376c0.1fdeb8","type":"ui_gauge","z":"72ca7ddb.f1fef4","name":"LUXMeter","group":"81c9e14d.0b0e","order":3,"width":"0","height":"0","gtype":"gage","title":"Licht","label":"LUX","format":"{{value}}","min":"5","max":"3000","colors":["#d9d900","#ffff00","#ffff80"],"seg1":"","seg2":"","x":740,"y":660,"wires":[]},{"id":"fab0db25.fb55b8","type":"ui_group","z":"","name":"DATA","tab":"12acef78.d57cc1","disp":true,"width":"6","collapse":false},{"id":"5dffa21.0a6fe5c","type":"modbus-client","z":"","name":"UNIT 1","clienttype":"simpleser","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB0","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"2000","reconnectTimeout":"4000"},{"id":"ed5e1c9c.66396","type":"ui_group","z":"","name":"DATA","tab":"12acef78.d57cc1","order":2,"disp":true,"width":"6","collapse":false},{"id":"81c9e14d.0b0e","type":"ui_group","z":"","name":"DATA","tab":"12acef78.d57cc1","order":3,"disp":true,"width":"6","collapse":false},{"id":"763642a9.9cd5fc","type":"ui_group","z":"","name":"DATA","tab":"12acef78.d57cc1","order":4,"disp":true,"width":"6","collapse":false},{"id":"12acef78.d57cc1","type":"ui_tab","z":"","name":"MODBUS SENSOR TEST","icon":"dashboard"}] |
Multisensor HW v1.10 – Groter en slimmer voorbeeld In dit voorbeeld de functie veel overzichtelijker gemaakt, tevens meerdere gegevens in 1 grafiek gezet. Ik heb het idee …
Node-RED – Voorbeeld – Modbus uitlezen en visualiseren (multisensor) Lees meer »