File tree Expand file tree Collapse file tree 5 files changed +12
-11
lines changed Expand file tree Collapse file tree 5 files changed +12
-11
lines changed Original file line number Diff line number Diff line change 2
2
The DHT11 library is an Arduino-GPIO based device driver for the DHTXX
3
3
Humidity and Temperature Sensor (DHT11, DHT21 and DHT22).
4
4
5
- Version: 1.0
5
+ Version: 1.1
6
6
7
7
## Classes
8
8
Original file line number Diff line number Diff line change @@ -32,5 +32,5 @@ void loop()
32
32
Serial.print (F (" : res = " ));
33
33
Serial.println (res);
34
34
}
35
- delay (1000 );
35
+ delay (2000 );
36
36
}
Original file line number Diff line number Diff line change 1
1
name =Arduino-DHT
2
- version =1.0
2
+ version =1.1
3
3
author =Mikael Patel
4
4
maintainer =Mikael Patel <mikael.patel@gmail.com>
5
5
sentence =Digital Humidity and Temperature (DHT) Sensor library for Arduino.
6
6
paragraph =The DHT library is an Arduino-GPIO based device driver for the DHTXX Humidity & Temperature Sensors (DHT11, DHT21 and DHT22).
7
7
category =Sensors
8
8
url =https://github.com/mikaelpatel/Arduino-DHT
9
- architectures =avr
9
+ architectures =avr,sam
Original file line number Diff line number Diff line change 3
3
The DHT library is an Arduino-GPIO based device driver for the DHTXX
4
4
Humidity and Temperature Sensors (DHT11, DHT21 and DHT22).
5
5
6
- Version: 1.0
6
+ Version: 1.1
7
7
*/
8
8
9
9
/** @page License
Original file line number Diff line number Diff line change @@ -49,8 +49,7 @@ class DHT {
49
49
m_humidity (0 ),
50
50
m_temperature (0 )
51
51
{
52
- m_data.input ();
53
- m_data.low ();
52
+ m_data.open_collector ();
54
53
}
55
54
56
55
/* *
@@ -82,10 +81,10 @@ class DHT {
82
81
m_data.output ();
83
82
delay (START_SIGNAL);
84
83
m_data.input ();
85
- uint8_t retry = 16 ;
84
+ int retry = 16 ;
86
85
do {
87
86
delayMicroseconds (PULLUP);
88
- } while (m_data != 0 && --retry);
87
+ } while (m_data && --retry);
89
88
if (retry == 0 || m_data.pulse () < THRESHOLD) return (-2 );
90
89
91
90
// Read data from the device. Each bit is pulse width coded;
@@ -94,8 +93,10 @@ class DHT {
94
93
uint8_t d[5 ];
95
94
for (int i = 0 ; i < 5 ; i++) {
96
95
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
+ }
99
100
d[i] = v;
100
101
if (i < 4 ) chsum += v;
101
102
}
You can’t perform that action at this time.
0 commit comments