DHT11 Humidity Sensor

Goeytex

Senior Member
The DHT11 Digital Humidity Sensor is available on Ebay and elsewhere and is an inexpensive alternative to sensors from Honeywell, Sensirion and Humirel. This project shows how to make this Sensor work with a Picaxe X2.

I had received several of these for testing but was unable to get them working due to a speed / timing issue related
to Picaxe processing overhead. But thanks to a clever workaround by Picaxe Forum Member MGU (Maguin Michel - Paris France ) the problem was solved. I took his idea and built a working circuit using a 74Hc221 instead of the 555 timer.

The results look very good and the Humidity and Temperature outputs are stable & accurate enough for many applications.

The DHT11 Datasheet can be found here:

http://www.robotshop.com/PDF/dht11.pdf
http://www.micro4you...ensor/DHT11.pdf


This is how I did it. ( See the Attached Files)

Edit: Added Schematic for using 555 timer instead of 74HC221. Fixed Graphic
 

Attachments

Last edited:

saunj

Senior Member
I am using the same sensor, sold as AM2301 from Satistronics in China in my Mobile Logger described in the Miscellaneous finished projects forum. I used a DS1302 clock (the RAM part in burst mode) as a buffer. It works perfectly with any Picaxe with reconfigurable ports. It only needs a simple circuit to change the sensor's PWM into separate NRZ and clock lines.
 

westaust55

Moderator
DHT11 Humidity Sensor to PICAXE

Well done Goeytex.

A relatively simple circuit and code size quite small for RH monitoring.
 

giokal

New Member
Greetings to all forum, I have read carefully the comments and analysis shown here and those shown in the French blog I think it's great the way they resolved, however I have noticed some details that I have very clear, these are: the schema using the 74hc221 pulse width according to R3 and C2 values shown, I get 110us (although according to Philips data sheet would be 77us) which are not consistent with 65us, C2 is not connected properly (leg should go to pin Rx / Cx and the other to Cx), mount the circuit but I do not get good results, RH% reading is very unstable and T ° C did not get ... I think it's a problem reading from the sensor (I'm using DHT03) not get the pulses correctly ... I can do? ... I think a 40X2 fit ... they recommend ....! thanks in advance
 

Goeytex

Senior Member
If you carefully read the Datasheet, the CX connection is correct. The CX pin ties directly to external ground as shown in the schematic. Then one leg of CX ties to external ground. See the note on Page 5 and the diagram in Figure 6.

To get the correct pulse width output you may have to experiment with the RX value while reading the pulse width with a scope. Trigger the 74Hc221 with a 20 to 50us pulse using pulsout and look for a 65 us pulse out from the 74Hc221. Adjust RX accordingly. Make sure you have decoupled both the Picaxe and the 74Hc221 with a .1uf capacitor.
 

nbw

Senior Member
I've read a pile on these DHT-11 sensors - I have one - and am looking to incorporate it into my orchid controller I've made (using a 40x2, 16MHz external resonator... I've got that bit!) I'm a little unsure of the hardware wiring so thought I'd just ask.
For the DHT-11, there's a + and -, which is obvious. A 100nF decouple cap I'll add too. The data line - goes straight to C.1 on the 40x2? As for C.0, do I simply add a 4k7 pull-up resistor on this port? I've seen the odd note on a diode of some description so if Goeytex or someone can clarify, I'd appreciate. Thanks for the posts; I feel like I'm about 80% there without having actually connected the sensor yet :)

Barney
 
Last edited:

nbw

Senior Member
Ah! Goeytex's PDF above helps (I missed it thinking it would be a datasheet). I'm not using a 555 or similar - purely a 40x2 and the DHT-11 sensor (it's on a board with +,-,out pins). I'm thinking the DHT-11's out pin gets tied high with a 4k7 resistor and I can see that C.1 1n4148 diode on there... but not sure still how c.0 comes into it?
 

PhilHornby

Senior Member
I'm not using a 555 or similar - purely a 40x2 and the DHT-11 sensor (it's on a board with +,-,out pins).
So how's it going to work? I thought the whole point of this thread, was to demonstrate how to use a 555 or similar to overcome the problem that the X2 Picaxe isn't fast enough to process the data directly :confused:
 

nbw

Senior Member
I understand you can use 1 (or 2) 555s, or the 74xxxx equivalent, or - if you use a 28X2 or 40X2 with a 16MHz resonator, you can get it to work with just 2 pins. (Which is what I am hoping for!)
 

westaust55

Moderator
I understand you can use 1 (or 2) 555s, or the 74xxxx equivalent, or - if you use a 28X2 or 40X2 with a 16MHz resonator, you can get it to work with just 2 pins. (Which is what I am hoping for!)
I used a similar scheme as per Goeytex with a 74HX221/74HC123 for my DCC Accessory Decoder project but that had to look at signals with half cycle durations of 58 us and 100 us.

If you are looking at the 28X2 or 40X2 with a 16 MHz resonator to achieve 64 MHz clock speed then the 20X2 can achieve this with the internal resonator.

I have not looked into reading the DH11 devices directly with a PICAXE chip. If you find that you need a little more speed again, then I have successfully (no Rev Ed warranty) used a 20 MHz resonator with a 28X2 for an 80 MHz clock speed.
 

nbw

Senior Member
Hmm, I'm sure (= I'm sure I read it on this forum :) )you can use a picaxe chip by itself provided it's a 28x2 or a 40x2 and it has an external resonator of 16MHz.
 

hippy

Technical Support
Staff member

nbw

Senior Member
So I can't use a 16MHz external resonator, because I'm unlucky enough to have a B.1 40x2. So, I'm going to go down the path of the 555 Goeytex has used. However, my 40x2 now will be crawling along at a whopping 8MHz. I had an idea - what if I slowed down the 555 circuit by a factor of 4, to give it more time to read the inbound data from the dht11? Thoughts, anyone? p.s. with I2C devices, an LCD screen, and this DHT11 sensor - the poor picaxe is going to be speeding up and slowing down all over the place....
 

hippy

Technical Support
Staff member
So I can't use a 16MHz external resonator, because I'm unlucky enough to have a B.1 40x2.
That is correct; the 40X2-5V has a maximum operating speed of 40MHz. The PLL is enabled so you can use an 8MHz resonator and run at 32MHz.
 

nbw

Senior Member
Hmmm, maybe it is worth me giving the 40x2 + 555 circuit + 32MHz + DHT-11 sensor a go. I've looked around, but if anyone can recommend a comparatively priced (= less than 5 pounds) sensor that can talk to a vintage 40x2 with little difficulty..............
 

hippy

Technical Support
Staff member
Rather than spend money on a different sensor, developing a 555 circuit, getting those to work, would it not make more sense to simply buy a 40X2 which should just work ?
 

lbenson

Senior Member
ESP8266 module works with DHT11 temp, humidity sensor. I assume it could talk to a picaxe, but I didn't check it. Fiddly, though, to get 4x2 connector working, so hippy's suggestion might be best.
 

nbw

Senior Member
I could buy a new 40x2 but the cost of shipping here is pretty expensive. Manty sensors can be shipped free from HK. Plus, I've got what I think is a pretty reasonable 40x2 (albeit B1) and I'd like to use it!! :)
 

MarvKern

Banned
Hi...i am new user here. As per my knowledge with a 74HX221/74HC123 for my DCC Accessory Decoder project but that had to look at signals with half cycle durations of 58 us and 100 us.If you are looking at the 28X2 or 40X2 with a 16 MHz resonator to achieve 64 MHz clock speed then the 20X2 can achieve this with the internal resonator.I have not looked into reading the DH11 devices directly with a PICAXE chip. If you find that you need a little more speed again, then I have successfully used a 20 MHz resonator with a 28X2 for an 80 MHz clock speed.
 

westaust55

Moderator
Hello Marv,

Welcome to the PICAXE forum.

Your comments are pretty much as per post 10.

Of topic, however from your comments, I presume that you have successfully constructed some PICAXE based DCC accessory decoders.

Quite some time ago hippy and others did tests and successfully had an X2 part operating at 100 MHz without apparent problems.
See here:http://www.picaxeforum.co.uk/showthread.php?17369-New-28X2-64-Mhz-at-5v-is-this-real


I elected to use the 80 MHz for the 28X2 on the DCC Accessory decoder as in intermediate level of over clocking. So potentially, albeit with no Rev Ed / PICAXE warranty if you let the smoke out, there is an opportunity for even greater speed if it helps.
 
Last edited:
Top