A library for the use of DHT11, a temperature and humidity sensor
Fork of DHT11 by
Diff: DHT11.cpp
- Revision:
- 6:257e2ab66d0f
- Parent:
- 4:48798b126d93
- Child:
- 7:50f5c8efd967
--- a/DHT11.cpp Wed Sep 10 17:35:27 2014 +0000 +++ b/DHT11.cpp Wed Sep 10 17:43:14 2014 +0000 @@ -11,21 +11,18 @@ io_irq.rise(this, &DHT11::pos_edge); io_irq.fall(this, &DHT11::neg_edge); io_irq.disable_irq(); - init(); + init(); + first_time = true; } // Destructor DHT11::~DHT11(void) {} -// Reading the data bits from DHT11 +// Reading the data bits from the DHT11 int DHT11::readData() { // Initialize - eod = false; - err = OK; - data = 0; - cnt = 0; - wdt = 0; + init(); // Checking the measurement frequency if (t.read_ms() < 2000 & first_time == false) { @@ -128,7 +125,6 @@ void DHT11::init(void) { t_pulse_us = 0; - first_time = true; data = 0; chksum = 0; cnt = 0;