Is "power" instead of "temperature" useable as a PID input?

Hello,
At the moment my solar paneIs are producing more then I can use. Altough it is not the most efficient way I want to use the energy to heat a boiler instead of returning to the grid. My problem is that the PID can only work with temperature as an input. Am I correct? I would like to make use of the example like this : GitHub - patrickcollins12/esphome-fan-controller: ESPHome Fan Controller

I would like to make use of the entity “Power Production” of my smart meter as setpoint for the PID control and have a SSR to fire a heating element in the boiler.

Who can give me the push in the right direction?

Thanks in advance,
Paul

Interesting thought. I cannot help with the actual question, but there is a difference in how such a system would behave. You’d want the energy to go to other things if needed, but the boiler itself will add tot the total load if turned on. So there is a feedback loop that is way more direct than would normally occur when controlling temperature. If you turn on the heat of the boiler, the energy consumption will immediately rise. Does that require a PID, or is the relation so direct you could just as easily use a simpler calculation?

EDIT - Thinking a bit more about it: that isn’t exactly true as the boiler as a thermostat of its own. From the PID’s point of view it will behave rather unpredictable: sometimes it will do as described above, and sometimes it will not respond at all because the boiler is already hot. If the PID tries to modulate the boiler, the boiler will have quite a different modulation of it’s own. I have no idea how that will behave in the end - it may work well and is certainly worth an experiment. I think a PID could be used, the’s no reason it couldn’t optimize other types of inputs. I’m just not sure how it would behave.

Unless you’re thinking of not controlling the temperature of the boiler at all, which is probably dangerous. And on top of all that, you’d also need a kind of bypass mechanism if you want to take a shower and there is no sun. The boiler can’t be turned off permanently I guess? basically you need a control system that balances two outputs, not one.

Maybe this is something that AI would be really good at?

Hi all,
@Edwin_D , thanks for the comments.
Safety first of course. The pressure safety valve is in place :wink:
The control loop should do its job because of the fact that the PID will start at 0% output. While the power production will increase so will the output to keep the setpoint at lets say 0 Watts. If a cloud will decrease the power production suddenly, the PID will react fast enough to keep the power production at 0 Watt. Even when the oven or washer starts the power production can go below 0 Watts, now I am consuming and the PID output will be 0%.

Only point I am dealing with is the type of input.

Thanks,
Paul

I think that would be true if the boiler would behave more predictably. If you keep the boiler thermostat in place, you might need to do something to avoid it turning the boiler off and on in short succession if the boiler consumes more than your power overproduction. But then again, maybe a PID does that all on its own, I’m not really sure.

But to get back to your origial questions, the PID will handle any value. If the implementation is too strict in allowing other units you could always create a template sensor to represent power as temperature.

Hi,
That is a nice one

Blockquote If the implementation is too strict in allowing other units you could always create a template sensor to represent power as temperature.

Can you explain how this is done?

Cheers.

In order to represent the boiler power usage (or any other numerical state) as temperature, you could put something like this in your templates.yaml file. You could divide the state by some number if you want the value to be more in a normal temperature range, but I would let it be so you won’t mistake it for an actual temperature:

- sensor:
    - name: Blazing hot boiler
      unique_id: sensor.blazing_hot_boiler
      device_class: temperature
      unit_of_measurement: °C
      availability_template: "{{ is_number(states('sensor.boiler_power')) }}"
      state: "{{ states('sensor.boiler_power') | float(0) }}"

Hi @Edwin_D ,
Thanks, this works for me. I can now focus on the example I mentioned.
Cheers.

1 Like

Hello, did you manage to use a PID to regulate power ? If yes do you have your ESPhome yaml file available ?

Hey, i have exactly the same idea, could you share your YAML code ?