Is It Possible ? Picaxe X2 and DHT-11 ?

Goeytex

Senior Member
I was sent a bunch of these humidity sensors for evaluation. Model DHT-11 made "overseas".

When queried the sensor sends back a 40 bit packet containing humidity data,
temperature data and a CRC. It uses a proprietary 1 wire protocol where.

1. A data 0 is a 26us pulse
2. A data 1 is a 70us pulse
3. Data bits are separated by a 50us "low" idle period.

The DHT-11 datasheet is here. http://www.robotshop.com/PDF/dht11.pdf

The attached diagram gives an example of the output

Question: Is is possible for an X2 Picaxe running at 64mhz to read and store this 40 bit packet ?

I'm guessing not possible due to the interpreter overhead and the short 50us idle time between bits.
However, someone out there smarter than I am may know how to get around the problem as I see it.

So far the best I can do is accurately count the bits using count while running the Picaxe at high speed.

Any suggestions would be appreciated.

Goey
 

Attachments

zebulon

Member
Hi Goeytex,

I have some DHT11 and will try too to get them running.

About the size of the pulse, I recently (1 day ago :) ) have to deal with 50µs pulse (wiegand26 protocol), and it works fine with a 28X2 working at 16 Mhz.

So, I think ther would be no problem wheb running at 64 Mhz.

Guillaume
 

hippy

Technical Support
Staff member
The Wiegand protocol has three advantages over this protocol when it comes to PICAXE use; it is unsolicited send-only, data pulses are longer ( 50us against 27us ), and it has 2ms ( against 50us ) between data bits in which to accumulate and store those pulses.

At first glance the protocol here looks very much like Dallas 1-wire comms which no one has managed to bit-bang on a PICAXE and I'd say would not be possible. If it is compatible with 1-wire then the OWIN and OWOUT commands on the X2 might be usable but the two protocols would have to be studied and compared against each other.

It might be possible to find some means of triggering a response and grabbing the first 8 or 9 bits of data using HSERIN or HSPIIN.

There might be some mileage in streaming the bits input to scratchpad and then analysing what's received but you'd really need to sample every 25us ...

Do
@ptrInc = pinX.Y
Loop

Or more likely a long sequence of consecutive '@ptrInc = pinX.Y'.
 

Goeytex

Senior Member
Hippy nailed it.

At 64 mhz 40 consecutive reads with pulsin seems to get the first 25 bits or so and then poop out
But this is deceiving because in reality is skipping/ missing about 15 bits. The sensor is just too fast.

pulsin b.0.1.@prtinc
pulsin b.0.1.@ptrinc
pulsin b.0.1.@ptrinc
pulsin b.0.1.@ptrinc
40 times

To use these sensors reliably would require a micro that can execute an instruction at least twice as fast
as A Picaxe X2 running at 64 mhz. I just can't understand why the designers of the sensor chose
such short data bit times when the sensor cannot be read more than 1 time per second for
accurate readings. Seems stupid to me, but what do I know?

The good news is that the same outfit has an analog sensor for about $7.00 US that seems to work
fine.


Thank Guys
 
Last edited:

westaust55

Moderator

MFB

Senior Member
Maybe it would be possible to replace the 555 with a simple RC/diode pulse stretching circuit driving a PICAXE Schmitt input?
 

westaust55

Moderator
French forum member MGU has now added a schematic diagram and PICAXE 20X2 program listing at his website which should benefit those members seeking to use the DHT11 sensor.
 

Goeytex

Senior Member
It works fine.

I added a 74Hc221 instead of the 555 to increase the 50us off time to 65us. All bits
are readable using sequential pulsin to scratchpad with Picaxe frequency at 64Mhz.
The Data 1 is changed to about 55us and the Data 0 to about 12us.
 

Goeytex

Senior Member
Reading Data and displaying it in PE terminal.

Gonna contact the Frenchman to see if it is OK to post my modified circuit and
code as a Completed Project. Credit to MGU the workaround.
 

Goeytex

Senior Member
I have added a Completed Project showing how to use the DHT11 with a Picaxe 20X2.
It is in the Miscellaneous Section.

Goey
 
Last edited:
Top