Solar Boiler with heating element PID

Hi guys,
first of all I appreciate this forum so much - I have solved most of my problems in my node red development by reading through the forum! However, now I stumbled into the following problem that I need your advice with.

My Setup:
I live on a sunny greek island and we produce our hot water using a steam based solar heater that has a 150L boiler with a heating element of 4.5 kW (ON/OFF). I measure the water temperature every 5 sec with a DS18B20 that is placed into a 30cm probe that runs into the middle of the boiler, however really close to the heating element.

On a cloudy day, usually people just turn on the switch and leave it on for 20-30 min and shower. Since the heating element is quite powerful and also high in energy consumption I thought to optimise this process. Also, we rarely have a day with 100% cloud cover throughout, so maybe firing up the heating element is not necessary at all. So monitoring and smartly switching the heating element based on temperature settings sounded like a good idea.

My Problem:
I am currently using a PID Function to facilitate the heating process. User selects a temperature and starts the PID controller. I have tuned the controller mainly using this thread (!topic/node-red/6f_R48lX5JU) and I am quite happy with the initial tuning. However I am facing a couple of hiccups which make the tuning a bit difficult:

  • The initial temperature at the beginning of the PID controlling process is variable.
  • The target temperature (SetPoint) is variable, for one person ~45C for two ~65C.

Is there any way around it? Would you use variable tuning figures depending on the above two?

Also, I would like to know WHEN the PID controller is stable enough so that the temperature is actually close to the SetPoint. Of course you can see the intervals between Boiler Heating ON moments on the graph getting bigger but I would like to automate this if possible. On the below graph you can see an example of my PID heating last night, and even though the temperature was stable for quite some time, after turning the controller off it dropped by 7-8C. This is probably due to the proximity of the temperature sensor to the heating element, due to the power of the heater and the slow mixing of the cold / warm water masses in the boiler. Any idea how to deal with this?

My PID values:
PB: 4
Integral time: 90
Derivative time: 0
Initial integral: 0
Max sample interval: 1800
Derivative smoothing: 3

My timeprop values:
Cycle time: 60
Actuator dead time: 1
Trigger: 0.6

Appreciate your support!

You shouldn't need to adjust the tuning parameters for the different conditions. The process transfer function (the maths relating the output to the input over time) does not change as you change initial temperature or setpoint and it is that transfer function that determines the optimum tuning constants.
If you are seeing poorer control under some conditions it may be that the tuning could be improved. The first step is to include the node-red-contrib-pid node power output in the chart, that is extremely useful in checking all is well, you might find that it is not as well tuned as you think when you look at what the power is doing.

Thanks for your input Colin.
I plotted the PID Power Output on the graph and changed my PID values a bit (timreprop unchanged):
PB: 10
Integral time: 80
Derivative time: 16
Max sample interval: 1800
Derivative smoothing: 3

After reading some other topics about PID the constant ON/OFF of the heating element and the heavy oscillation on the PID Power Output seem still a concern, what do you think?

Also, I am still quite surprised that after manually turning off the process after 1h 20min the set temperature is still not achieved and settles around 5C degrees lower than Setpoint 50C. Any suggestions on that?

Thanks a lot!

I think that indicates that the sensor is too close to the heater, so it is controlling the temperature of the water near the heater and not the temperature of the bulk of the water. That would explain why the response of the temperature is so quick, which I was surprised at since you are heating a large quantity of water. It would be better if you could move the sensor away from the heater element. If you did that you would need to retune the loop as the response would then be much slower and would be a better representation of what you really want to control

The oscillation on the power output is probably due to the same problem, that the temperature is moving significantly in response to the heating switching. If you move the sensor as above and the whole loop becomes much slower then you should be able to slow down the time proportion signal too so as to reduce the cycling. How are you switching the heater? Is it a big relay or solid state?

Yeah good point, I was suspecting this could be an issue. However I went ahead since the original analogue thermostat of the boiler uses the exact same copper lead. (see picture below)

I am considering to change my setup and use a T-split on the warm-out of the boiler and immerse a probe holding the DS18B20 around 20cm / ~8in into the lower/colder part of the tank. Will do that in the next days and let you know :slight_smile:

I will try it in the next days.. For the switching: I am using a small 3.3V 1-CH Optocoupler (10A) that closes a circuit and actuates a 20A contactor, similar to this one here:

normally in a solar system there are, in the tank, 2 probes: bottom and top, and in the panel another probe.
The one that interests us for the heating, is the one from above (sensor 1). This is where hot water comes out. It is it who will tell the heating element if it should power on.
the long tube that we see, next to it, along the heating resistance is a safety probe which must cut the heating beyond 60-70 or 80 is adjustable.

The sensor 2 is far from the heating resistor.

Thanks for your effort, SuperNinja - and apologies for not being clear.
The solar system I am using is a compact solar heater that heats up a liquid that is running through the panels, rises up into a shell around the water tank and heats that water up. For additional heating, a simple heating element is inserted into the tank. Just like this:

Oh yes I see. So if you can't put a probe away from the heating element, inside the balloon, you can fix it against the tube where the hot water comes out towards the house.
It will have to be put as close to the balloon, and insulated as best as possible so that it measures the temperature of the pipe, and not the temperature of the ambient air.

OK a system such as the one you have shown usually uses a thermosiphon effect i..e hot water rises and cold falls usually with a one way valve so there is no reverse effect overnight.

I would leave your current system in place (once tuned properly based on proble location) - but put another one on the inlet and outlet to the heating panel - measure the temperature of the water on both and keep track of them - you should be able to create a table about how long it takes to heat up based on the rising termperature of the returning water and the ambient air temp


I am targeting to measure it directly from the warm water outlet, with a t-split - as it can be seen on the graph below (new setup vs current setup), to avoid any false measurements. Will try it in a few days!

Thanks for your suggestions, Craig. Indeed it is using the thermosiphon effect, however the collector water and the tank water are separate. I am not sure how measuring the temperature on the inlet and outlet of the collector/heating panel (see below blue circles) would benefit me since I am more interested in the heating behaviour of the electric heater and the overall tank temperature. Or do you mean on the inlet / outlet of the actual water tank?
My goal is to:
a) know when it is necessary to turn on the electric heater
b) know how long the electric heater needs to stay on to reach temperature x

good idea !

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.