DHT22Gen3_RK
|
Class for encapsulating the results to a call to getSample() More...
#include <DHT22Gen3_RK.h>
Public Types | |
enum | SampleResult { SampleResult::SUCCESS = 0, SampleResult::ERROR, SampleResult::TOO_MANY_RETRIES, SampleResult::BUSY } |
Enumeration for result codes from the getSample() request. More... | |
Public Member Functions | |
DHTSample () | |
Constructor. More... | |
virtual | ~DHTSample () |
Destructor. | |
void | clear () |
Clears the results. More... | |
bool | isValidChecksum () const |
Returns true if the checksum in bytes is valid. More... | |
float | getTempC () const |
Gets the temperature in degrees Celsius. More... | |
float | getTempF () const |
Gets the temperature in degrees Fahrenheit. | |
float | getHumidity () const |
Gets the humidity in percent RH (0-100) as a floating point number. More... | |
float | getDewPointC () const |
Gets the dew point in degrees Celsius. More... | |
float | getDewPointF () const |
Gets the dew point in degrees Fahrenheit. More... | |
SampleResult | getSampleResult () const |
Gets the sample result value (0 = success, non-zero = error) More... | |
int | getTries () const |
Gets the number of retries. More... | |
DHTSample & | withSuccess () |
Sets the sample result to SUCCESS. | |
bool | isSuccess () const |
Returns true if getSample() was successful. More... | |
DHTSample & | withBusy () |
Sets the sample result to BUSY. | |
bool | isBusy () const |
Returns true if getSample() failed because another call was in progress. | |
DHTSample & | withError () |
Sets the sample result to ERROR. | |
bool | isError () const |
Returns true if getSample() failed because of an internal error. | |
DHTSample & | withTooManyRetries () |
Sets the sample result to TOO_MANY_RETRIES. | |
bool | isTooManyRetries () const |
Returns true if getSample() failed because a valid result was not obtained in the maximum number of retries. | |
DHTSample & | withSensorType (DHTSensorType *sensorType) |
Sets the data format of bytes. | |
uint8_t | operator[] (size_t index) const |
Get a byte from the bytes array. | |
Protected Attributes | |
SampleResult | sampleResult = SampleResult::ERROR |
Result code. 0 is success, error are non-zero. | |
DHTSensorType * | sensorType = 0 |
Sensor type for this sample. | |
uint8_t | bytes [5] = {0} |
Raw bytes of data from DHT22. | |
int | tries = 0 |
Number of retries. Normally 1 for the initial try, will be greater for retries. | |
Friends | |
class | DHT22Gen3 |
Class for encapsulating the results to a call to getSample()
|
strong |
Enumeration for result codes from the getSample() request.
Success is 0. All other codes are errors
DHTSample::DHTSample | ( | ) |
Constructor.
You normally don't need to construct one of these; it's filled in for you by getSample()
void DHTSample::clear | ( | ) |
Clears the results.
Sets the result to ERROR, zeros the bytes, sets tries to 0
float DHTSample::getDewPointC | ( | ) | const |
Gets the dew point in degrees Celsius.
The value is undefined is isSuccess() is not true. You you check that before relying on this value.
float DHTSample::getDewPointF | ( | ) | const |
Gets the dew point in degrees Fahrenheit.
The value is undefined is isSuccess() is not true. You you check that before relying on this value.
float DHTSample::getHumidity | ( | ) | const |
Gets the humidity in percent RH (0-100) as a floating point number.
The value is undefined is isSuccess() is not true. You you check that before relying on this value.
|
inline |
Gets the sample result value (0 = success, non-zero = error)
You may want to use isSuccess(), isBusy(), isError(), or isTooManyRetries() instead.
float DHTSample::getTempC | ( | ) | const |
Gets the temperature in degrees Celsius.
The value is undefined is isSuccess() is not true. You you check that before relying on this value.
|
inline |
Gets the number of retries.
|
inline |
Returns true if getSample() was successful.
The call completed successfully and the checksum passed. The temperature and humidity values should be valid.
bool DHTSample::isValidChecksum | ( | ) | const |
Returns true if the checksum in bytes is valid.
You normally should check isSuccess() since that will only be set if the checksum is valid and normally don't need to call this directly.