Dependents: Interfacage_Disco_DHT22
DHT22.h@2:8c7fa818f329, 2020-04-16 (annotated)
- Committer:
- dacamposol
- Date:
- Thu Apr 16 12:00:14 2020 +0000
- Revision:
- 2:8c7fa818f329
- Parent:
- 0:a4f404326ee0
Increase the detail on the temperature and humidity (float accuracy)
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 | 2:8c7fa818f329 | 10 | float 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 | 2:8c7fa818f329 | 28 | float 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 | 2:8c7fa818f329 | 33 | float getHumidity(); |
dacamposol | 0:a4f404326ee0 | 34 | }; |
dacamposol | 0:a4f404326ee0 | 35 | |
dacamposol | 0:a4f404326ee0 | 36 | #endif |