Welcome, Guest
Username: Password: Secret Key Remember me

TOPIC: DHT11 anyone?

Re: DHT11 anyone? 8 years 3 months ago #8641

  • jmessina
  • jmessina's Avatar
  • Offline
  • Senior Boarder
  • Posts: 44
  • Thanks received: 189
Well, it's not a "normal serial" signal.

For each of the forty data bits (5 eight-bit bytes) you have to measure the time that the line is high to determine if it's a 0 or a 1 bit. After you sense the line low for 50us, a high period of 26-28us is a 0 bit while a high period of 70us is a 1 bit.

Re: DHT11 anyone? 8 years 3 months ago #8644

  • RogerTango
  • RogerTango's Avatar
  • Offline
  • Fresh Boarder
  • Thanks received: 2
That may be tooooo much for my weak mind to try and institute in programming.

This with a DS18B20 may be the better setup for me:
http://www.sparkfun.com/products/10239
(HH10D)

also Google]www.google.com/search?q=HH10D&ie ... =firefox-a[/url]

Andrew

Re: DHT11 anyone? 8 years 3 months ago #8645

  • RogerTango
  • RogerTango's Avatar
  • Offline
  • Fresh Boarder
  • Thanks received: 2
Good intel on counting the pulses to discover RH%!

http://www.picaxeforum.co.uk/showthread.php?t=11749

Re: DHT11 anyone? 8 years 2 months ago #8652

  • red_kooga
  • red_kooga's Avatar
  • Offline
  • Fresh Boarder
  • Thanks received: 1
You can try this, i haven't used it in a while i had all my pic code on a usb stick that got corrupt, i think this one worked.

'Declare Xtal 16 'declare xtal to give exact delays
Dim ip As Byte 'hi pulse from sensor
Dim temp As Byte
Dim hum As Byte
Dim chksm As Byte
Dim temp1 As Byte
Dim hum1 As Byte
Dim temp2 As Word
Dim hum2 As Word
Dim test As Byte
Dim i As Byte
DelayMS 1000 'give sensor time to settle
loop:
chksm=0
TRISB.0 = 0 'portb o/p
PORTB.0=1 'make high
DelayMS 50 'wait for a while
PORTB.0=0:DelayMS 18 'send 18ms low
PORTB.0=1:DelayUS 30 'send 30us hi
ip = PulsIn PORTB.0,1 'wait for hi
If ip < 130 Then GoTo loop1 ' if < 80us loop
ip = 0
For i = 7 To 0 Step -1
ip = PulsIn PORTB.0,1 'recieve pulses from sensor
If ip >70 Then
SetBit hum,i
Else
ClearBit hum,i
EndIf
Next i
For i = 7 To 0 Step -1
ip = PulsIn PORTB.0,1 'recieve pulses from sensor
If ip >70 Then
SetBit hum1,i
Else
ClearBit hum1,i
EndIf
Next i
For i = 7 To 0 Step -1
ip = PulsIn PORTB.0,High 'recieve pulses from sensor
If ip >70 Then
SetBit temp,i
Else
ClearBit temp,i
EndIf
Next i
For i = 7 To 0 Step -1
ip = PulsIn PORTB.0,High 'recieve pulses from sensor
If ip >70 Then
SetBit temp1,i
Else
ClearBit temp1,i
EndIf
Next i
For i = 0 To 7' Step -1
ip = PulsIn PORTB.0,High
If ip >70 Then
SetBit chksm,i
Else
SetBit chksm,i
EndIf
Next i
'chksm = chksm -1 'fudge to correct mis-read?

HRSOut "humidity ",Dec hum,".",Dec hum1,"%"
HRSOut " temperature ",Dec temp,".",Dec temp1,"C",13

test = (temp1 + hum1 + hum2 + temp2)
If chksm <> test Then HRSOut "error",13

DelayMS 2000 'give sensor time to settle
GoTo loop
loop1:
HRSOut "sensor not ready",13
GoTo loop

Re: DHT11 anyone? 8 years 2 months ago #8653

  • Jon Chandler
  • Jon Chandler's Avatar
  • Offline
  • Moderator
  • Posts: 365
  • Thanks received: 352
Good intel on counting the pulses to discover RH%!

http://www.picaxeforum.co.uk/showthread.php?t=11749

You do realize this doesn't apply to the humidity sensor you've mentioned, right?

Re: DHT11 anyone? 8 years 2 months ago #8657

  • RogerTango
  • RogerTango's Avatar
  • Offline
  • Fresh Boarder
  • Thanks received: 2
Thanks Kooga! Ill order one of those, there really inexpensive on ebay with free ship, and give your code a try! It would be awesome if it all works out right!

Ill post back with any results...


Andrew
Time to create page: 0.261 seconds