Communication with energy power meter Mercury 200.02 over serial interface.
-
-
Save farcop/2d5081090c7ce80f8bda34bb5f26bb47 to your computer and use it in GitHub Desktop.
node-red-MercuryStats
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":"ba386057.845d3","type":"mqtt-broker","broker":"api.xively.com","port":"1883","clientid":""},{"id":"b28d45e3.18cd","type":"serial-port","serialport":"/dev/ttyUSB0","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","newline":"500","bin":"bin","out":"time","addchar":true},{"id":"9e8d7bd0.703918","type":"serial out","name":"(in) Mercury200.02","serial":"b28d45e3.18cd","x":719,"y":394,"z":"c2f61f76.2fd47","wires":[]},{"id":"2ed275cf.9e4f72","type":"inject","name":"getCurrentEnergy","topic":"","payload":"","payloadType":"none","repeat":"60","crontab":"","once":false,"x":293,"y":199,"z":"c2f61f76.2fd47","wires":[["e957721d.477ee"]]},{"id":"5190eab0.c467c4","type":"serial in","name":"(out) Mercury200.02","serial":"b28d45e3.18cd","x":723,"y":480,"z":"c2f61f76.2fd47","wires":[["d917dde9.93694"]]},{"id":"e957721d.477ee","type":"function","name":"BinaryRequest","func":"msg.payload = new Buffer ([0x00,0x06,0x47,0x5E,0x63,0xEC,0xD4]);\nreturn msg;","outputs":1,"x":468,"y":199,"z":"c2f61f76.2fd47","wires":[["9e8d7bd0.703918"]]},{"id":"d917dde9.93694","type":"function","name":"Parser","func":"var cmd = msg.payload.toString('hex',4,5);\nif(cmd==63) {\n\tmsg.payload.voltage = Number(msg.payload.toString('hex',5,7)/10);\n\tmsg.payload.amperage = Number(msg.payload.toString('hex',7,9)/100);\n\tmsg.payload.energy = Number(msg.payload.toString('hex',9,12)/1);\n\treturn [ msg, null ];\n} else if (cmd==27) {\n\tmsg.payload.T1Power = Number(msg.payload.toString('hex',5,9)/100);\n\tmsg.payload.T2Power = Number(msg.payload.toString('hex',9,13)/100);\n\treturn [ null, msg ];\n}\n","outputs":"2","x":908,"y":480,"z":"c2f61f76.2fd47","wires":[["4f3b5afc.c3b48c"],["3dc28dea.3a3b5a"]]},{"id":"82a77e34.d2d158","type":"mqtt out","name":"Xively","topic":"/v2/feeds/19249442.json","qos":"","retain":"","broker":"ba386057.845d3","x":1166,"y":433,"z":"c2f61f76.2fd47","wires":[]},{"id":"77b961aa.72b808","type":"inject","name":"getTotalEnergy","topic":"","payload":"","payloadType":"none","repeat":"3600","crontab":"","once":false,"x":293,"y":269,"z":"c2f61f76.2fd47","wires":[["59e6f1e8.5e931"]]},{"id":"59e6f1e8.5e931","type":"function","name":"BinaryRequest","func":"msg.payload = new Buffer ([0x00,0x06,0x47,0x5E,0x27,0xEC,0xE7]);\nreturn msg;","outputs":1,"x":468,"y":269,"z":"c2f61f76.2fd47","wires":[["9e8d7bd0.703918"]]},{"id":"f456257d.620be8","type":"comment","name":"Read data from Energey Meter 'Mercury 200.02'","info":"","x":358,"y":446,"z":"c2f61f76.2fd47","wires":[]},{"id":"61ac228.ff1035c","type":"file","name":"HTTP page","filename":"/var/www/power.html","appendNewline":false,"overwriteFile":"true","x":1181,"y":519,"z":"c2f61f76.2fd47","wires":[]},{"id":"3dc28dea.3a3b5a","type":"template","name":"html","field":"payload","template":"<html>\n<head>\n<meta http-equiv=\"refresh\" content=\"3600\">\n<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n<style>\nbody {font-size:30px;font-family:Verdana;} a,a:hover,a:visited{color:green;}\n</style>\n</head>\n<body>\nEnergy Meter<br/>\n\"Day\":<span style=\"font-weight: bolder;font-size:90px;color:red;\">{{payload.T1Power}}</span>kW*h<br/>\n\"Night\":<span style=\"font-weight: bolder;font-size:90px;color:red;\">{{payload.T2Power}}</span>kW*h<br/>\n\n<a href=\"https://xively.com/feeds/19249442\" />ïàðàìåòðû ñåòè</a>","x":965,"y":584,"z":"c2f61f76.2fd47","wires":[["61ac228.ff1035c"]]},{"id":"4f3b5afc.c3b48c","type":"template","name":"json","field":"payload","template":"{\n\t\"version\":\"1.0.0\",'\n\t\"datastreams\":['\n\t {\"id\":\"voltage\", \"current_value\":\"{{payload.voltage}}\"},\n\t {\"id\":\"amperage\", \"current_value\":\"{{payload.amperage}}\"},\n\t {\"id\":\"energy\", \"current_value\":\"{{payload.energy}}\"}\n\t]\n}","x":956,"y":383,"z":"c2f61f76.2fd47","wires":[["82a77e34.d2d158"]]}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment