[Device] IoT Studio fetch 智慧電表 PM-3133 show on Dashboard

Questions and Answers

Moderator: IoTStudio Support

Post Reply
IoTStudio Support
Posts: 39
Joined: Wed Nov 23, 2022 9:26 am

[Device] IoT Studio fetch 智慧電表 PM-3133 show on Dashboard

Post by IoTStudio Support »

PM-3133 Smart Power Meter has the Modbus RTU interface.
The system architecture:
SA.PNG
SA.PNG (25.06 KiB) Viewed 3043 times
The connect image:
實物.png
實物.png (124.53 KiB) Viewed 3043 times
Modbus Register depends on PM-3133 User's Manual, Modubus Module #4 - Input Register: Power value (Float) 34353~34470.
User IoT Studio fetch Power Values and show CT1 value V_a, I_a and kWh_a on Dashboard.
The flow:

Code: Select all

[{"id":"a51c1dd2a3737937","type":"tab","label":"PM-3133 Modbus RTS R/W","disabled":false,"info":"","env":[]},{"id":"f8bac4228331a020","type":"tab","label":"PM-3133 - Dashboard","disabled":false,"info":"","env":[]},{"id":"a826b8f80f821478","type":"modbus-client","name":"","clienttype":"serial","bufferCommands":true,"stateLogEnabled":true,"queueLogEnabled":false,"failureLogEnabled":true,"tcpHost":"192.168.1.5","tcpPort":"502","tcpType":"DEFAULT","serialPort":"COM3","serialType":"RTU-BUFFERD","serialBaudrate":"19200","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"1000","serialAsciiResponseStartDelimiter":"0x3A","unit_id":1,"commandDelay":1,"clientTimeout":1000,"reconnectOnTimeout":false,"reconnectTimeout":2000,"parallelUnitIdsAllowed":true,"showErrors":true,"showWarnings":true,"showLogs":true},{"id":"8d034e9d05738f91","type":"ui_group","name":"智慧電表 (Smart Power Meter)","tab":"3f38a04c838180d9","order":4,"disp":true,"width":"22","collapse":false,"className":""},{"id":"3f38a04c838180d9","type":"ui_tab","name":"PM-3133-100P","icon":"dashboard","disabled":false,"hidden":false},{"id":"315df5c82eefb03f","type":"ui_base","theme":{"name":"theme-light","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#097479","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"themeState":{"base-color":{"default":"#0094CE","value":"#0094CE","edited":false},"page-titlebar-backgroundColor":{"value":"#0094CE","edited":false},"page-backgroundColor":{"value":"#fafafa","edited":false},"page-sidebar-backgroundColor":{"value":"#ffffff","edited":false},"group-textColor":{"value":"#1bbfff","edited":false},"group-borderColor":{"value":"#ffffff","edited":false},"group-backgroundColor":{"value":"#ffffff","edited":false},"widget-textColor":{"value":"#111111","edited":false},"widget-backgroundColor":{"value":"#0094ce","edited":false},"widget-borderColor":{"value":"#ffffff","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey","palette":"light"}},"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"564805e7af8d91e0","type":"ui_spacer","z":"a51c1dd2a3737937","name":"spacer","group":"8d034e9d05738f91","order":9,"width":11,"height":1},{"id":"aabd2f9ad61ba5a6","type":"ui_spacer","z":"a51c1dd2a3737937","name":"spacer","group":"8d034e9d05738f91","order":10,"width":11,"height":1},{"id":"0ca6b2c332f95084","type":"ui_spacer","z":"a51c1dd2a3737937","name":"spacer","group":"8d034e9d05738f91","order":13,"width":11,"height":1},{"id":"c4558d21e4edfa12","type":"ui_spacer","z":"a51c1dd2a3737937","name":"spacer","group":"8d034e9d05738f91","order":14,"width":11,"height":1},{"id":"afc1b02939c53318","type":"ui_spacer","z":"a51c1dd2a3737937","name":"spacer","group":"8d034e9d05738f91","order":16,"width":11,"height":1},{"id":"d9b69ace90824c0d","type":"debug","z":"a51c1dd2a3737937","name":"debug 6","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":420,"y":900,"wires":[]},{"id":"e36d3d1732e6fb4b","type":"debug","z":"a51c1dd2a3737937","name":"debug 7","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":420,"y":940,"wires":[]},{"id":"55c285a620e2f38e","type":"modbus-flex-getter","z":"a51c1dd2a3737937","name":"","showStatusActivities":true,"showErrors":true,"showWarnings":true,"logIOActivities":false,"server":"a826b8f80f821478","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":true,"delayOnStart":false,"startDelayTime":"","x":230,"y":920,"wires":[["d9b69ace90824c0d","68c823ff7ca262fa"],["e36d3d1732e6fb4b"]]},{"id":"b75bde42b354324f","type":"inject","z":"a51c1dd2a3737937","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":true,"onceDelay":"6","topic":"data","payload":"","payloadType":"date","x":150,"y":200,"wires":[["5123da6d124a4819"]]},{"id":"5123da6d124a4819","type":"function","z":"a51c1dd2a3737937","name":"Power value (Float) 4353","func":"\nmsg.payload = {\n    value: 1,\n    'fc': 4,\n    'unitid': 1,\n    'address': 4352,\n    'quantity': 118 };\nreturn msg; ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":200,"wires":[["0e565af7d1682f2f"]]},{"id":"17cb8792bc6d95e7","type":"function","z":"a51c1dd2a3737937","name":"Power value (Inverse Integer) 4609 (no value)","func":"\nmsg.payload = {\n    value: 1,\n    'fc': 4,\n    'unitid': 1,\n    'address': 4608,\n    'quantity': 72 };\nreturn msg; ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":240,"wires":[["0e565af7d1682f2f"]]},{"id":"efcd99c152a0a33a","type":"inject","z":"a51c1dd2a3737937","d":true,"name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":240,"wires":[["17cb8792bc6d95e7"]]},{"id":"1f8336aeca2bf114","type":"function","z":"a51c1dd2a3737937","name":"Model Name, Model Type, Firmware Version","func":"\nmsg.payload = {\n    value: 1,\n    'fc': 4,\n    'unitid': 1,\n    'address': 514,\n    'quantity': 3 };\nreturn msg; ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":160,"wires":[["0e565af7d1682f2f"]]},{"id":"45e3dad1dd40beaa","type":"inject","z":"a51c1dd2a3737937","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"3","topic":"info","payload":"","payloadType":"date","x":160,"y":160,"wires":[["1f8336aeca2bf114"]]},{"id":"c350c7d85d132669","type":"link in","z":"a51c1dd2a3737937","name":"Send to Device","links":["0e565af7d1682f2f"],"x":95,"y":920,"wires":[["55c285a620e2f38e"]]},{"id":"0e565af7d1682f2f","type":"link out","z":"a51c1dd2a3737937","name":"link out 1","mode":"link","links":["c350c7d85d132669"],"x":725,"y":300,"wires":[]},{"id":"68e5433a756f31be","type":"function","z":"a51c1dd2a3737937","name":"Power value (Integer) 4865 (no value)","func":"\nmsg.payload = {\n    value: 1,\n    'fc': 4,\n    'unitid': 1,\n    'address': 4864,\n    'quantity': 72 };\nreturn msg; ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":280,"wires":[["0e565af7d1682f2f"]]},{"id":"ca8f8a87787d3510","type":"inject","z":"a51c1dd2a3737937","d":true,"name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":280,"wires":[["68e5433a756f31be"]]},{"id":"c8cc8e5c2d771532","type":"inject","z":"a51c1dd2a3737937","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":440,"wires":[["add47549fd17481a"]]},{"id":"add47549fd17481a","type":"function","z":"a51c1dd2a3737937","name":"kWh_a 4365","func":"\nmsg.payload = {\n    value: 1,\n    'fc': 4,\n    'unitid': 1,\n    'address': 4364,\n    'quantity': 2 };\nreturn msg; ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":440,"wires":[["0e565af7d1682f2f"]]},{"id":"fe44795125cb5ea4","type":"inject","z":"a51c1dd2a3737937","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":560,"y":760,"wires":[["30096441313879ce"]]},{"id":"f3ff74ee3b70727d","type":"function","z":"a51c1dd2a3737937","name":"function 1","func":"\nfunction WordToByteArray(_word) {\n    // we want to represent the input as a 8-bytes array\n    var byteArray = [0, 0];\n\n    for (var index = 0; index < byteArray.length; index++) {\n        var byte = _word & 0xff;\n        byteArray[index] = byte;\n        _word = (_word - byte) / 256;\n    }\n\n    return byteArray;\n};\n\n\nlet data = msg.payload;\nlet a = WordToByteArray(data[0]);\nlet b = a.concat(WordToByteArray(data[1]));\n\n//msg.payload = b;\n//return msg;\n\nconst buf = Buffer.from(b);\nmsg.payload = buf.readFloatLE(0);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":840,"y":760,"wires":[["365b85034fad4555"]]},{"id":"365b85034fad4555","type":"debug","z":"a51c1dd2a3737937","name":"debug 8","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1020,"y":760,"wires":[]},{"id":"30096441313879ce","type":"function","z":"a51c1dd2a3737937","name":"input","func":"\nmsg.payload = [8722, 15550];\nmsg.payload = [9860, 15719];\nmsg.payload = [29601, 14861];\nmsg.payload = [16117, 15551];\nreturn msg;\n\n\nfunction WordToByteArray(_word) {\n    // we want to represent the input as a 8-bytes array\n    var byteArray = [0, 0];\n\n    for (var index = 0; index < byteArray.length; index++) {\n        var byte = _word & 0xff;\n        byteArray[index] = byte;\n        _word = (_word - byte) / 256;\n    }\n\n    return byteArray;\n};\n\nmsg.payload = WordToByteArray(8722);\nreturn msg;\n\nconst buf = Buffer.from([8722, 15550]);\nmsg.payload = buf.readFloatBE(0);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":760,"wires":[["f3ff74ee3b70727d"]]},{"id":"68c823ff7ca262fa","type":"link out","z":"a51c1dd2a3737937","name":"link out 2","mode":"link","links":["2c85c49f33c6b06e"],"x":385,"y":860,"wires":[]},{"id":"2c85c49f33c6b06e","type":"link in","z":"a51c1dd2a3737937","name":"proc data","links":["68c823ff7ca262fa"],"x":445,"y":860,"wires":[["35a6505604bcfe0e"]]},{"id":"13778daaea53772a","type":"function","z":"a51c1dd2a3737937","name":"prco data","func":"\nlet _do = msg.payload;\n\nlet DataObj = {};\n\nDataObj.a = {};\nDataObj.a.V = _do.V_a;\nDataObj.a.I = _do.I_a;\nDataObj.a.kW = _do.kW_a;\nDataObj.a.kvar = _do.kvar_a;\nDataObj.a.kVA = _do.kVA_a;\nDataObj.a.PF = _do.PF_a;\nDataObj.a.kWh = _do.kWh_a;\nDataObj.a.kvarh = _do.kvarh_a;\nDataObj.a.kVAh = _do.kVAh_a;\nDataObj.a.Freq = _do.Freq_a;\n\nDataObj.b = {};\nDataObj.b.V = _do.V_b;\nDataObj.b.I = _do.I_b;\nDataObj.b.kW = _do.kW_b;\nDataObj.b.kvar = _do.kvar_b;\nDataObj.b.kVA = _do.kVA_b;\nDataObj.b.PF = _do.PF_b;\nDataObj.b.kWh = _do.kWh_b;\nDataObj.b.kvarh = _do.kvarh_b;\nDataObj.b.kVAh = _do.kVAh_b;\nDataObj.b.Freq = _do.Freq_b;\n\nDataObj.c = {};\nDataObj.c.V = _do.V_c;\nDataObj.c.I = _do.I_c;\nDataObj.c.kW = _do.kW_c;\nDataObj.c.kvar = _do.kvar_c;\nDataObj.c.kVA = _do.kVA_c;\nDataObj.c.PF = _do.PF_c;\nDataObj.c.kWh = _do.kWh_c;\nDataObj.c.kvarh = _do.kvarh_c;\nDataObj.c.kVAh = _do.kVAh_c;\nDataObj.c.Freq = _do.Freq_c;\n\nDataObj.else = {};\nDataObj.else.timestamp = _do.ts;\nDataObj.else.V_avg = _do.V_avg;\nDataObj.else.I_avg = _do.I_avg;\nDataObj.else.KW_tot = _do.KW_tot;\nDataObj.else.kvar_tot = _do.kvar_tot;\nDataObj.else.kVA_tot = _do.kVA_tot;\nDataObj.else.PF_tot = _do.PF_tot;\nDataObj.else.kWh_tot = _do.kWh_tot;\nDataObj.else.kvarh_tot = _do.kvarh_tot;\nDataObj.else.kVAh_tot = _do.kVAh_tot;\nDataObj.else.Freq_max = _do.Freq_max;\nDataObj.else.VTHD = _do.VTHD;\nDataObj.else.ITHD = _do.ITHD;\nDataObj.else.Bi_Postitive_kWh = _do.Bi_Postitive_kWh;\nDataObj.else.Bi_Negative_kWh = _do.Bi_Negative_kWh;\nDataObj.else.Bi_Net_kWh = _do.Bi_Net_kWh;\nDataObj.else.Bi_Total_kWh = _do.Bi_Total_kWh;\n\nlet msg_a = {};\nmsg_a.payload = DataObj.a;\n\nlet msg_b = {};\nmsg_b.payload = DataObj.b;\n\nlet msg_c = {};\nmsg_c.payload = DataObj.c;\n\nlet msg_else = {};\nmsg_else.payload = DataObj.else;\n\nreturn [msg_a, msg_b, msg_c, msg_else];","outputs":4,"noerr":0,"initialize":"","finalize":"","libs":[],"x":840,"y":880,"wires":[["b71e42e14eef062b","365b85034fad4555","d8d5e8f30ccf68b0"],["9d310d2cb9687d6d","29abdfc5793b10d7"],["af1fb89c1546bc21","f73eb05ac13d74f9"],["f97f712263f5d75b"]]},{"id":"7411b18cc60052cf","type":"function","z":"a51c1dd2a3737937","name":"Collect Data","func":"\nlet ts = Date.now();\nlet ds = msg.payload;\n\nfunction WordToByteArray(_word) {\n    // we want to represent the input as a 8-bytes array\n    var byteArray = [0, 0];\n\n    for (var index = 0; index < byteArray.length; index++) {\n        var byte = _word & 0xff;\n        byteArray[index] = byte;\n        _word = (_word - byte) / 256;\n    }\n\n    return byteArray;\n};\n\nfunction dt(w1, w2) {\n    let a = WordToByteArray(w1);\n    let b = a.concat(WordToByteArray(w2));\n    const buf = Buffer.from(b);\n    let ret = buf.readFloatLE(0);\n    return ret;\n}\n\nlet DataObj = {};\n\n//node.warn(ts);\nDataObj.ts = ts;\n\nDataObj.V_a = dt(ds[0], ds[1]);\nDataObj.I_a = dt(ds[2], ds[3]);\nDataObj.kW_a = dt(ds[4], ds[5]);\nDataObj.kvar_a = dt(ds[6], ds[7]);\nDataObj.kVA_a = dt(ds[8], ds[9]);\nDataObj.PF_a = dt(ds[10], ds[11]);\nDataObj.kWh_a = dt(ds[12], ds[13]);\nDataObj.kvarh_a = dt(ds[14], ds[15]);\nDataObj.kVAh_a = dt(ds[16], ds[17]);\n\nDataObj.V_b = dt(ds[18], ds[19]);\nDataObj.I_b = dt(ds[20], ds[21]);\nDataObj.kW_b = dt(ds[22], ds[23]);\nDataObj.kvar_b = dt(ds[24], ds[25]);\nDataObj.kVA_b = dt(ds[26], ds[27]);\nDataObj.PF_b = dt(ds[28], ds[29]);\nDataObj.kWh_b = dt(ds[30], ds[31]);\nDataObj.kvarh_b = dt(ds[32], ds[33]);\nDataObj.kVAh_b = dt(ds[34], ds[35]);\n\nDataObj.V_c = dt(ds[36], ds[37]);\nDataObj.I_c = dt(ds[38], ds[39]);\nDataObj.kW_c = dt(ds[40], ds[41]);\nDataObj.kvar_c = dt(ds[42], ds[43]);\nDataObj.kVA_c = dt(ds[44], ds[45]);\nDataObj.PF_c = dt(ds[46], ds[47]);\nDataObj.kWh_c = dt(ds[48], ds[49]);\nDataObj.kvarh_c = dt(ds[50], ds[51]);\nDataObj.kVAh_c = dt(ds[52], ds[53]);\n\nDataObj.V_avg = dt(ds[54], ds[55]);\nDataObj.I_avg = dt(ds[56], ds[57]);\nDataObj.KW_tot = dt(ds[58], ds[59]);\nDataObj.kvar_tot = dt(ds[60], ds[61]);\nDataObj.kVA_tot = dt(ds[62], ds[63]);\nDataObj.PF_tot = dt(ds[64], ds[65]);\nDataObj.kWh_tot = dt(ds[66], ds[67]);\nDataObj.kvarh_tot = dt(ds[68], ds[69]);\nDataObj.kVAh_tot = dt(ds[70], ds[71]);\nDataObj.Freq_a = dt(ds[72], ds[73]);\nDataObj.Freq_b = dt(ds[74], ds[75]);\nDataObj.Freq_c = dt(ds[76], ds[77]);\nDataObj.Freq_max = dt(ds[78], ds[79]);\nDataObj.VTHD = dt(ds[80], ds[81]);\nDataObj.ITHD = dt(ds[82], ds[83]);\nDataObj.Bi_Postitive_kWh = dt(ds[84], ds[85]);\nDataObj.Bi_Negative_kWh = dt(ds[86], ds[87]);\nDataObj.Bi_Net_kWh = dt(ds[98], ds[89]);\nDataObj.Bi_Total_kWh = dt(ds[90], ds[91]);\n\nmsg.payload = DataObj;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":670,"y":880,"wires":[["13778daaea53772a"]]},{"id":"b71e42e14eef062b","type":"link out","z":"a51c1dd2a3737937","name":"a","mode":"link","links":["8c4a5407f15cae48"],"x":965,"y":820,"wires":[]},{"id":"9d310d2cb9687d6d","type":"link out","z":"a51c1dd2a3737937","name":"b","mode":"link","links":["14c8f92d6b8e3761"],"x":965,"y":860,"wires":[]},{"id":"af1fb89c1546bc21","type":"link out","z":"a51c1dd2a3737937","name":"c","mode":"link","links":["361231343979259b"],"x":965,"y":900,"wires":[]},{"id":"f97f712263f5d75b","type":"link out","z":"a51c1dd2a3737937","name":"else","mode":"link","links":["631294fd6e2a6dd4","1da45112df24755a"],"x":965,"y":940,"wires":[]},{"id":"35a6505604bcfe0e","type":"switch","z":"a51c1dd2a3737937","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"info","vt":"str"},{"t":"eq","v":"data","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":530,"y":860,"wires":[["caeaae64e88673b5","dde8911a0f72deb4"],["7411b18cc60052cf"]]},{"id":"caeaae64e88673b5","type":"link out","z":"a51c1dd2a3737937","name":"link out 3","mode":"link","links":["9d82889e4283ddb6"],"x":635,"y":840,"wires":[]},{"id":"dde8911a0f72deb4","type":"debug","z":"a51c1dd2a3737937","name":"debug 9","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":760,"y":1000,"wires":[]},{"id":"2d59d1d6f7780927","type":"function","z":"a51c1dd2a3737937","name":"Model Name, Model Type, Firmware Version","func":"\nmsg.payload = {\n    value: 1,\n    'fc': 3,\n    'unitid': 1,\n    'address': 4106,\n    'quantity': 1 };\nreturn msg; ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":320,"wires":[["0e565af7d1682f2f"]]},{"id":"41b4c1385e745e79","type":"inject","z":"a51c1dd2a3737937","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"info","payload":"","payloadType":"date","x":160,"y":320,"wires":[["2d59d1d6f7780927"]]},{"id":"b19f213040b3de4a","type":"function","z":"a51c1dd2a3737937","name":"Model Name, Model Type, Firmware Version","func":"\n//m`sg.payload = {\n// `   value: 1,\n// `   'fc': 6,\n// `   'unitid': 1,\n// `   'address': 4106,\n// `   'quantity': 1 };\nmsg.payload = 1;\nreturn msg; ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":580,"wires":[["ae693f5b8061384f"]]},{"id":"687d8fe543edf835","type":"inject","z":"a51c1dd2a3737937","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"info","payload":"","payloadType":"date","x":160,"y":580,"wires":[["b19f213040b3de4a"]]},{"id":"ae693f5b8061384f","type":"modbus-write","z":"a51c1dd2a3737937","name":"w 4106","showStatusActivities":false,"showErrors":false,"showWarnings":true,"unitid":"1","dataType":"HoldingRegister","adr":"4106","quantity":"1","server":"a826b8f80f821478","emptyMsgOnFail":false,"keepMsgProperties":false,"delayOnStart":false,"startDelayTime":"","x":720,"y":580,"wires":[["75ad9f28c9260a9b"],["2eac79151517837b"]]},{"id":"75ad9f28c9260a9b","type":"debug","z":"a51c1dd2a3737937","name":"debug 10","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":880,"y":560,"wires":[]},{"id":"2eac79151517837b","type":"debug","z":"a51c1dd2a3737937","name":"debug 11","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":880,"y":600,"wires":[]},{"id":"29abdfc5793b10d7","type":"debug","z":"a51c1dd2a3737937","name":"debug 14","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1060,"y":840,"wires":[]},{"id":"925cc08b4b0e12f3","type":"function","z":"a51c1dd2a3737937","name":"Model Name, Model Type, Firmware Version","func":"\n//m`sg.payload = {\n// `   value: 1,\n// `   'fc': 6,\n// `   'unitid': 1,\n// `   'address': 4106,\n// `   'quantity': 1 };\nmsg.payload = 100;\nreturn msg; ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":500,"wires":[["1adf413c94092ee9"]]},{"id":"b4c9d6621e8ceefb","type":"inject","z":"a51c1dd2a3737937","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"info","payload":"","payloadType":"date","x":160,"y":500,"wires":[["925cc08b4b0e12f3"]]},{"id":"1adf413c94092ee9","type":"modbus-write","z":"a51c1dd2a3737937","name":"w 4099","showStatusActivities":false,"showErrors":false,"showWarnings":true,"unitid":"1","dataType":"HoldingRegister","adr":"4099","quantity":"1","server":"a826b8f80f821478","emptyMsgOnFail":false,"keepMsgProperties":false,"delayOnStart":false,"startDelayTime":"","x":720,"y":500,"wires":[[],[]]},{"id":"70500c97f125c8e8","type":"function","z":"a51c1dd2a3737937","name":"Model Name, Model Type, Firmware Version","func":"\nmsg.payload = {\n    value: 1,\n    'fc': 3,\n    'unitid': 1,\n    'address': 4099,\n    'quantity': 1 };\nreturn msg; ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":360,"wires":[["0e565af7d1682f2f"]]},{"id":"bb5df5a916ee2222","type":"inject","z":"a51c1dd2a3737937","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"info","payload":"","payloadType":"date","x":160,"y":360,"wires":[["70500c97f125c8e8"]]},{"id":"23da1eec836ef23f","type":"function","z":"a51c1dd2a3737937","name":"Model Name, Model Type, Firmware Version","func":"\nmsg.payload = {\n    value: 1,\n    'fc': 3,\n    'unitid': 1,\n    'address': 4114,\n    'quantity': 1 };\nreturn msg; ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":400,"wires":[["0e565af7d1682f2f"]]},{"id":"450adf1ba6d7c962","type":"inject","z":"a51c1dd2a3737937","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"info","payload":"","payloadType":"date","x":160,"y":400,"wires":[["23da1eec836ef23f"]]},{"id":"60a64d30e3a7e437","type":"function","z":"a51c1dd2a3737937","name":"Model Name, Model Type, Firmware Version","func":"\n//m`sg.payload = {\n// `   value: 1,\n// `   'fc': 6,\n// `   'unitid': 1,\n// `   'address': 4106,\n// `   'quantity': 1 };\nmsg.payload = 1;\nreturn msg; ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":540,"wires":[["66a37f786adb89c7"]]},{"id":"01f0387c42417f2a","type":"inject","z":"a51c1dd2a3737937","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"info","payload":"","payloadType":"date","x":160,"y":540,"wires":[["60a64d30e3a7e437"]]},{"id":"66a37f786adb89c7","type":"modbus-write","z":"a51c1dd2a3737937","name":"w 4114","showStatusActivities":false,"showErrors":false,"showWarnings":true,"unitid":"1","dataType":"HoldingRegister","adr":"4114","quantity":"1","server":"a826b8f80f821478","emptyMsgOnFail":false,"keepMsgProperties":false,"delayOnStart":false,"startDelayTime":"","x":720,"y":540,"wires":[[],[]]},{"id":"d8d5e8f30ccf68b0","type":"debug","z":"a51c1dd2a3737937","name":"debug 15","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1060,"y":800,"wires":[]},{"id":"f73eb05ac13d74f9","type":"debug","z":"a51c1dd2a3737937","name":"debug 16","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1060,"y":980,"wires":[]},{"id":"8c4a5407f15cae48","type":"link in","z":"f8bac4228331a020","name":"link in 1","links":["b71e42e14eef062b"],"x":235,"y":120,"wires":[["9e9c675011b842ce"]]},{"id":"9e9c675011b842ce","type":"function","z":"f8bac4228331a020","name":"a","func":"let obj = msg.payload;\n\nlet msg_1 = {};\nmsg_1.payload = obj.I.toFixed(5);\n\nlet msg_2 = {};\nmsg_2.payload = obj.V.toFixed(5);\n\nlet msg_3 = {};\nmsg_3.payload = obj.kWh.toFixed(7);\nnode.warn(msg_3.payload);\n\nlet msg_4 = {};\nlet kWh_fixed = obj.kWh * 0.424;\nmsg_4.payload = kWh_fixed.toFixed(8);\nnode.warn(msg_4.payload);\n\nreturn [msg_1, msg_2, msg_3, msg_4];","outputs":4,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":120,"wires":[["b689e4f29747d340","8435715b55049b4d"],["a80423b8e357d69f","df519995754cb676"],["ca1013689bd99f6f","484fe836dbd3352d"],["27b224de1b3f773e"]]},{"id":"14c8f92d6b8e3761","type":"link in","z":"f8bac4228331a020","name":"link in 2","links":["9d310d2cb9687d6d"],"x":235,"y":280,"wires":[["223d232d427c6ffd"]]},{"id":"223d232d427c6ffd","type":"function","z":"f8bac4228331a020","name":"b","func":"let obj = msg.payload;\n\nlet msg_kWh = {};\nmsg_kWh.payload = obj.kWh*10;\n\nlet msg_kvarh = {};\nmsg_kvarh.payload = obj.kvarh*10;\n\nlet msg_kVAh = {};\nmsg_kVAh.payload = obj.kVAh*10;\n\nreturn [msg_kWh, msg_kvarh, msg_kVAh];","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":280,"wires":[[],[],[]]},{"id":"361231343979259b","type":"link in","z":"f8bac4228331a020","name":"link in 3","links":["af1fb89c1546bc21"],"x":235,"y":440,"wires":[["893a92c331b6a53e"]]},{"id":"893a92c331b6a53e","type":"function","z":"f8bac4228331a020","name":"c","func":"let obj = msg.payload;\n\nlet msg_kWh = {};\nmsg_kWh.payload = obj.kWh*10;\n\nlet msg_kvarh = {};\nmsg_kvarh.payload = obj.kvarh*10;\n\nlet msg_kVAh = {};\nmsg_kVAh.payload = obj.kVAh*10;\n\nreturn [msg_kWh, msg_kvarh, msg_kVAh];","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":440,"wires":[[],[],[]]},{"id":"1da45112df24755a","type":"link in","z":"f8bac4228331a020","name":"link in 5","links":["f97f712263f5d75b"],"x":235,"y":600,"wires":[["c526d5c04a4a3d1e"]]},{"id":"c526d5c04a4a3d1e","type":"function","z":"f8bac4228331a020","name":"total","func":"//kWh_tot: 0.06965582817792892\n//kvarh_tot: 0.001996060833334923\n//kVAh_tot: 0.070045597851276\n\nlet obj = msg.payload;\n\nlet msg_kWh = {};\nmsg_kWh.payload = obj.kWh_tot*10;\n\nlet msg_kvarh = {};\nmsg_kvarh.payload = obj.kvarh_tot*10;\n\nlet msg_kVAh = {};\nmsg_kVAh.payload = obj.kVAh_tot*10;\n\nreturn [msg_kWh, msg_kvarh, msg_kVAh];\n\n","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":600,"wires":[[],[],[]]},{"id":"f7cfae2e2bd2ed55","type":"ui_template","z":"f8bac4228331a020","group":"","name":"","order":2,"width":0,"height":0,"format":"<style>\n    body {\n        background-image: url('/static/img/AIoT-BG.jpg');    \n    }\n//#PM-3133-100P_智慧電表_\\(Smart_Power_Meter\\)_cards >\n//md-card.nr-dashboard-text._md.layout-row.layout-align-start-center.nr-dashboard-widget-Model_Name.visible {font-size:20px !important;}\n//\n//#PM-3133-100P_智慧電表_\\(Smart_Power_Meter\\)_cards >\n//md-card.nr-dashboard-text._md.layout-row.layout-align-start-center.nr-dashboard-widget-DateTime.visible {font-size:20px !important;}\n//\n//    #PM-3133-100P_智慧電表_\\(Smart_Power_Meter\\)_cards > md-card:nth-child(6) {font-size:20px !important;}\n//    #PM-3133-100P_智慧電表_\\(Smart_Power_Meter\\)_cards > md-card:nth-child(7) {font-size:20px !important;}\n//\n//    #PM-3133-100P_智慧電表_\\(Smart_Power_Meter\\)_cards >\n//    md-card.nr-dashboard-text._md.layout-row.layout-align-start-center.nr-dashboard-widget-kWh.visible {font-size:20px !important;}\n//\n//    #PM-3133-100P_智慧電表_\\(Smart_Power_Meter\\)_cards >\n//    md-card.nr-dashboard-text._md.layout-row.layout-align-space-between-center.nr-dashboard-widget-_______kWh___0_424__KG_.visible {font-size:20px !important;}\n//\n//    #PM-3133-100P_智慧電表_\\(Smart_Power_Meter\\)_cards > md-card:nth-child(12) {font-size:20px !important;}\n//\n//#PM-3133-100P_智慧電表_\\(Smart_Power_Meter\\)_cards > md-card:nth-child(6) > p.value \n//{font-size:40px !important;}\n//#PM-3133-100P_智慧電表_\\(Smart_Power_Meter\\)_cards > md-card:nth-child(13) > p.value\n{font-size:40px !important;}\n.label{font-size:25px !important;}\n.value{font-size:25px !important;}\n</style>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"global","className":"","x":740,"y":100,"wires":[[]]},{"id":"0bb094f9daed1f36","type":"ui_template","z":"f8bac4228331a020","group":"","name":"","order":2,"width":0,"height":0,"format":"<style>\n    body {\n        //background-image: url('/static/img/AIoT-BG.jpg');\n        background-color: transparent;\n    }\n</style>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":580,"y":480,"wires":[[]]},{"id":"b689e4f29747d340","type":"ui_chart","z":"f8bac4228331a020","name":"","group":"8d034e9d05738f91","order":4,"width":11,"height":6,"label":"電流(A)","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":580,"y":80,"wires":[[]]},{"id":"a80423b8e357d69f","type":"ui_text","z":"f8bac4228331a020","group":"8d034e9d05738f91","order":7,"width":11,"height":1,"name":"","label":"電壓","format":"{{msg.payload}} V","layout":"row-left","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":570,"y":200,"wires":[]},{"id":"27b224de1b3f773e","type":"ui_text","z":"f8bac4228331a020","group":"8d034e9d05738f91","order":12,"width":11,"height":1,"name":"","label":"總碳排","format":"{{msg.payload}} KG","layout":"row-left","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":570,"y":360,"wires":[]},{"id":"8435715b55049b4d","type":"ui_text","z":"f8bac4228331a020","group":"8d034e9d05738f91","order":6,"width":11,"height":1,"name":"","label":"電流","format":"{{msg.payload}} A","layout":"row-left","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":570,"y":120,"wires":[]},{"id":"df519995754cb676","type":"ui_chart","z":"f8bac4228331a020","name":"","group":"8d034e9d05738f91","order":5,"width":11,"height":6,"label":"電壓(V)","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":580,"y":160,"wires":[[]]},{"id":"ca1013689bd99f6f","type":"ui_chart","z":"f8bac4228331a020","name":"","group":"8d034e9d05738f91","order":8,"width":11,"height":6,"label":"耗電量(kWh)","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":590,"y":240,"wires":[[]]},{"id":"484fe836dbd3352d","type":"ui_text","z":"f8bac4228331a020","group":"8d034e9d05738f91","order":15,"width":11,"height":1,"name":"","label":"耗電量","format":"{{msg.payload}} V","layout":"row-left","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":570,"y":280,"wires":[]},{"id":"90d892c09c0da250","type":"ui_text","z":"f8bac4228331a020","group":"8d034e9d05738f91","order":11,"width":11,"height":1,"name":"","label":"碳排公式 = kWh * 0.424 (KG)","format":"{{msg.payload}}","layout":"row-spread","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":640,"y":320,"wires":[]},{"id":"24430e65da38f574","type":"ui_template","z":"f8bac4228331a020","group":"8d034e9d05738f91","name":"","order":2,"width":0,"height":0,"format":"<style>\n    //*[@id=\"PM-3133-100P_智慧電表_(Smart_Power_Meter)_cards\"]/md-card[6]\n    //body {\n        //background-image: url('/static/img/AIoT-BG.jpg');\n    //    background-color: transparent;\n    //}\n    //.stylish span {position:relative;}\n    #PM-3133-100P_智慧電表_\\(Smart_Power_Meter\\)_cards > md-card:nth-child(6) {font-size:100px !important;}\n    //#PM-3133-100P_智慧電表_\\(Smart_Power_Meter\\)_cards > md-card:nth-child(7) > p.value {\n    //    font-size: 100px;\n    //}\n\n    ///html/body/md-content/section/md-content/div[1]/ui-card-panel/div/div/md-card[7]/p[2] {\n    //    font-size: 100px;\n    //        }\n</style>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":580,"y":440,"wires":[[]]},{"id":"631294fd6e2a6dd4","type":"link in","z":"f8bac4228331a020","name":"link in 4","links":["f97f712263f5d75b"],"x":235,"y":700,"wires":[["027255356ddc261a"]]},{"id":"027255356ddc261a","type":"function","z":"f8bac4228331a020","name":"timestamp to string","func":"let obj = msg.payload;\nnode.warn(obj.timestamp);\nlet out = new Date(obj.timestamp + 8*60*60*1000);\nmsg.payload = out.toISOString();\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":700,"wires":[["7d826552d450e75f"]]},{"id":"7d826552d450e75f","type":"ui_text","z":"f8bac4228331a020","group":"8d034e9d05738f91","order":3,"width":0,"height":0,"name":"","label":"DateTime","format":"{{msg.payload}}","layout":"row-left","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":550,"y":700,"wires":[]},{"id":"9d82889e4283ddb6","type":"link in","z":"f8bac4228331a020","name":"info","links":["caeaae64e88673b5"],"x":235,"y":800,"wires":[["164b926daf89137e"]]},{"id":"164b926daf89137e","type":"function","z":"f8bac4228331a020","name":"function 2","func":"let data = msg.payload;\n\nlet msg1 = {};\nmsg1.payload = data[0];\n\nlet msg2 = {};\n//node.warn(data[2]);\n//msg2.payload = parseInt(data[2].toString(10), 16)\n//let dec = 0x302;\n//msg2.payload = parseInt(dec.toString(10), 16)\n//(data[2] >>> 0).toString(2);\n\n\nreturn [msg1, msg2];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":800,"wires":[["46677c03f062d541"],[]]},{"id":"46677c03f062d541","type":"ui_text","z":"f8bac4228331a020","group":"8d034e9d05738f91","order":1,"width":0,"height":0,"name":"","label":"Model Name","format":"{{msg.payload}}","layout":"row-left","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":500,"y":780,"wires":[]}]
The Dashboard:
PM-3133 Dashboard.PNG
PM-3133 Dashboard.PNG (146.45 KiB) Viewed 3043 times
Best Regards,
IoT Studio Support Team
Post Reply