9#include "../Data/RollingAverage.h"
64 DHT11(
const bool isUsingPi5OrAbove,
const unsigned int dhtPinNumber,
const unsigned int maxTimings = 85U);
89 virtual void TurnOn()
override;
101 virtual void TurnOff()
override;
129 virtual std::string
ToString()
const override;
Abstract base class for every component (sensor, actuator, etc.) the library manages.
Definition: BaseComponent.h:60
The DHT11 temperature and humidity sensor.
Definition: DHT11.h:22
std::chrono::steady_clock::time_point myLastReadTime
When the last successful read happened (the sensor needs ~2s between reads).
Definition: DHT11.h:46
float GetAverageHumidity() const
Gets the rolling-average humidity.
Definition: DHT11.cpp:369
bool myIsUsingPi5OrAbove
Whether to use the Pi 5+ kernel sysfs read path (true) or the older bit-banged GPIO read (false).
Definition: DHT11.h:25
float GetCurrentTemperatureInFahrenheit() const
Gets the most recent temperature reading converted to Fahrenheit (not averaged).
Definition: DHT11.cpp:461
virtual std::string ToString() const override
Serializes the sensor's current and averaged temperature (Celsius and Fahrenheit) and humidity to a s...
Definition: DHT11.cpp:96
float GetAverageTemperatureInCelsius() const
Gets the rolling-average temperature in Celsius.
Definition: DHT11.cpp:403
unsigned int myDHTPinNumber
The GPIO pin the sensor is wired to (older bit-banged path).
Definition: DHT11.h:28
DHT11(const bool isUsingPi5OrAbove, const unsigned int dhtPinNumber, const unsigned int maxTimings=85U)
Builds a DHT11 on the given pin.
Definition: DHT11.cpp:24
float GetCurrentHumidity() const
Gets the most recent humidity reading (not averaged).
Definition: DHT11.cpp:386
virtual void TurnOff() override
Turns the sensor off.
Definition: DHT11.cpp:79
float GetAverageTemperatureInFahrenheit() const
Gets the rolling-average temperature converted to Fahrenheit.
Definition: DHT11.cpp:443
float GetCurrentTemperatureInCelsius() const
Gets the most recent temperature reading in Celsius (not averaged).
Definition: DHT11.cpp:426
virtual void TurnOn() override
Turns the sensor on.
Definition: DHT11.cpp:64
float myCurrentTemperatureInCelsius
The most recent temperature reading (Celsius), or NaN if none yet.
Definition: DHT11.h:37
RollingAverage myAverageHumidity
Rolling average of humidity readings.
Definition: DHT11.h:40
virtual void ProcessRawValues() override
Reads the sensor (rate-limited to ~once every 2 seconds) and, on a good read, feeds the temperature a...
Definition: DHT11.cpp:123
unsigned int GetMaxTimings() const
Gets the maximum number of signal transitions sampled per read (older bit-banged path).
Definition: DHT11.cpp:352
RollingAverage myAverageTemperatureInCelsius
Rolling average of temperature readings (Celsius).
Definition: DHT11.h:43
unsigned int GetDHTPinNumber() const
Gets the GPIO pin the sensor is wired to.
Definition: DHT11.cpp:335
virtual ~DHT11()
Destroys the sensor, turning it off first.
Definition: DHT11.cpp:49
unsigned int myMaxTimings
Maximum signal transitions to sample per read (older bit-banged path).
Definition: DHT11.h:31
float myCurrentHumidity
The most recent humidity reading (percent), or NaN if none yet.
Definition: DHT11.h:34
Maintains a rolling (moving) average over a fixed-length window of recent readings using a circular b...
Definition: RollingAverage.h:14
RumPi is the library's top-level facade.
Definition: AlertManager.h:6