Skip to content

Commit

Permalink
Merge pull request #8 from soerup/master
Browse files Browse the repository at this point in the history
Support for non 16 MHz devices by adding extra parameter to constructor
  • Loading branch information
ladyada committed Jan 2, 2013
2 parents 71ee113 + ad73fab commit 26e2bc1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions DHT.cpp
Expand Up @@ -6,9 +6,10 @@ written by Adafruit Industries


#include "DHT.h" #include "DHT.h"


DHT::DHT(uint8_t pin, uint8_t type) { DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) {
_pin = pin; _pin = pin;
_type = type; _type = type;
_count = count;
firstreading = true; firstreading = true;
} }


Expand Down Expand Up @@ -129,7 +130,7 @@ boolean DHT::read(void) {
if ((i >= 4) && (i%2 == 0)) { if ((i >= 4) && (i%2 == 0)) {
// shove each bit into the storage bytes // shove each bit into the storage bytes
data[j/8] <<= 1; data[j/8] <<= 1;
if (counter > 6) if (counter > _count)
data[j/8] |= 1; data[j/8] |= 1;
j++; j++;
} }
Expand Down
4 changes: 2 additions & 2 deletions DHT.h
Expand Up @@ -23,13 +23,13 @@ written by Adafruit Industries
class DHT { class DHT {
private: private:
uint8_t data[6]; uint8_t data[6];
uint8_t _pin, _type; uint8_t _pin, _type, _count;
boolean read(void); boolean read(void);
unsigned long _lastreadtime; unsigned long _lastreadtime;
boolean firstreading; boolean firstreading;


public: public:
DHT(uint8_t pin, uint8_t type); DHT(uint8_t pin, uint8_t type, uint8_t count=6);
void begin(void); void begin(void);
float readTemperature(bool S=false); float readTemperature(bool S=false);
float convertCtoF(float); float convertCtoF(float);
Expand Down

0 comments on commit 26e2bc1

Please sign in to comment.