SDM630 Test Flow

Based on biancode modbus library with added influxdb outputs. Still in experimenting mode. Uses modbus to poll 2 x SDM630 meters and pull various measurements. Totaliser (chrismoorhouse) used to determine difference between imported and exported power going through meter #2 Most outputs to influxdb and visuals with grafana.

Happy to accept any suggestions on improving performance and streamlining.

[{"id":"6f7f9cb4.d7a634","type":"tab","label":"SDM630 Modbus Gateway"},{"id":"5f6e55b1.d2bd8c","type":"modbus-read","z":"6f7f9cb4.d7a634","name":"","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"InputRegister","adr":"0x000","quantity":"50","rate":"10","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"ed881a69.ee8e48","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":110,"y":80,"wires":[[],["2bda8e17.3e5a42","59a7825a.cd1fcc"]]},{"id":"2bda8e17.3e5a42","type":"modbus-response","z":"6f7f9cb4.d7a634","name":"","registerShowMax":"1","x":330,"y":30,"wires":[]},{"id":"59a7825a.cd1fcc","type":"function","z":"6f7f9cb4.d7a634","name":"extract buffer data","func":"let voltageL1 = msg.payload.buffer.readFloatBE(0,4) // 1,2\nlet voltageL2 = msg.payload.buffer.readFloatBE(4,4) // 3,4\nlet voltageL3 = msg.payload.buffer.readFloatBE(8,4) // 5,6\n\nlet powerL1 = msg.payload.buffer.readFloatBE(12,4) // 7,8\nlet powerL2 = msg.payload.buffer.readFloatBE(16,4) // 9,10\nlet powerL3 = msg.payload.buffer.readFloatBE(20,4) // 11,12\n\nlet demandL1 = msg.payload.buffer.readFloatBE(24,4) // 13,14\nlet demandL2 = msg.payload.buffer.readFloatBE(28,4) // 15,16\nlet demandL3 = msg.payload.buffer.readFloatBE(32,4) // 17,18\n\nlet voltageAVG = msg.payload.buffer.readFloatBE(84,8) // 43-46\nlet powerAVG = msg.payload.buffer.readFloatBE(92,4) // 47,48\n\nreturn [\n    {\n        payload: {\n            L1: {\n                voltage: voltageL1,\n                power: powerL1,\n                demand: demandL1\n            },\n            L2: {\n                voltage: voltageL2,\n                power: powerL2,\n                demand: demandL2\n            },\n            L3: {\n                voltage: voltageL3,\n                power: powerL3,\n                demand: demandL3\n            },\n            voltageAVG: voltageAVG,\n            powerAVG: powerAVG,            \n        }\n    }\n];","outputs":"1","noerr":0,"x":330,"y":90,"wires":[["902d25c5.0ff418","18f77e4.ff50782","3e12c93b.6d78a6","aa6b96d7.a7e9c8"]]},{"id":"902d25c5.0ff418","type":"debug","z":"6f7f9cb4.d7a634","name":"","active":false,"tosidebar":true,"console":false,"complete":"false","x":330,"y":180,"wires":[]},{"id":"18f77e4.ff50782","type":"function","z":"6f7f9cb4.d7a634","name":"amps","func":"return [\n    {payload: msg.payload.L1.power, topic:'AL1'}, \n    {payload: msg.payload.L2.power, topic:'AL2'}, \n    {payload: msg.payload.L3.power, topic:'AL3'},\n    {payload: msg.payload.powerAVG, topic:'AAVG'}\n];","outputs":"4","noerr":0,"x":510,"y":40,"wires":[["66e4700a.ce147","c7079a32.687968"],["b73f63e7.48c83","55b2cad.dcd2b34"],["b0e99011.d02f2","9bbfcc60.b5a3a"],["1db45545.79be1b"]]},{"id":"3e12c93b.6d78a6","type":"function","z":"6f7f9cb4.d7a634","name":"voltage","func":"return [\n    {payload: msg.payload.L1.voltage, topic:'VL1'}, \n    {payload: msg.payload.L2.voltage, topic:'VL2'}, \n    {payload: msg.payload.L3.voltage, topic:'VL3'},\n    {payload: msg.payload.voltageAVG, topic:'VAVG'}\n];","outputs":"4","noerr":0,"x":520,"y":200,"wires":[["737fd1f9.e8e89","9648da18.e6b048"],["1ba7dd0c.276233","48fec76c.aa6b18"],["7591d43b.1e476c","d6cf2c11.1bed2"],["146d20f5.a1d05f","d506fe96.99ae8"]]},{"id":"aa6b96d7.a7e9c8","type":"function","z":"6f7f9cb4.d7a634","name":"watts","func":"return [\n    {payload: msg.payload.L1.demand, topic:'WL1'}, \n    {payload: msg.payload.L2.demand, topic:'WL2'}, \n    {payload: msg.payload.L3.demand, topic:'WL3'}\n];","outputs":3,"noerr":0,"x":510,"y":320,"wires":[["f72e39bb.2bfcb8"],["e010f4e4.c20ad8"],["73a9fec9.bac66"]]},{"id":"cd1ca600.8849e8","type":"modbus-read","z":"6f7f9cb4.d7a634","name":"","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"InputRegister","adr":"0x030","quantity":"8","rate":"10","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"ed881a69.ee8e48","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":110,"y":540,"wires":[[],["1991e9c7.243c86","d2de7550.8a2598"]]},{"id":"1991e9c7.243c86","type":"function","z":"6f7f9cb4.d7a634","name":"extract buffer data","func":"let sumLineCurrentAmps = msg.payload.buffer.readFloatBE(0,4) // 49,50\nlet totalSystemPowerWatts = msg.payload.buffer.readFloatBE(8,12) // 53,54\n\nreturn [\n    {\n        payload: {\n            sumLineCurrentAmps: sumLineCurrentAmps,\n            totalSystemPowerWatts: totalSystemPowerWatts\n        }\n    }\n];","outputs":1,"noerr":0,"x":330,"y":570,"wires":[["73168a17.7e4e94","3089a6e1.d7632a","4b47fbc9.4fee54"]]},{"id":"73168a17.7e4e94","type":"debug","z":"6f7f9cb4.d7a634","name":"","active":false,"console":"false","complete":"false","x":630,"y":620,"wires":[]},{"id":"d2de7550.8a2598","type":"modbus-response","z":"6f7f9cb4.d7a634","name":"","registerShowMax":"1","x":330,"y":500,"wires":[]},{"id":"66e4700a.ce147","type":"debug","z":"6f7f9cb4.d7a634","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":40,"wires":[]},{"id":"b73f63e7.48c83","type":"debug","z":"6f7f9cb4.d7a634","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":80,"wires":[]},{"id":"b0e99011.d02f2","type":"debug","z":"6f7f9cb4.d7a634","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":120,"wires":[]},{"id":"1db45545.79be1b","type":"debug","z":"6f7f9cb4.d7a634","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":160,"wires":[]},{"id":"737fd1f9.e8e89","type":"debug","z":"6f7f9cb4.d7a634","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":200,"wires":[]},{"id":"1ba7dd0c.276233","type":"debug","z":"6f7f9cb4.d7a634","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":240,"wires":[]},{"id":"7591d43b.1e476c","type":"debug","z":"6f7f9cb4.d7a634","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":280,"wires":[]},{"id":"146d20f5.a1d05f","type":"debug","z":"6f7f9cb4.d7a634","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":320,"wires":[]},{"id":"f72e39bb.2bfcb8","type":"debug","z":"6f7f9cb4.d7a634","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":360,"wires":[]},{"id":"e010f4e4.c20ad8","type":"debug","z":"6f7f9cb4.d7a634","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":400,"wires":[]},{"id":"73a9fec9.bac66","type":"debug","z":"6f7f9cb4.d7a634","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":440,"wires":[]},{"id":"c7079a32.687968","type":"influxdb out","z":"6f7f9cb4.d7a634","influxdb":"a59c6a8c.065b48","name":"AL1","measurement":"AL1","precision":"","retentionPolicy":"","x":950,"y":40,"wires":[]},{"id":"55b2cad.dcd2b34","type":"influxdb out","z":"6f7f9cb4.d7a634","influxdb":"a59c6a8c.065b48","name":"AL2","measurement":"AL2","precision":"","retentionPolicy":"","x":950,"y":80,"wires":[]},{"id":"9bbfcc60.b5a3a","type":"influxdb out","z":"6f7f9cb4.d7a634","influxdb":"a59c6a8c.065b48","name":"AL3","measurement":"AL3","precision":"","retentionPolicy":"","x":950,"y":120,"wires":[]},{"id":"9648da18.e6b048","type":"influxdb out","z":"6f7f9cb4.d7a634","influxdb":"a59c6a8c.065b48","name":"VL1","measurement":"VL1","precision":"","retentionPolicy":"","x":950,"y":240,"wires":[]},{"id":"48fec76c.aa6b18","type":"influxdb out","z":"6f7f9cb4.d7a634","influxdb":"a59c6a8c.065b48","name":"VL2","measurement":"VL2","precision":"","retentionPolicy":"","x":950,"y":280,"wires":[]},{"id":"d6cf2c11.1bed2","type":"influxdb out","z":"6f7f9cb4.d7a634","influxdb":"a59c6a8c.065b48","name":"VL3","measurement":"VL3","precision":"","retentionPolicy":"","x":950,"y":320,"wires":[]},{"id":"d506fe96.99ae8","type":"influxdb out","z":"6f7f9cb4.d7a634","influxdb":"a59c6a8c.065b48","name":"VAVG","measurement":"VAVG","precision":"","retentionPolicy":"","x":950,"y":360,"wires":[]},{"id":"c597316d.609b3","type":"modbus-read","z":"6f7f9cb4.d7a634","name":"","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"2","dataType":"InputRegister","adr":"0x048","quantity":"4","rate":"10","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"ed881a69.ee8e48","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":110,"y":720,"wires":[[],["58c0a410.193a3c","2fa82d34.899c72"]]},{"id":"58c0a410.193a3c","type":"modbus-response","z":"6f7f9cb4.d7a634","name":"","registerShowMax":"1","x":330,"y":680,"wires":[]},{"id":"2fa82d34.899c72","type":"function","z":"6f7f9cb4.d7a634","name":"extract buffer data","func":"let impwattHourSinceLastReset = msg.payload.buffer.readFloatBE(0,4)*-1 // 73,74\nlet expwattHourSinceLastReset = msg.payload.buffer.readFloatBE(4,8) // 75,76\n\nreturn [\n    {\n        payload: {\n            expwatts_id2: impwattHourSinceLastReset,//these are swapped as the wiring is back to front\n            impwatts_id2: expwattHourSinceLastReset\n        }\n    }\n];","outputs":"1","noerr":0,"x":320,"y":730,"wires":[["18f6b475.b5f38c","7cad7898.6b4778","17b02ae8.bff835","2a895ca3.22adb4"]]},{"id":"18f6b475.b5f38c","type":"function","z":"6f7f9cb4.d7a634","name":"impwatts_ID2","func":"return [\n    {payload: msg.payload.impwatts_id2, topic:'IMPWATTS_ID2'}\n];","outputs":"1","noerr":0,"x":520,"y":680,"wires":[[]]},{"id":"7cad7898.6b4778","type":"function","z":"6f7f9cb4.d7a634","name":"expwatts_ID2","func":"return [\n    {payload: msg.payload.expwatts_id2, topic:'EXPWATTS_ID2'}\n];","outputs":1,"noerr":0,"x":520,"y":720,"wires":[[]]},{"id":"17b02ae8.bff835","type":"debug","z":"6f7f9cb4.d7a634","name":"","active":false,"console":"false","complete":"false","x":310,"y":780,"wires":[]},{"id":"571d1622.6ad3d8","type":"modbus-read","z":"6f7f9cb4.d7a634","name":"","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"InputRegister","adr":"0x048","quantity":"2","rate":"10","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"ed881a69.ee8e48","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":100,"y":950,"wires":[[],["444be834.a2a7b8","9a536112.70da1"]]},{"id":"444be834.a2a7b8","type":"modbus-response","z":"6f7f9cb4.d7a634","name":"","registerShowMax":"1","x":320,"y":910,"wires":[]},{"id":"9a536112.70da1","type":"function","z":"6f7f9cb4.d7a634","name":"extract buffer data","func":"let impwattHourSinceLastResetID1 = msg.payload.buffer.readFloatBE(0,4) // 73,74\n//let expwattHourSinceLastResetID1 = msg.payload.buffer.readFloatBE(4,8) // 75,76\n\nreturn [\n    {\n        payload: {\n            impwatts_id1: impwattHourSinceLastResetID1,\n            //expwatts_id1: expwattHourSinceLastResetID1\n        }\n    }\n];","outputs":"1","noerr":0,"x":310,"y":960,"wires":[["1f85a784.1afd68","2bb90fb9.bf1d6"]]},{"id":"1f85a784.1afd68","type":"function","z":"6f7f9cb4.d7a634","name":"impwatts_ID1","func":"return [\n    {payload: msg.payload.impwatts_id1, topic:'IMPWATTS_ID1'}\n];","outputs":"1","noerr":0,"x":520,"y":920,"wires":[[]]},{"id":"2bb90fb9.bf1d6","type":"debug","z":"6f7f9cb4.d7a634","name":"","active":false,"console":"false","complete":"false","x":510,"y":1030,"wires":[]},{"id":"4b47fbc9.4fee54","type":"function","z":"6f7f9cb4.d7a634","name":"SLCA","func":"return [\n    {payload: msg.payload.sumLineCurrentAmps, topic:'SLCA'}\n];","outputs":"1","noerr":0,"x":600,"y":500,"wires":[["e65dac67.cde4a"]]},{"id":"3089a6e1.d7632a","type":"function","z":"6f7f9cb4.d7a634","name":"TSPW","func":"return [\n    {payload: msg.payload.totalSystemPowerWatts, topic:'TSPW'}\n];","outputs":1,"noerr":0,"x":600,"y":570,"wires":[["1ef6e3b6.64a61c"]]},{"id":"e65dac67.cde4a","type":"influxdb out","z":"6f7f9cb4.d7a634","influxdb":"a59c6a8c.065b48","name":"SLCA","measurement":"SLCA","precision":"","retentionPolicy":"","x":740,"y":500,"wires":[]},{"id":"1ef6e3b6.64a61c","type":"influxdb out","z":"6f7f9cb4.d7a634","influxdb":"a59c6a8c.065b48","name":"TSPW","measurement":"TSPW","precision":"","retentionPolicy":"","x":740,"y":569,"wires":[]},{"id":"2a895ca3.22adb4","type":"function","z":"6f7f9cb4.d7a634","name":"Net Power Flow","func":"return [\n    {payload: msg.payload.expwatts_id2 + msg.payload.impwatts_id2, topic:'NETWATTS_ID2'}\n];","outputs":1,"noerr":0,"x":520,"y":760,"wires":[["7e027925.f5bbf8","d77d7308.157c4","aede7920.fed3a8"]]},{"id":"7e027925.f5bbf8","type":"influxdb out","z":"6f7f9cb4.d7a634","influxdb":"a59c6a8c.065b48","name":"NETWATTS_ID2A","measurement":"NETWATTS_ID2A","precision":"","retentionPolicy":"","x":710,"y":760,"wires":[]},{"id":"d77d7308.157c4","type":"debug","z":"6f7f9cb4.d7a634","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":690,"y":800,"wires":[]},{"id":"aede7920.fed3a8","type":"totaliser","z":"6f7f9cb4.d7a634","output":"diff","interval":"10","intervalUnits":"minutes","name":"NetWattsID2","x":590,"y":840,"wires":[["217501bd.97233e","bd71d481.5dfec8"]]},{"id":"1affc786.a45038","type":"debug","z":"6f7f9cb4.d7a634","name":"NetWattsID2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":910,"y":800,"wires":[]},{"id":"cd5acba3.9d9868","type":"influxdb out","z":"6f7f9cb4.d7a634","influxdb":"a59c6a8c.065b48","name":"NETWATTS_ID2","measurement":"NETWATTS_ID2","precision":"","retentionPolicy":"","x":930,"y":900,"wires":[]},{"id":"217501bd.97233e","type":"function","z":"6f7f9cb4.d7a634","name":"NetWattsID2","func":"return [\n    {payload: msg.payload.total, topic:'NETWATTS_ID2'}\n];","outputs":1,"noerr":0,"x":750,"y":860,"wires":[["cd5acba3.9d9868","1affc786.a45038"]]},{"id":"bd71d481.5dfec8","type":"debug","z":"6f7f9cb4.d7a634","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":900,"y":760,"wires":[]},{"id":"ed881a69.ee8e48","type":"modbus-client","z":"6f7f9cb4.d7a634","name":"SDM630 Modbus Gateway","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"10.1.1.99","tcpPort":"8899","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"","commandDelay":1,"clientTimeout":10000,"reconnectTimeout":2000},{"id":"a59c6a8c.065b48","type":"influxdb","z":"6f7f9cb4.d7a634","hostname":"grafpi","port":"8086","protocol":"http","database":"sdm630","name":"grafpi","usetls":false,"tls":""}]

Flow Info

Created 5 years, 4 months ago
Updated 4 years, 11 months ago
Rating: 5 2

Owner

Actions

Rate:

Node Types

Core
  • debug (x18)
  • function (x14)
Other

Tags

  • SDM630
  • modbus
  • influxdb
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option