Skip to content

Commit 745de45

Browse files
committed
Port to GPIO/SAM
1 parent d9e9c89 commit 745de45

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
The DHT11 library is an Arduino-GPIO based device driver for the DHTXX
33
Humidity and Temperature Sensor (DHT11, DHT21 and DHT22).
44

5-
Version: 1.0
5+
Version: 1.1
66

77
## Classes
88

examples/DHT11/DHT11.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ void loop()
3232
Serial.print(F(": res = "));
3333
Serial.println(res);
3434
}
35-
delay(1000);
35+
delay(2000);
3636
}

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=Arduino-DHT
2-
version=1.0
2+
version=1.1
33
author=Mikael Patel
44
maintainer=Mikael Patel <mikael.patel@gmail.com>
55
sentence=Digital Humidity and Temperature (DHT) Sensor library for Arduino.
66
paragraph=The DHT library is an Arduino-GPIO based device driver for the DHTXX Humidity & Temperature Sensors (DHT11, DHT21 and DHT22).
77
category=Sensors
88
url=https://github.com/mikaelpatel/Arduino-DHT
9-
architectures=avr
9+
architectures=avr,sam

mainpage.dox

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The DHT library is an Arduino-GPIO based device driver for the DHTXX
44
Humidity and Temperature Sensors (DHT11, DHT21 and DHT22).
55

6-
Version: 1.0
6+
Version: 1.1
77
*/
88

99
/** @page License

src/DHT.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ class DHT {
4949
m_humidity(0),
5050
m_temperature(0)
5151
{
52-
m_data.input();
53-
m_data.low();
52+
m_data.open_collector();
5453
}
5554

5655
/**
@@ -82,10 +81,10 @@ class DHT {
8281
m_data.output();
8382
delay(START_SIGNAL);
8483
m_data.input();
85-
uint8_t retry = 16;
84+
int retry = 16;
8685
do {
8786
delayMicroseconds(PULLUP);
88-
} while (m_data != 0 && --retry);
87+
} while (m_data && --retry);
8988
if (retry == 0 || m_data.pulse() < THRESHOLD) return (-2);
9089

9190
// Read data from the device. Each bit is pulse width coded;
@@ -94,8 +93,10 @@ class DHT {
9493
uint8_t d[5];
9594
for (int i = 0; i < 5; i++) {
9695
uint8_t v = 0;
97-
for (int j = 0; j < 8; j++)
98-
v = (v << 1) | (m_data.pulse() > THRESHOLD);
96+
for (int j = 0; j < 8; j++) {
97+
uint8_t width = m_data.pulse();
98+
v = (v << 1) | (width > THRESHOLD);
99+
}
99100
d[i] = v;
100101
if (i < 4) chsum += v;
101102
}

0 commit comments

Comments
 (0)