Skip to content

Commit 4126dfc

Browse files
committed
+ 0.1.08
+ minor revision of comments + added formula for timeout to support DUE
1 parent d7e68d4 commit 4126dfc

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

libraries/DHTlib/dht.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
//
22
// FILE: dht.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.07
4+
// VERSION: 0.1.08
55
// PURPOSE: DHT Temperature & Humidity Sensor library for Arduino
66
// URL: http://arduino.cc/playground/Main/DHTLib
77
//
88
// HISTORY:
9+
// 0.1.08 added formula for timeout based upon clockspeed
910
// 0.1.07 added support for DHT21
1011
// 0.1.06 minimize footprint (2012-12-27)
1112
// 0.1.05 fixed negative temperature bug (thanks to Roseman)
@@ -22,7 +23,11 @@
2223

2324
#include "dht.h"
2425

25-
#define TIMEOUT (F_CPU/1600) // unsigned int in code, for higher CPU speeds this might exceed MAXINT.
26+
// #define TIMEOUT 10000
27+
// uint16_t for UNO, higher CPU speeds => exceed MAXINT.
28+
// works for DUE
29+
#define TIMEOUT (F_CPU/1600)
30+
2631

2732
/////////////////////////////////////////////////////
2833
//
@@ -45,7 +50,7 @@ int dht::read11(uint8_t pin)
4550
}
4651

4752
// CONVERT AND STORE
48-
humidity = bits[0]; // bit[1] == 0;
53+
humidity = bits[0]; // bits[1] == 0;
4954
temperature = bits[2]; // bits[3] == 0;
5055

5156
// TEST CHECKSUM
@@ -124,6 +129,7 @@ int dht::read(uint8_t pin)
124129
delayMicroseconds(40);
125130
pinMode(pin, INPUT);
126131

132+
// TODO rewrite with miros()?
127133
// GET ACKNOWLEDGE or TIMEOUT
128134
unsigned int loopCnt = TIMEOUT;
129135
while(digitalRead(pin) == LOW)

libraries/DHTlib/dht.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: dht.h
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.07
4+
// VERSION: 0.1.08
55
// PURPOSE: DHT Temperature & Humidity Sensor library for Arduino
66
// URL: http://arduino.cc/playground/Main/DHTLib
77
//
@@ -18,7 +18,7 @@
1818
#include <Arduino.h>
1919
#endif
2020

21-
#define DHT_LIB_VERSION "0.1.07"
21+
#define DHT_LIB_VERSION "0.1.08"
2222

2323
#define DHTLIB_OK0
2424
#define DHTLIB_ERROR_CHECKSUM-1

0 commit comments

Comments
 (0)