Heating water with solar power and node-red-contrib-pid

Hi Guys,

question about node-red-contrib-pid, heating water, solar power and, of course, nodered.
What i have:
I am using a small solar plant for my own use, about 1.5KW peak. When
the sun shines an i dont use much electric devices i feed my power to
the energy provider, for nothing.
Instead I want to use the power to heat my water.
I also have a superfast modbus power counter (SDM630) which updates
my mqtt/nodered every second with actual power values.
When i feed power to the energy provider the sdm630 reports a negative power value.
What i need is a control circuit that powers my heater in my water
tank. (Heating unit, controlled by raspi and PWM to 0-10V thyristor
switch) when the power from the meter goes below zero.
It should heat as much as it needs to get the power value to min of -10(setpoint)! (for example)
On cloudy days the power level jumps from 400W to 1500W and back in
seconds. The reaction of the node has to be superfast and should not
use power from the energy provider because it is to slow.
Superfast means, other than the examples i found for heaters - they react in minutes or houres - i need the circut to react in a second.
-500W means 490 Watt to the heating, next second -140W means 130 Watt to the heating.... at once!
Input value is only the Power from the SDM630.

Anybody knows if node-red-contrib-pid can do that?
What are the basic start values for all parameters of node-red-contrib-pid to start?
What values do you need to give me a starting point?

regards Martin

Can't you use a simple arithmetic calculation each second (so triggered by the mqtt power message) to determine how much power to take for the next second in order to keep the value at approx zero?

yes, that was the plan bevor i found node-red-contrib-pid.
But that involves 2 more power meters.
At now i have 1 meter that measures the overall power. i need at least 2 more to measure the solar power and the power i need for my devices.
Than is is easy, but i want to avoid paying money for power meter and electrician for mounting it.
But it is definitely plan b.

regards Martin

I don't understand that. I am suggesting a straight replacement of the PID node with the node that does the calculations. I don't see that it needs any more information than the PID node does. What inputs are you planning to provide to the PID node and what are you going to do with the output?

[Edit] Remember that you already know how much power you are putting into your heater because that is what you are setting with the PWM output.

I agree with @Colin on this one. You don't want / need a PID, just a simple if-then loop.
Source: I have tuned 1000's of PID loops over the past 35 years.... What you are describing is not a PID loop.


ok - will try. but if i have -200 Watts at my power meter and i put 200 Watts in my heater the meter show 0. what then? go on putting 200W in my heater...? until power meter shows 50 Watts and then i put only 150w to the heater?

i Have uploaded data https://pastebin.com/ueKRKL9D with ms from last value to now and power. But i dont see how the math can be to get power to zero.
It is not 0 = power - x ! because when i apply the power to the heater power changes!
About n Watts, what i suposed my PI send to the heater. But again, after sending n Watts to the heater, power changes ...

regards Martin

Each second you will get the current nett power. So in the case you suggest it might be -200, so in principle you could put 200 more into the heater than it is currently being given. A second later you will get another reading, if nothing else has changed then presumably that will be close to zero, so maybe +10, in that case take 10 off the power to heater and wait for another second, and so on. In practice, however, nothing is instantaneous and you will have some time delays in the system so you might find if you do exactly as suggested that you end up with an unstable system, with the power leaping up and down every second trying to get to zero. So I suggest that each second you only go part of the way to cancelling out the error. You could start at 80% of the way maybe. In that case when you see a power of -200 then multiply that by 0.8, giving 160 extra Watts for the heater. Then at the next second you might have -40, so add 32 to the heater power, and so on. Then you can play with the multiplier to get the best control. Feed both the measured nett power and the power you are giving to the heater to a graph so you can get a good idea of how it is performing, then you can tweak the multiplier to get the best control. The nearer the multiplier is to 1 then the quicker will be the response when something changes, but if you go too high then it may start leaping about.

To get a good perspective on this, have a look at https://learn.openenergymonitor.org/pv-diversion/background/meters
You maybe need to think in terms of a 'energy packets' or often called 'energy buckets', as energy usage is usually registered when 1Wh (3600J) of usage has been recorded, so you can 'borrow' energy, so long as you stop short of overflowing the energy packet, and triggering the meter register.

1 Like

My charts only update every 5 seconds, so you don't get a detailed view of what's happening under the hood, just averaged data to 5 second windows, but this was recorded a few minutes ago.

The yellow trace is the solar power feed, and due to passing clouds, the panels are generating between 600W and just over 1100W.

The green trace shows the power feed to a 1100W immersion heater, and you can see it is being switched on & off because there isn't quite enough generation to support it being permanently on. (In addition to the immersion heater, about 150W is also being consumed with household appliances which isn't shown in this chart, so to be permanently 'on', the solar gen would need to be at least 1250W)

The blue trace is showing what power is being used from the grid (positive values), and power being given back to the grid (negative values). Now back to the comment above about 'energy packets', the chart shows that the blue line isn't flat, it's constantly filling and emptying the energy packets, and will draw power from the grid up to the point just before the meter register clocks up a chargeable 1Wh. Then it allows power to flow back to the grid to again fill up the packet again.
If I look at my meter, I get no increments in it's display, and the red blinking light remains off - so free hot water!


NOTE, when I built this in 2012, I initially used a relay to switch the immersion heater, but found that due to the frequency of it being switched on/off, it's lifecycle quickly expired, so it's important to use a solid state switching device.