Library for the control of the DHT22.
Dependents: Interfacage_Disco_DHT22
DHT22.h@0:a4f404326ee0, 2020-04-15 (annotated)
- Committer:
- dacamposol
- Date:
- Wed Apr 15 18:45:36 2020 +0000
- Revision:
- 0:a4f404326ee0
- Child:
- 2:8c7fa818f329
Library for the control of the sensor DHT22.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dacamposol | 0:a4f404326ee0 | 1 | #ifndef MBED_DHT22_H |
dacamposol | 0:a4f404326ee0 | 2 | #define MBED_DHT22_H |
dacamposol | 0:a4f404326ee0 | 3 | |
dacamposol | 0:a4f404326ee0 | 4 | #include "mbed.h" |
dacamposol | 0:a4f404326ee0 | 5 | |
dacamposol | 0:a4f404326ee0 | 6 | class DHT22 |
dacamposol | 0:a4f404326ee0 | 7 | { |
dacamposol | 0:a4f404326ee0 | 8 | private: |
dacamposol | 0:a4f404326ee0 | 9 | PinName pin_name; |
dacamposol | 0:a4f404326ee0 | 10 | int m_temperature, m_humidity; |
dacamposol | 0:a4f404326ee0 | 11 | |
dacamposol | 0:a4f404326ee0 | 12 | short shortFromBits(bool bits[]); |
dacamposol | 0:a4f404326ee0 | 13 | |
dacamposol | 0:a4f404326ee0 | 14 | public: |
dacamposol | 0:a4f404326ee0 | 15 | /* Instantiates a new DHT22 object |
dacamposol | 0:a4f404326ee0 | 16 | * - param PinName name of the pin where the DHT22 is connected |
dacamposol | 0:a4f404326ee0 | 17 | */ |
dacamposol | 0:a4f404326ee0 | 18 | DHT22(PinName); |
dacamposol | 0:a4f404326ee0 | 19 | |
dacamposol | 0:a4f404326ee0 | 20 | /* Populates the values stored in the fields m_temperature and m_humidity |
dacamposol | 0:a4f404326ee0 | 21 | * - PRE: The object DHT22 is instantiated and the sensor connected. |
dacamposol | 0:a4f404326ee0 | 22 | */ |
dacamposol | 0:a4f404326ee0 | 23 | int read(); |
dacamposol | 0:a4f404326ee0 | 24 | |
dacamposol | 0:a4f404326ee0 | 25 | /* Returns the value of the temperature captured by the sensor |
dacamposol | 0:a4f404326ee0 | 26 | * - PRE: The method read() has been performed at least once. |
dacamposol | 0:a4f404326ee0 | 27 | */ |
dacamposol | 0:a4f404326ee0 | 28 | int getTemperature(); |
dacamposol | 0:a4f404326ee0 | 29 | |
dacamposol | 0:a4f404326ee0 | 30 | /* Returns the value of the humidity captured by the sensor |
dacamposol | 0:a4f404326ee0 | 31 | * - PRE: The method read() has been performed at least once. |
dacamposol | 0:a4f404326ee0 | 32 | */ |
dacamposol | 0:a4f404326ee0 | 33 | int getHumidity(); |
dacamposol | 0:a4f404326ee0 | 34 | }; |
dacamposol | 0:a4f404326ee0 | 35 | |
dacamposol | 0:a4f404326ee0 | 36 | #endif |