Connect to sensor XNX with Modbus RTU and write data into MySQL database
-
-
Save Reiner68/2442fa23b36ba7e11517962ea65c5659 to your computer and use it in GitHub Desktop.
Honeywell XNX Gas-Detector with Modbus RTU to MySQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"id":"a36ea496.cd66e8","type":"modbus-server","z":"bd325811.2e8cc","name":"Modbus Server","logEnabled":false,"serverPort":10502,"responseDelay":100,"delayUnit":"ms","coilsBufferSize":1024,"holdingBufferSize":1024,"inputBufferSize":1024,"x":378.70056343078613,"y":165.37563467025757,"wires":[["cdc09c20.7d7ea"],["cdc09c20.7d7ea"],["cdc09c20.7d7ea"]]},{"id":"cdc09c20.7d7ea","type":"debug","z":"bd325811.2e8cc","name":"","active":false,"console":"false","complete":"payload","x":650.7005615234375,"y":168.37564086914062,"wires":[]},{"id":"92ab3295.dae4f","type":"inject","z":"bd325811.2e8cc","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":178.70056343078613,"y":165.37563467025757,"wires":[["a36ea496.cd66e8"]]},{"id":"def55565.ecab48","type":"comment","z":"bd325811.2e8cc","name":"Modbus Server","info":"","x":195.40057373046875,"y":122.37563705444336,"wires":[]},{"id":"980fc180.00b66","type":"comment","z":"bd325811.2e8cc","name":"Read modbus register(s)","info":"","x":156,"y":388.0000066757202,"wires":[]},{"id":"5bcd37c0.5c179","type":"ui_chart","z":"bd325811.2e8cc","name":"","group":"74f90edd.da6d9","order":1,"width":"0","height":"0","label":"Holding Register Chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"-25","ymax":"150","removeOlder":"30","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":true,"x":994.6156539916992,"y":581.0068531036377,"wires":[[],[]]},{"id":"6f4e4e75.612478","type":"ui_text","z":"bd325811.2e8cc","group":"74f90edd.da6d9","order":2,"width":0,"height":0,"name":"","label":"Holding Register Sensor1","format":"{{msg.payload}}","layout":"row-spread","x":1004.6717071533203,"y":613.3999691009521,"wires":[]},{"id":"3163fd34.a0b532","type":"mysql","z":"bd325811.2e8cc","mydb":"af877d5.64cac","name":"","x":747.464282989502,"y":734.8928909301758,"wires":[[]]},{"id":"8b1f69b3.9e4c98","type":"debug","z":"bd325811.2e8cc","name":"","active":true,"console":"false","complete":"payload","x":1039.1857814788818,"y":798.5739135742188,"wires":[]},{"id":"a6ea80e5.bc0cf8","type":"function","z":"bd325811.2e8cc","name":"Update Mess","func":"data = (msg.payload);\nvar m = {\n topic : \"UPDATE `tbl_sensor` SET `messwert` = '\" + data + \"' WHERE `idsensor` = '5';\" \n};\nreturn m;","outputs":1,"noerr":0,"x":606.8465919494629,"y":711.3897581100464,"wires":[["3163fd34.a0b532","12524721.dd4d09"]]},{"id":"247d52b6.2f7d7e","type":"function","z":"bd325811.2e8cc","name":"Select Messwert","func":"m = {\n topic : \"SELECT `messwert` FROM `ha`.`tbl_sensor`;\" \n};\nreturn m;","outputs":1,"noerr":0,"x":455.3736801147461,"y":846.1104907989502,"wires":[["26fd2561.d54d3a"]]},{"id":"d31b670b.706238","type":"ui_text","z":"bd325811.2e8cc","group":"6bee444e.5c983c","order":4,"width":0,"height":0,"name":"","label":"Messwert[0]","format":"{{msg.payload}}","layout":"row-spread","x":1034.4812545776367,"y":841.1352100372314,"wires":[]},{"id":"d37cd2c4.06905","type":"inject","z":"bd325811.2e8cc","name":"","topic":"","payload":"","payloadType":"num","repeat":"2","crontab":"","once":false,"x":108.10000610351562,"y":480,"wires":[["6f28e888.3e7668"]]},{"id":"6f28e888.3e7668","type":"function","z":"bd325811.2e8cc","name":"FC[3] dev1","func":"msg.payload = { \n 'fc': 3, \n 'unitid': 1, \n 'address': 2 , \n 'quantity': 2\n};\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":480,"wires":[["a52c2bf5.eeeb58"]]},{"id":"a52c2bf5.eeeb58","type":"modbus-flex-getter","z":"bd325811.2e8cc","name":"","showStatusActivities":false,"showErrors":false,"server":"7c04dc0e.08f05c","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":523.3381881713867,"y":480.23053538799286,"wires":[[],["e61602f1.655b5","9e287b95.f16708","3405273c.8f2af8"]]},{"id":"e61602f1.655b5","type":"modbus-response","z":"bd325811.2e8cc","name":"","registerShowMax":"","x":768.0000228881836,"y":499.0000629425049,"wires":[]},{"id":"7ab107bf.52fdd8","type":"comment","z":"bd325811.2e8cc","name":"Messwert XNX id1","info":"","x":132.5,"y":434,"wires":[]},{"id":"9e287b95.f16708","type":"function","z":"bd325811.2e8cc","name":"float(CD AB)","func":"var rawData = new ArrayBuffer(4);\nvar intView = new Uint16Array(rawData);\nvar fltView = new Float32Array(rawData);\nvar rawData = msg.values;\n//Read input in format \"CD_AB\" [reg2, reg1]\nintView[0] = msg.values[1]; //low\nintView[1] = msg.values[0]; //high\nmsg.payload = fltView[0];\nreturn msg;","outputs":1,"noerr":0,"x":751.4285736083984,"y":577.1428642272949,"wires":[["4173497.d0b5cb8","5bcd37c0.5c179","6f4e4e75.612478","a6ea80e5.bc0cf8"]]},{"id":"4173497.d0b5cb8","type":"debug","z":"bd325811.2e8cc","name":"","active":false,"console":"false","complete":"payload","x":973.0001258850098,"y":542.0000162124634,"wires":[]},{"id":"3405273c.8f2af8","type":"debug","z":"bd325811.2e8cc","name":"","active":false,"console":"false","complete":"values","x":756.100118637085,"y":463.0000171661377,"wires":[]},{"id":"12524721.dd4d09","type":"debug","z":"bd325811.2e8cc","name":"","active":false,"console":"false","complete":"false","x":767.814323425293,"y":692.5428829193115,"wires":[]},{"id":"8d44f9bd.b93518","type":"inject","z":"bd325811.2e8cc","name":"","topic":"","payload":"","payloadType":"num","repeat":"2","crontab":"","once":false,"x":180.14286851882935,"y":847.1428928375244,"wires":[["247d52b6.2f7d7e"]]},{"id":"6449d9a1.9f6548","type":"ui_gauge","z":"bd325811.2e8cc","name":"Messwert[0]","group":"6bee444e.5c983c","order":0,"width":0,"height":0,"gtype":"gage","title":"Gauge","label":"%UEG","format":"","min":"-25","max":"125","colors":["#00b500","#e6e600","#ca3838"],"seg1":"25","seg2":"50","x":1038.696460723877,"y":888.428674697876,"wires":[]},{"id":"26fd2561.d54d3a","type":"mysql","z":"bd325811.2e8cc","mydb":"af877d5.64cac","name":"","x":630.8928604125977,"y":846.7858228683472,"wires":[["5cd69aa1.6efd64"]]},{"id":"5cd69aa1.6efd64","type":"function","z":"bd325811.2e8cc","name":"Messwert[0]","func":"//Auswahl Array[].messwert\nmsg.payload = msg.payload[0].messwert;\nreturn msg;","outputs":1,"noerr":0,"x":807.2857704162598,"y":847.1428937911987,"wires":[["d31b670b.706238","8b1f69b3.9e4c98","6449d9a1.9f6548"]]},{"id":"74f90edd.da6d9","type":"ui_group","z":"","name":"Sensor","tab":"854fe68d.ac995","order":3,"disp":true,"width":"6"},{"id":"af877d5.64cac","type":"MySQLdatabase","z":"","host":"127.0.0.1","port":"3306","db":"ha","tz":""},{"id":"6bee444e.5c983c","type":"ui_group","z":"","name":"Messwert","tab":"12743c8.1877a44","disp":true,"width":"6"},{"id":"7c04dc0e.08f05c","type":"modbus-client","z":"","name":"USB0","clienttype":"serial","bufferCommands":true,"stateLogEnabled":true,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB0","serialType":"RTU","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"even","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectTimeout":"2000"},{"id":"854fe68d.ac995","type":"ui_tab","z":"","name":"Modbus Honeywell","icon":"dashboard"},{"id":"12743c8.1877a44","type":"ui_tab","z":"","name":"Test MySQL ","icon":"dashboard"}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment