Cross-section thermal model: solar gain heats the interior, conduction loses heat to the outside through the glazing, ventilation exchanges air, and a heater actuator adds heat — all combined in a PID controller driving the vent and heater.
dT/dt = (Q_solar + Q_heater − U·A·(T_in−T_out) − Q_vent)/C
Q_vent = k_vent · ventOpen · (T_in − T_out)
u(t) = Kp·e + Ki·∫e dt + Kd·de/dt
- Target temp — the PID setpoint the loop tries to hold inside the greenhouse.
- Outside temp — external disturbance; try extremes to see the controller struggle.
- Vent opening limit — caps how far the roof vents can open, limiting passive cooling capacity.
- Heater power — maximum heater output available to the controller for cold nights.
- Day / Night toggle — switches solar gain on/off, the dominant daytime heat source.
Real application: commercial greenhouse climate computers run this exact heat-balance + PID logic to hold crops within a few tenths of a degree using minimal energy.