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

Support DHT22 sensor. #2

Closed
mbeacom opened this issue Apr 19, 2016 · 15 comments
Closed

Support DHT22 sensor. #2

mbeacom opened this issue Apr 19, 2016 · 15 comments

Comments

@mbeacom
Copy link

mbeacom commented Apr 19, 2016

@winlinvip Do you anticipate extending this to support the DHT22 model?

@winlinvip
Copy link
Owner

@mbeacom No plan, I have no time to play, 😄
BTW: Seems there are lots of libraries about the DHT22, why not use them?

@mbeacom
Copy link
Author

mbeacom commented Apr 21, 2016

Honestly, I was just excited to see your DHT11 package, since I've been following you on GH as of lately and I'm in the middle of working on a personal, side project using the DHT11 and 22s. Haha

Regardless, Thanks for everything @winlinvip !

@winlinvip
Copy link
Owner

So you are using Arduino to Sample the temperature and humidity by DHT11/22?

@mbeacom
Copy link
Author

mbeacom commented Apr 22, 2016

👍 Ongoing sampling with a raspberry pi and Arduino to monitor temperature/RH!

@winlinvip
Copy link
Owner

It works~ I have done that.
BTW: It's not possible for raspberry-pi to directly drive the DHT11(maybe use C is ok, but python is not), for the DHT11 use Nms interval as the protocol, while the Arduino is good to do such things.

You can use Serial for Raspberrypi to communicate with Arduino. https://github.com/winlinvip/SimpleSerial
Use Arduino to sample the DHT11 and send the data to RaspeberryPi by usb serial port.

@winlinvip
Copy link
Owner

winlinvip commented Jun 3, 2017

It seems the protocol between DHT22 and DHT11 is not very different, I can support DHT22, but I haven't get a DHT22, can you test it for me?

The major difference of DHT22 and DHT11 is the startup signal, DHT11 PULL LOW 18ms+, while DHT22 PULL LOW 500us+ or 1ms+.

@winlinvip
Copy link
Owner

winlinvip commented Jun 3, 2017

I have supported DHT22 in 32bf028, however I didn't test it yet, please use example to test it. Other examples should also work by changing the class SimpleDHT11 to SimpleDHT22.

After testing it, please close this issue. Thanks~

@winlinvip winlinvip changed the title DHT22 in the roadmap? Support DHT22 sensor. Jun 3, 2017
@mbeacom
Copy link
Author

mbeacom commented Jun 5, 2017

@winlinvip I will test the patch sometime this evening and let you know!

@winlinvip
Copy link
Owner

Great, what's the result?

@equake
Copy link

equake commented Jun 30, 2017

I'm trying to use this lib with an DHT22 without success. I get error 101 / 102 while trying to fetch temperature.

I can make some tests if you want!

@winlinvip
Copy link
Owner

@equake Please do some tests.

@winlinvip
Copy link
Owner

image

I will refine the protocol according to http://akizukidenshi.com/download/ds/aosong/AM2302.pdf

@winlinvip
Copy link
Owner

I have verify the v1.0.5, it works with DHT11:

Sample DHT11 with RAW bits...
Sample RAW Bits: 0001 1110 0000 0000 0001 1100 0000 0000 0011 1010 
Sample OK: 28 *C, 30 H
=================================
Sample DHT11 with RAW bits...
Sample RAW Bits: 0001 1110 0000 0000 0001 1100 0000 0000 0011 1010 
Sample OK: 28 *C, 30 H

With DHT22:

Sample DHT22 with RAW bits...
Sample RAW Bits: 0000 0010 1011 0001 0000 0001 0001 1111 1101 0011 
Sample OK: 28.70 *C, 68.90 RH%
=================================
Sample DHT22 with RAW bits...
Sample RAW Bits: 0000 0010 1010 1000 0000 0001 0010 0000 1100 1011 
Sample OK: 28.80 *C, 68.00 RH%

Remark: Notice that the DHT11 humidity is H, while DHT22 is RH%, for example:

Humidity:0011 0101=35H=53%RH

This was referenced Jul 8, 2017
@Rayzor53
Copy link

Rayzor53 commented Nov 16, 2017

Doesn't work below freezing. Returns an absurd answer -2856. This with DHT22.

@winlinvip
Copy link
Owner

@Rayzor53 Dup to #14

winlinvip pushed a commit that referenced this issue Aug 18, 2018
* Fixing issue #2 (timing problems Mega2560 r3 + DHT11).
Added method for more precise time measurement of the level states.
Simplified interface dropping 'pin' from most methods (keeping overloaded methods for interface compatibility).

* Adding constructors without parameters (for backward interface compatibility), #2

* Cleaning-up old and debug code, corrected comments, #2

* Default value defined already in .h, #2

* Correcting timing in DHT11:sample(), error threshold value lowered to work properly on ESP2866, #3

* Simplifying the code of the time measurement methods (#2, #3).

* Preventing potential inf. loop in levelTime() and levelTimePrecise(), #5
Adjusting pin level times for DHT11, needed after the fix above (-> need to adjust times after any change in the time measurement code...), #3

* Adjusting timing for mega2560_r3 after changes for #5 (also: cont. #2).

* Correcing comments / api doc. (#2, #3).
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

4 participants