File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 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)
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;
4954temperature = bits[2 ]; // bits[3] == 0;
5055
5156// TEST CHECKSUM
@@ -124,6 +129,7 @@ int dht::read(uint8_t pin)
124129delayMicroseconds (40 );
125130pinMode (pin, INPUT);
126131
132+ // TODO rewrite with miros()?
127133// GET ACKNOWLEDGE or TIMEOUT
128134unsigned int loopCnt = TIMEOUT;
129135while (digitalRead (pin) == LOW)
Original file line number Diff line number Diff line change 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//
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_OK 0
2424#define DHTLIB_ERROR_CHECKSUM -1
You can’t perform that action at this time.
0 commit comments