Energy monitor for heat pump



I want to keep track of my heat pumps energy consumption. I got a meter with a blinking diode it blinks 1000/kWh I know how to get the signal in to the raspberry pi and how to create a diagram. I just need to what to write ind the function node.

And yes I have been trawling Google for answers but I can't find anything.

Best regards Christian Rosenkrantz



Hi @Rosenkrantz

we can't really tell you what to write in a Function node without knowing more about what you have setup already.

Do you have the signal coming into a node-red flow already? Do you have it connected to a GPIO pin that pulses with each blink of the led? Is it some other connection? What messages do you get in the flow and what do you want to do with the data?




It is the same as this project :

I got a puls coming in to the pi from a lm393.
It's connected to a gpio pin and it a 1 and a 0.
I want it to go to a chart so I can see the temperature and the energy consumption



Have you already tried reading the GPIO pin using the Raspberry pi node rpi gpio in Node-RED?

See also section "Accessing GPIO" on



Yes I know how to get readings from the gpio. The only thing I don't know is how to calculate the gpio readings to kWh.



OK, I assume that you get a message for every pulse in Node-RED (maybe 2 messages one for the gpio pin changing to 1 and another for the gpio pin changing to 0).

So if 1000 pulses corresponds to 1 kWh then it is just a matter of counting the pulses in an interval.
To make life easy there exists also a node (= that will do this counting and charting for you.

If a 1 is sent for every pulse then the chart will show the Wh in Y-axis instead of KWh. If you want KWh then you need to add a change node that changes the 1 into 0.001 before injecting it in the node-red-contrib-dashboard-sum-bars node.



Thanks mayby that will work but it would be nice to get a line in this chart :

This is a screenshot of the temperature on my heat pump. Then i can if something i wrong with it.



Here below an example flow for a pulse counting chart. Basically it will store the pulse count in flow context variable "pulse_count". I hope this gets you on the road.

[{"id":"d0c1c3c1.bcac","type":"inject","z":"aebab71e.d21788","name":"every 5 minutes","topic":"","payload":"","payloadType":"date","repeat":"60","crontab":"","once":true,"onceDelay":0.1,"x":170,"y":340,"wires":[["3c29ba3a.32b306"]]},{"id":"3366e56f.849c7a","type":"rpi-gpio in","z":"aebab71e.d21788","name":"","pin":"13","intype":"tri","debounce":"25","read":false,"x":110,"y":220,"wires":[["a1a58290.05041"]]},{"id":"f8736769.a757c8","type":"change","z":"aebab71e.d21788","name":"increment flow pulse count","rules":[{"t":"set","p":"pulse_count","pt":"flow","to":"$flowContext(\"pulse_count\")+1\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":220,"wires":[[]]},{"id":"a1a58290.05041","type":"switch","z":"aebab71e.d21788","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":290,"y":220,"wires":[["f8736769.a757c8"]]},{"id":"4dd9cc8e.4be7e4","type":"inject","z":"aebab71e.d21788","name":"test inject 1","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":160,"wires":[["a1a58290.05041"]]},{"id":"492d7819.1fd118","type":"inject","z":"aebab71e.d21788","name":"test inject 0","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":120,"wires":[[]]},{"id":"2fd81bcd.7cf3c4","type":"ui_chart","z":"aebab71e.d21788","name":"","group":"59f79075.4aae4","order":0,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":910,"y":340,"wires":[[],[]]},{"id":"3c29ba3a.32b306","type":"change","z":"aebab71e.d21788","name":"set msg.payload = flow.pulse_count","rules":[{"t":"set","p":"payload","pt":"msg","to":"pulse_count","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":340,"wires":[["320a1f2e.2bffe","61c339f4.76fd48"]]},{"id":"320a1f2e.2bffe","type":"range","z":"aebab71e.d21788","minin":"0","maxin":"1000","minout":"0","maxout":"1","action":"scale","round":false,"property":"payload","name":"convert to kWh","x":720,"y":340,"wires":[["2fd81bcd.7cf3c4"]]},{"id":"61c339f4.76fd48","type":"change","z":"aebab71e.d21788","name":"set flow.pulse_count = 0","rules":[{"t":"set","p":"pulse_count","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":400,"wires":[[]]},{"id":"cd73904e.31704","type":"inject","z":"aebab71e.d21788","name":"test chart update","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":280,"wires":[["3c29ba3a.32b306"]]},{"id":"59f79075.4aae4","type":"ui_group","name":"Group 1","tab":"3097cbe4.f0ae84","order":1,"disp":true,"width":6},{"id":"3097cbe4.f0ae84","type":"ui_tab","name":"Tab 6","icon":"dashboard","order":7}]


Thanks janvda this looks like it will work. but now my node red has crached. i will update later



Somethins i wrong. My sub meter says 4.3 kWh ish. But my chart says 0.07 (0.07 (readings pr minute) * 60 minutes is 4.2 kWt) but how can i update the chart per 5 seconds (my temperature is updated every 5 seconds) and still get the output to show the same as my sub meter?

The dragon teeth from 20:03 and to 20:23 is updated with 5 seconds and the last bit of chart is updated every 1 minute like it was i your original node



I think you should just change the interval in the inject node to 5 s.

4.2 kWh seems not that bad if the actual value should be 4.3 kWh.