Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: DHT11.h
- Revision:
- 9:056d1e9b428c
- Parent:
- 5:da586c935e88
- Child:
- 10:f0d789f49df7
--- a/DHT11.h Wed Sep 10 18:00:31 2014 +0000
+++ b/DHT11.h Thu Sep 11 13:45:00 2014 +0000
@@ -28,7 +28,7 @@
*/
class DHT11
-{
+{
public:
/** Create a DHT11 interface
* @param pin 1-wire-like serial I/O port of DHT11
@@ -49,20 +49,20 @@
int readData(void);
/** Reading the humidity from the data
- * @return Humidity in % if readData() returns no error.
- * Otherwise, returns 0xffffffff.
+ * @return Humidity in %,
+ * regardless of the error from readData()
*/
int readHumidity(void);
/** Reading the temperature from the data
- * @return Temperature in Celcius if readData() returns no error.
- * Otherwise, returns 0xffffffff.
+ * @return Temperature in Celcius,
+ * regardless of the error from readData()
*/
int readTemperature(void);
enum ErrorDHT11 {
OK = 0,
- TOO_FAST_READ = 1,
+ READ_TOO_OFTEN = 1,
BUS_BUSY = 2,
NOT_PRESENT = 3,
NOT_READY = 4,
@@ -75,13 +75,14 @@
InterruptIn io_irq;
Timer t;
uint32_t t_pulse_us;
+ const static int t_tol_start;
+ const static int t_tol_pulse;
bool first_time;
uint64_t data;
uint32_t chksum;
uint32_t cnt;
uint32_t wdt;
bool eod;
- ErrorDHT11 err;
void init(void);
void pos_edge(void);
void neg_edge(void);