Skip to content

Commit 26e2bc1

Browse files
committed
Merge pull request adafruit#8 from soerup/master
Support for non 16 MHz devices by adding extra parameter to constructor
2 parents 71ee113 + ad73fab commit 26e2bc1

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

DHT.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ written by Adafruit Industries
66

77
#include "DHT.h"
88

9-
DHT::DHT(uint8_t pin, uint8_t type) {
9+
DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) {
1010
_pin = pin;
1111
_type = type;
12+
_count = count;
1213
firstreading = true;
1314
}
1415

@@ -129,7 +130,7 @@ boolean DHT::read(void) {
129130
if ((i >= 4) && (i%2 == 0)) {
130131
// shove each bit into the storage bytes
131132
data[j/8] <<= 1;
132-
if (counter > 6)
133+
if (counter > _count)
133134
data[j/8] |= 1;
134135
j++;
135136
}

DHT.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ written by Adafruit Industries
2323
class DHT {
2424
private:
2525
uint8_t data[6];
26-
uint8_t _pin, _type;
26+
uint8_t _pin, _type, _count;
2727
boolean read(void);
2828
unsigned long _lastreadtime;
2929
boolean firstreading;
3030

3131
public:
32-
DHT(uint8_t pin, uint8_t type);
32+
DHT(uint8_t pin, uint8_t type, uint8_t count=6);
3333
void begin(void);
3434
float readTemperature(bool S=false);
3535
float convertCtoF(float);

0 commit comments

Comments
 (0)