37 float p = power / 1000;
39 return (p * t) / (c *
m);
43 float value =
clamp(output_value, 0.0f, 1.0f);
47 temperature += this->
delta_t(power);
53 float cool_power = (thermal_conductivity * surface * dt) / update_interval;
54 temperature -= this->
delta_t(cool_power);
57 delayed_temps.push_back(temperature);
59 delayed_temps.erase(delayed_temps.begin());
60 float prev_temp = this->delayed_temps[0];
62 float ret = (1 - alpha) * prev_temp + alpha * prev_temp;
Base class for all output components that can output a variable level, like PWM.
float efficiency
current temperature of object in °C
void write_state(float state) override
This class simplifies creating components that periodically check a state.
constexpr const T & clamp(const T &v, const T &lo, const T &hi, Compare comp)
float heat_power
specific heat capacity of mass in kJ/(kg*K), here: water
float output_value
how many update cycles to delay the output
float temperature
mass of simulated object in kg
float mass
surface area in m²
void publish_state(float state)
Publish a new state to the front-end.
size_t delay_cycles
storage of past temperatures for delaying temperature reading
float delta_t(float power)
float ambient_temperature
Heating power in W.
float thermal_conductivity
heating efficiency, 1 is 100% efficient
float update_interval
Ambient temperature in °C.
Implementation of SPI Controller mode.
float specific_heat_capacity
thermal conductivity of surface are in W/(m*K), here: steel
std::vector< float > delayed_temps
The simulated updated interval in seconds.
sensor::Sensor * sensor
Current output value of heating element.
Base-class for all sensors.