el_supremo
Well-known member
The library code supplied for the DHT22 (https://github.com/adafruit/DHT-sensor-library) works when run on a 328 based chip (Arduino Nano etc.) but it doesn't work on the Teensy 3.
When instantiating the DHT22 object, the example code sets the digital pin being used and the type of device. But there is a third argument which if unspecified defaults to 6. This number is used to differentiate between the length of a zero and a one when reading data from the DHT22 and it is much too short for a Teensy3. I've played around with this value and determined that, at all three cpu speeds (24, 48, 96MHz), any value in the range from 13 to 40 works.
So I'd recommend that you use something in the middle, such as 27, and change the example code from this:
to this:
Pete
When instantiating the DHT22 object, the example code sets the digital pin being used and the type of device. But there is a third argument which if unspecified defaults to 6. This number is used to differentiate between the length of a zero and a one when reading data from the DHT22 and it is much too short for a Teensy3. I've played around with this value and determined that, at all three cpu speeds (24, 48, 96MHz), any value in the range from 13 to 40 works.
So I'd recommend that you use something in the middle, such as 27, and change the example code from this:
Code:
DHT dht(DHTPIN, DHTTYPE);
Code:
DHT dht(DHTPIN, DHTTYPE, 27);
Pete