Library for the control of the DHT22.
Dependents: Interfacage_Disco_DHT22
Diff: DHT22.h
- Revision:
- 0:a4f404326ee0
- Child:
- 2:8c7fa818f329
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DHT22.h Wed Apr 15 18:45:36 2020 +0000 @@ -0,0 +1,36 @@ +#ifndef MBED_DHT22_H +#define MBED_DHT22_H + +#include "mbed.h" + +class DHT22 +{ +private: + PinName pin_name; + int m_temperature, m_humidity; + + short shortFromBits(bool bits[]); + +public: + /* Instantiates a new DHT22 object + * - param PinName name of the pin where the DHT22 is connected + */ + DHT22(PinName); + + /* Populates the values stored in the fields m_temperature and m_humidity + * - PRE: The object DHT22 is instantiated and the sensor connected. + */ + int read(); + + /* Returns the value of the temperature captured by the sensor + * - PRE: The method read() has been performed at least once. + */ + int getTemperature(); + + /* Returns the value of the humidity captured by the sensor + * - PRE: The method read() has been performed at least once. + */ + int getHumidity(); +}; + +#endif \ No newline at end of file