Shop OBEX P1 Docs P2 Docs Learn Events
DHT11 or DHT22 Temperature and Humidity Sensors with the Propeller? — Parallax Forums

DHT11 or DHT22 Temperature and Humidity Sensors with the Propeller?

DroneDrone Posts: 433
edited 2012-08-03 10:02 in Propeller 1
I picked up a couple of DHT11 temperature and humidity sensors (can be had for around three to five USD each; a bit more with a breakout board. But the sensor's native pin-outs are 0.1" spaced as-is).

I would like to interface these sensors with the Propeller. Has anyone done this before?

The DHT11 and higher-performance but more expensive DHT22 (apparently from China) are very popular with the Arduino and PIC Community.

I've searched the Propeller Forum and ObEx and have not found anything that addresses these seemingly very popular parts.

The sensor uses a digital pulse-width method to distinguish between 1's and 0's in the 40 bit data output. The interface is via a single wire with a pull-up resistor (5V and 3.3V compatible). Note, the protocol is not the same as the Maxim/Dallas one-wire specification. The DHTxx modules are not individually addressable.

Here's the best of what I can find about how these parts work so-far:

* Data Sheet for DHT11 Temperature and Humidity sensor (likely translated from Chinese, but half-way decent):

http://www.robotshop.com/PDF/dht11.pdf

* A good explanation of the protocol in a project interfacing a DHT11 to a PIC16F628A:

http://embedded-lab.com/blog/?p=4333

Thanks for any feedback or suggestions...

Best Regards, David

Comments

  • DroneDrone Posts: 433
    edited 2012-08-02 03:10
    Kevin Cook wrote: »
    I'm attaching something used for the SHT-11, it should be a good starting point...

    SensirionPst120406a - Archive [Date 2012.04.06 Time 15.26].zip

    Thanks Kevin! The SHT-11 uses a clocked two-wire protocol, while the DHT-11/22 uses a one-wire protocol. But I'll read the SHT-11 data sheet and have a look at your code to see if I can pick up some pointers.

    Regards, David
  • Kevin CookKevin Cook Posts: 159
    edited 2012-08-03 07:02
    You'll need to adjust the serial communication but it should still be useful. Let me know how it goes!
  • varnonvarnon Posts: 184
    edited 2012-08-03 10:02
    I have an SHT11 myself. It works pretty well. In case you change your mind and switch to an SHT11, keep in mind that you have to adjust the data provided by the SHT to produce accurate measurements of temperature and humidity.The sensirion_full object (and Kevin's code) does this, but the standard Sensirion object does not. The data sheet describes these adjustments fairly well.
    If you are clever, you can transform the equations to remove the use of floats.

    I use this method, along with Sensirion_Full to read the sensor, then process the measurements. This adjustment is only accurate for 3.3v.
    Both temperature and relative humidity are returned multiplied by 1000. For example, a reading of 98.675 will be returned as 98675.
    When I save the data, I save it like this, or I write the integer string, a decimal point, then the decimal string to a file.
    I'm pretty sure these equations are accurate. I spent a good while tweaking them so that I could remove the floats and maintain precision.
    I actually haven't compared this to a method using floats in the propeller, but I did compare the equations in Excel.
    rawtemperature:=sensirion.readtemperature                               ' Reads temperature
    rawhumidity:=sensirion.readhumidity                                         ' Reads humidity
    
    
    temperature:=(-39350+(18*rawtemperature))                               ' Adjusts temperature reading. 39350 adjust for 3.3v.
    temperatureC:=((temperature-32000)*5)/9                                   ' Converts to celcius - needed for humidity adjustment
    
    
    RHlinear:=(-40000+((-28*(rawhumidity*rawhumidity))/1000)+((405*rawhumidity)/1))/10
    ' Converts raw humidity to linear relative humidity. 
    
    
    humidity:=((temperatureC-25000)*(1000+8*rawhumidity))/100000+RHlinear
    ' Adjust linear relative humidity with temperature.
    
Sign In or Register to comment.