Constructs a new thermostat based on the supplied configuration.
A string to uniquely identify a thermostat.
The sensor's type. Must be either 11 (DHT11) or 22 (DHT22/AM2302).
A simple correction of the measured temperature by a fixed summand.
The default sensor type for a new thermostat.
The default temperature (in °C) to be maintained by a newly created thermostat, if no such value is configured on creation.
Sampling interval (in seconds) for all thermostats.
This is the interval ranging from
Delay (in seconds) between sensor power on and start of measurements.
Timeout after which all measurements will be stopped.
Determines whether the heating is currently on.
Relative humidity (in %) measured in the latest measurement.
Determines whether the thermostat is active.
Raw temperature (in °C) measured in the latest measurement.
The desired temperature (in °C) to be maintained by the thermostat.
The desired temperature (in °C) to be maintained by the thermostat.
Temperature (in °C) measured in the latest measurement; possibly with correction summand applied.
UNIX timestamp (in milliseconds) of the latest measurement.
GPIO pin controlling the power supply for all connected DHT sensors. If undefined, power is assumed to be always on.
GPIO pin controlling the power supply for all connected DHT sensors. If undefined, power is assumed to be always on.
Activates the thermostat.
Deactivates the thermostat.
Determines whether after deactivation of the thermostat the heating is off (default) or on (if set to true).
Generated using TypeDoc
An implementation of a thermostat on a Raspberry Pi using
Once activated, a thermostat regularly measures the current temperature (and relative humidity). It then activates or deactivates the actuator GPIO (which in turn should control the heating, e.g. by using a relay) by comparing the current temperature with the given setpoint:
Common measuring loop
Note that this implementation uses a common measuring loop for all configured thermostats, hence the samplingInterval as well as the measurement timeout is configured globally (i.e. as static variables).
Power rail activation/deactivation
The implementation optionally supports a (common) power rail activation/deactivation: If a sensorPowerPin is specified, power to the DHT sensors will be switched on prior to a measurement and switched off after measurements finished (or timed out). The sensorWarmUpTime determines, how long (in seconds) the software will wait until starting a measurement after power has been activated.