Increase room temperature as fast as possible, but without overheating

felic:
I want the Arduino to be able to increase the room temperature to a given value e.g. 25°C. This should on the one hand happen as fast as possible.

The problem with that code is that once the temperature is reached and the valve is closed, the radiator of the heating is still extremely hot causing the room temperature to increase even further.

I wonder if the complexity of PID has much to offer in this case. The problem is that there is no cooling system to counteract excessive heat - and a cooling system would just waste energy anyway.

I reckon you need to do some tests to figure out how much the temperature rises after the heating valve is closed and then build into your program the decision to turn the valve off at T - R where T is the desired temperature and R is the number of degrees that the temperature will continue to rise after the valve is closed.

Of course the value of R may vary widely depending on the outside temperature and whether the room door is regularly opened and closed by people coming in and out on one day and not on another day.

It might help to have a small array with several (maybe 4 or 8 would be enough) values of R and if the Arduino discovered that the temperature did not rise to the desired value quickly enough (or if it rises too high) it could switch to using a different R value for the next few hours.

...R