Hello,
I want to display 3 values on the dashboard (AMP, KW, PF ) i have added 3 functions for the same.
I have published data in inject node in JSON Format, can someone please help me on this?
Hello,
I want to display 3 values on the dashboard (AMP, KW, PF ) i have added 3 functions for the same.
I have published data in inject node in JSON Format, can someone please help me on this?
I think we will need a bit more information as to where the problem is.
Is it getting three outputs from a single 'function' node, or how to split the 'json' or something else??
If you can, please publish (the flow for) what you tried so far.
In particular you need to show us what the data coming in looks like.
Did you realise that you can select just part of a message to show in many of the dashboard nodes. So for example, guessing at what you might be trying to do, if AMP is in msg.payload.AMP then in a text node, for example, in the Value Format field you can put {{msg.payload.AMP}}
so if your other data fields are similarly available you can feed the same message into all the dashboard nodes and select in the node what to display.
//p=JSON.parse(msg.paylaod);
//msg.payload=p.context.KW
msg.payload = msg.payload.context.KW;
return msg;
Above is the code that i have used in Function node, Also data format attached which is in JSON Node.... in JSON there are 3 values i am receiving and i want to dispaly it on dashboard..
hope this works...
Thanks
Thanks Colin,
I have used 3 function node in node red ( KW,PF,AMP) and data is coming on said MQTT Topic, i have subscribe same topic and connected to the 2 Text Node, Gauge Node using Node Function, in node function i have mentioned below code..
//p=JSON.parse(msg.paylaod);
//msg.payload=p.context.KW
msg.payload = msg.payload.context.KW;
return msg;
//p=JSON.parse(msg.paylaod);
//msg.payload=p.context.KW
msg.payload = msg.payload.context.AMP;
return msg;
//p=JSON.parse(msg.paylaod);
//msg.payload=p.context.KW
msg.payload = msg.payload.context.PF;
return msg;
Now data is coming in below format where you can see 3 values are there..
{"context":{"Meter_Name":"TG3","KW":0,"AMP":0,"PF":0},"datastream_name":"MeterC","value":"11","tstamp":1596196265000}
Getting error.
"TypeError: Cannot read property 'KW' of undefined"
"TypeError: Cannot read property 'AMP' of undefined"
"TypeError: Cannot read property 'PF of undefined"
Flow image also added in this msg..
p
Is that image a debug window ? Its not something i have seen looking like that before ?
Could you attach a debug node to the Incoming MQTT stream and have it display the full Debug of the whole messsage and show us the left side debug output
Craig
Are you just trying to show the values recieved by MQTT?
Like this?...
Did you set the MQTT in node to Parse JSON?
If you do that then you simply copy the path from the debug & paste it into the text/gauge...
Yes i am just trying to show real time value on gauge which i received on MQTT, i have used JSON node..
Issue has been resolved, Thank you very much all of you guys.
It would be great if anyone help me on making dashboard more attractive. I have attached SS which i had made.
Here's a screen-shot of my simple dashboard.
I'm using a PZEM-04 module with a split-ring current transformer feeding into a Wemos D1 Mini flashed with Tasmota that transmits to Node-RED via MQTT (very similar to your system).
Here's a screen-shot of the NR flow.
And here's the flow-code that uses a dynamic band changer for the Power-gauge.
[{"id":"47ec6f8.e8c9b9","type":"ui_gauge","z":"f0f0fcca.cf3ac8","name":"","group":"900b126f.c721c8","order":2,"width":"3","height":"2","gtype":"gage","title":"","label":"units","format":"{{value}}","min":"200","max":"250","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":710,"y":180,"wires":[]},{"id":"ea161a29.89ceb8","type":"function","z":"f0f0fcca.cf3ac8","name":"","func":"msg.payload = msg.payload.ENERGY.Voltage;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":550,"y":180,"wires":[["47ec6f8.e8c9b9"]]},{"id":"5ae7768c.60cf88","type":"ui_gauge","z":"f0f0fcca.cf3ac8","name":"","group":"c18058f9.c02498","order":2,"width":"3","height":"2","gtype":"gage","title":"","label":"units","format":"{{value}}","min":"0","max":"10","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":710,"y":220,"wires":[]},{"id":"1f0c06ab.5660b1","type":"function","z":"f0f0fcca.cf3ac8","name":"","func":"var current = msg.payload.ENERGY.Current;\n\nflow.set(\"current\",current);\nmsg.payload = current.toFixed(2);\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":220,"wires":[["5ae7768c.60cf88"]]},{"id":"82d6bd9.cb8dcc","type":"ui_gauge","z":"f0f0fcca.cf3ac8","name":"","group":"a4a4f685.020db8","order":2,"width":"3","height":"2","gtype":"gage","title":"","label":"units","format":"{{value}}","min":"0","max":"1","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":710,"y":260,"wires":[]},{"id":"97b76b0c.33ebb","type":"function","z":"f0f0fcca.cf3ac8","name":"","func":"msg.payload = msg.payload.ENERGY.Factor;\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":260,"wires":[["82d6bd9.cb8dcc"]]},{"id":"763ebc9b.9285fc","type":"ui_gauge","z":"f0f0fcca.cf3ac8","name":"","group":"9ef7a427.101b48","order":2,"width":"3","height":"2","gtype":"gage","title":"Power","label":"units","format":"{{value}}","min":"200","max":"250","colors":["#c0c0c0","#c0c0c0","#c0c0c0"],"seg1":"","seg2":"","x":990,"y":360,"wires":[]},{"id":"5fdefe64.082328","type":"function","z":"f0f0fcca.cf3ac8","name":"Dynamically alter guage band","func":"var max = 300;\nvar min = 0;\n\nvar voltage = msg.payload.ENERGY.Voltage;\nvar power_factor = msg.payload.ENERGY.Factor;\n\nvar current = flow.get(\"current\") || 1.0;\n\nvar power = voltage * current;\npower = power.toFixed(0);\n\nif (power > 5000) {\n max = 6000;\n min = 5000;\n}\nelse if (power > 4000) {\n max = 5000;\n min = 4000;\n}\nelse if (power > 3000) {\n max = 4000;\n min = 3000;\n}\nelse if (power > 2000) {\n max = 3000;\n min = 2000;\n}\nelse if (power > 1000) {\n max = 2000;\n min = 1000;\n}\nelse if (power >500) {\n max=1000;\n min=500;\n}\nelse {\n max=500;\n min=0;\n}\nmsg = {payload:power,ui_control:{min:min,max:max},topic:\"Power_Watts\"};\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":730,"y":360,"wires":[["763ebc9b.9285fc","9480ad7d.79ca18"]]},{"id":"9fc093bb.f4e298","type":"mqtt in","z":"f0f0fcca.cf3ac8","name":"","topic":"tele/energy_sensor/SENSOR/#","qos":"0","datatype":"json","broker":"628037a0.fd0ec8","x":210,"y":180,"wires":[["51a1a04c.4b722","ea161a29.89ceb8","1f0c06ab.5660b1","97b76b0c.33ebb","97591472.5b5308"]]},{"id":"51a1a04c.4b722","type":"debug","z":"f0f0fcca.cf3ac8","name":"","active":false,"console":"false","complete":"false","x":490,"y":100,"wires":[]},{"id":"9480ad7d.79ca18","type":"ui_chart","z":"f0f0fcca.cf3ac8","name":"Watts","group":"bb436026.d3b128","order":0,"width":"12","height":"8","label":"Energy consumption over the last 2-Hrs","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"step","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"2","removeOlderPoints":"520","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":990,"y":440,"wires":[[]]},{"id":"78f8ecf5.0b398c","type":"ui_template","z":"f0f0fcca.cf3ac8","group":"900b126f.c721c8","name":"","order":1,"width":0,"height":0,"format":"<style>\n.masonry-container {\n width: 800px;\n}\n</style>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":720,"y":100,"wires":[[]]},{"id":"2af414b4.3834dc","type":"inject","z":"f0f0fcca.cf3ac8","name":"Clear the graph","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":440,"wires":[["9eeeb91.dd45748"]]},{"id":"9eeeb91.dd45748","type":"function","z":"f0f0fcca.cf3ac8","name":"","func":"msg.payload = [];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":480,"y":440,"wires":[["9480ad7d.79ca18"]]},{"id":"97591472.5b5308","type":"delay","z":"f0f0fcca.cf3ac8","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":480,"y":360,"wires":[["5fdefe64.082328"]]},{"id":"900b126f.c721c8","type":"ui_group","z":"","name":"Voltage","tab":"6d8b03e2.31316c","order":1,"disp":true,"width":"3","collapse":false},{"id":"c18058f9.c02498","type":"ui_group","z":"","name":"Current","tab":"6d8b03e2.31316c","order":2,"disp":true,"width":"3","collapse":false},{"id":"a4a4f685.020db8","type":"ui_group","z":"","name":"Power_factor","tab":"6d8b03e2.31316c","order":3,"disp":true,"width":"3","collapse":false},{"id":"9ef7a427.101b48","type":"ui_group","z":"","name":"Power","tab":"6d8b03e2.31316c","order":4,"disp":true,"width":"3","collapse":false},{"id":"628037a0.fd0ec8","type":"mqtt-broker","z":"","name":"156 server","broker":"192.168.1.154","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"bb436026.d3b128","type":"ui_group","z":"","name":"Energy Plot","tab":"6d8b03e2.31316c","order":5,"disp":true,"width":"12","collapse":false},{"id":"6d8b03e2.31316c","type":"ui_tab","z":"","name":"Home_Energy_Monitor","icon":"dashboard","order":19,"disabled":false,"hidden":false}]
I know this is s bit off topic but could you point me in the direction of how to do this. Google finds 'nothing'
This is the module I used PZEM-04 0-100A from BangGood with a serial connection to Wemos.
I cut the USB connector off the end of the lead and fed the Tx and Rx signals through level shifters as the PZEM-04 used 5V logic and the Wemos is 3v3. It took quite a lot of trail-and-error to find the best pins to use on the Wemos with Tasmota. I can draw out the circuit/schematic over the weekend if you need it.
Thank you, yes please
Hi Jeff @Buckskin, here's a very ROUGH sketch of the circuit.
I used a 4-channel level shifter. One UP channel (3v3 to 5v) and a DOWN channel (5v to 3v3) as my version of the PZEM-004T is powered from 5v and the Wemos is 3v3.
Here's the wiring at the PZEM-004T end.
Here's the layout of the breadboard that houses the Wemos D1 Mini (flashed with Tasmota 8.4.0).
And finally, here's a screen-shot of the PZEM-004T configuration panel.
I did try using the native Tx and Rx connections on the Wemos but couldn't get them to work.
I'll probably write this up as a tutorial (when I have some spare time ) for my IoT students.
Thank you, this is great. I think that this would make a great project that would also be useful for a student at home
Yes it probably would... but please be careful with the wiring as you (and/or the student) are dealing with...
MAINS voltages that could KILL you.
Please take extreme care!!!
Hey Dave,
Is that module actually outputting into USB i.e. serial to USB was part of the cable they supply ? So i could therefore connect 3 of them for my 3 phase into a USB hub and then into a Pi for monitoring my whole house power useage ?
Craig
Hi Craig,
The module came with a USB cable. I just cut the connector off the end as I didn't need it.
So I suppose the answer is 'yes' you could use three modules to measure the three phases.
The thing to note is the CT is clamped around the main feed (say the LIVE) and the Live and Neutral are wired to the PZEM-004T so the electronics can measure voltage, phase angle, etc...
Not sure how you would deal with a 3-phase supply.
Why have you got a 3-phase supply in a domestic house??
Hi Dave,
We are in Australia.
We have a large Aircon whole house ducted system that we installed about 15 years ago and had 3 phase installed for that.
When we had our house renovated - the sparky (a mate) pulled the 3 phases from the switchboard directly into our main house distribution panel
I did not realise this had to tape into the live and neutral - i thought it was simply the CT clamp - although i now note that they are talkign about 260V max voltage - our 3 phase is 415v across the phases
Will have to get my sparky involved to have a look and tell me the best way to monitor it all
Craig
Hi Craig,
That makes sense in respect of the 3-phase.
Do you mean you are using different phases in different parts of your house, or you have the option to do that??
I'm not an eletcrician, but would have thought that the various loads (in your home) would have gone between a phase and the star-point to give you 230v and just the aircon unit would be driven by 3-phase.
The PZEM-004T module has a lot of eletconics inside it to do all the clever stuff and I definitely wouldn't connect it across two phases.Too dangerous!!!
I used to use a simple CT clamp (years ago) across my LIVE feed and a simple circuit to measure the induced voltage/current and transmit this value via 433MHz to a remote indicator.
Very, very simple readings - nothing like what the PZEM offers.
I'd be interested to hear what your 'sparky' says.
David
Hi Dave,
Yep been speaking to my sparky tonight - he does not completely remember what he did here a few years ago - but is pretty sure that all 3 phases come into the main switchboard (and it looks like that to me as well). He is coming out on Wednesday to confirm what we have and where i can tap into the main incoming and outgoing 3 phase.
It looks like we are 4 wire 3 phase and hence each phase can be tapped with the neutral to give 240/230v
I will have a look at some of the energy forums (iotawatt and Openenergy monitor) and see if there are other aussies and what they are doing.
Will report back once i have a handle on it all.
Craig