Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with Teensy #9

Closed
Rotario opened this issue Jun 28, 2017 · 4 comments
Closed

Does not work with Teensy #9

Rotario opened this issue Jun 28, 2017 · 4 comments

Comments

@Rotario
Copy link

Rotario commented Jun 28, 2017

Hi,
I've got a DHT22, running the DHT22Default example.
I'm trying to get this library to work with the Teensy 3.6 and I'm getting a standard error:
err=101

This is using a cloned library of this git so latest version I assume. The board works with the standard ADAFRUIT library but I'd prefer to use this one as I can access just the simple bits which would speed up the data collection. I've read that the Teensy is much more accurate with its delayMicroseconds and the CPU I'm running clocks at 180MHz whereas an arduino would be around 18MHz, maybe I should just slow down the transfer?
Thanks,
Rowan

UPDATE ***
After reading https://forum.pjrc.com/threads/16806-T3-FYI-Adafruit-DHT22-AM2302
I changed the delayMicroseconds(10) to (15) in your .cpp and (30) to (35) and got this output

Sample OK: 0 *C, 2 %

Now unfortunately I think this data is incorrect as it's definitely not 0*C!
I'll have another go tomorrow

@winlinvip
Copy link
Owner

The error code 101 is defined:

// Error to wait for start high signal.
#define SimpleDHTErrStartHigh 101

That because the start high signal is not arrived according to https://cdn-shop.adafruit.com/datasheets/DHT22.pdf

image

If Teensy is more accurate, I think it should work. I will do some research.

@winlinvip
Copy link
Owner

I note that there's a comment:

// NOTE: For working with a faster chip, like an Arduino Due or Teensy, you
// might need to increase the threshold for cycle counts considered a 1 or 0.
// You can do this by passing a 3rd parameter for this threshold. It's a bit
// of fiddling to find the right value, but in general the faster the CPU the
// higher the value. The default for a 16mhz AVR is a value of 6. For an
// Arduino Due that runs at 84mhz a value of 30 works.
// Example to initialize DHT sensor for Arduino Due:

DHT dht(DHTPIN, DHTTYPE, 25);

I think it's because it use for loop to simulate the delayMicroseconds, as the Teensy is a faster chip so it need to change the threshold. But we use delayMicroseconds and now that Teensy is much more accurate, I think the delayMicroseconds is also accurate, why should change the delay(10) to delay(15) and (30) to (35)?

@winlinvip
Copy link
Owner

I found it, it's because the data format is changed. Read Table 5:AM2302 Communication format specifier of http://akizukidenshi.com/download/ds/aosong/AM2302.pdf

I will fix it in v1.0.5, please try it when released.

@winlinvip
Copy link
Owner

Read #2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants