From 57c8257d71f4b06064e26e0e4b7d8dbcb9ee61d2 Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 29 Jan 2015 22:10:44 +0800 Subject: [PATCH] use delayMicroseconds replace usleep, and set LOW for 40 msbefor read --- Adafruit_DHT_Driver_Python/dhtreader.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Adafruit_DHT_Driver_Python/dhtreader.c b/Adafruit_DHT_Driver_Python/dhtreader.c index 9856c138..a03ed80e 100644 --- a/Adafruit_DHT_Driver_Python/dhtreader.c +++ b/Adafruit_DHT_Driver_Python/dhtreader.c @@ -53,9 +53,11 @@ int readDHT(int type, int pin, float *temp_p, float *hum_p) bcm2835_gpio_fsel(pin, BCM2835_GPIO_FSEL_OUTP); bcm2835_gpio_write(pin, HIGH); - usleep(500000); // 500 ms + delayMicroseconds(500000); // 500 ms bcm2835_gpio_write(pin, LOW); - usleep(20000); + delayMicroseconds(20000); + bcm2835_gpio_write(pin, HIGH); + delayMicroseconds(40); bcm2835_gpio_fsel(pin, BCM2835_GPIO_FSEL_INPT); @@ -63,7 +65,7 @@ int readDHT(int type, int pin, float *temp_p, float *hum_p) // wait for pin to drop? while (bcm2835_gpio_lev(pin) == 1) { - usleep(1); + delayMicroseconds(1); } // read data!