The DHT is a great temp and humidity sensior at a low price. I too hoped and tried to interface it with a picaxe 18M2.
It is started with a low pulse against the bus pullup resistor of around 80 usecs which I did OK with Pulse out, then it responds after gap of around 80usec with a low going pulse of around 8o usecs then follows ths with 40 low going data pulses (25 usec long for a 1 and 70 usec for a 0 ) each of these having an interpulse gap of around 80usecs. I used 41 pulsein's stored directy using @bptrinc into ram. It was easy to read the 1's and 1's in the memory but with the 18m2 running at 32 MHz the intepulse gap was not long enough to process the pulse ins so many were missed leaving only about 20 out of 41 getting through. Lowering the clock speed made it even worse.
A. here is the code and results:
thumscan01: setfreq m32 ; bump speed up - get short timeout 80msec if no responce.
high B.1
pause 100
bptr = 150
pulsout B.1, 4000 ; output read start pulse approx 5 msec low
pulsin B.1,1,@bptrinc ; sensor ack pulse
pulsin B.1,1,@bptrinc ; tries to collect 40 bits of data pulses (1.25 usecs)
pulsin B.1,1,@bptrinc ; pulse time count approx 17 for 1 and and 70 for 0
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
pulsin B.1,1,@bptrinc
setfreq m4
bptr = 150
for wb2 = 1 to 41
sertxd (#@bptrinc,COM)
next wb2
sertxd (RET,LFEED)
pause 10000
goto results
;
; here are the results of the above at Picaxe clock 32Mhz - about the half rate needed
;63,17,17,17,17,57,17,17,57,17,17,17,17,57,17,57,17,57,57,17,57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;63,17,17,17,17,57,17,17,57,17,17,17,17,57,17,57,57,57,57,18,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;62,17,18,17,17,57,17,17,17,17,18,17,17,57,17,57,57,57,57,57,57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;63,17,17,17,17,57,18,17,18,18,17,17,17,57,18,57,57,57,57,57,57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
; here are the results of the above at Pcaxe clock 16 Mhz - even less get sampled (times half that above );
;8,8,28,29,8,8,8,9,9,28,8,28,9,8,9,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;9,9,28,28,9,8,8,9,9,28,9,28,8,8,8,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;8,8,28,29,8,28,8,8,8,29,8,29,9,8,9,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;8,8,28,28,8,29,9,8,8,28,9,28,8,8,8,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
B. I tried again using sertxd to trigger on the start of each pulse with a high baud rate where the recieved bits sat over the pulse to distinguish between 0the short (1) or long (0)
sertest:
setfreq M32
bptr = 150
high B.1
pause 100
pulsout B.1, 4000 ; output read start pulse approx 5 msec low
serin [10], B.1,N38400_32,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc
setfreq m4
bptr = 150
for wb2 = 1 to 41
sertxd (#@bptrinc,COM)
next wb2
sertxd (RET,LFEED)
pause 10000
goto results
;
;
;Here are the results at N38400 baud with top speed clock of 32 Mhz data = idling low waiting for start bit
;219,219,140,27,140,219,219,27,99,99,140,27,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;219,219,140,155,108,219,155,27,99,99,140,219,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;219,219,140,219,219,219,108,108,219,140,140,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;219,219,140,219,108,219,99,227,108,99,108,108,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;
;here are the results at N38400 baud with reduced clock speed at 16Mhz
;182,153,205,54,76,75,166,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;182,153,213,55,77,74,107,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;182,153,148,183,171,75,170,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;183,153,149,182,170,41,205,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;
;Here are the results at T38400baud = Idle high
;
;146,146,78,206,114,146,146,146,114,146,206,78,206,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;146,146,78,206,146,146,114,114,206,114,78,114,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;146,146,78,206,206,146,146,146,114,146,206,78,206,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;146,146,78,206,206,146,146,146,114,206,206,78,242,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;
;Here is T38400baud with the reduced clock speed down to 16MHz
;
;145,213,85,81,213,212,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;144,213,37,82,213,212,81,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;146,213,86,82,213,212,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
;145,209,37,82,85,169,165,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
C. I did start trying Hserin but since it only has a 2 byte buffer it requiered to many instructions to process each on arrival
D. Andrew Hornblow tried to do this on the faster 20X2 but still with no luck.
E. If someone was really interested then probably the 20x2 witch can read a whole string of bytes in the background could possibly do it.
F. I have gone back to Thomas Li to see if their engineers could re-program the chip in it say to use the spare pin to optionally set a much longer interpulse gap ( say 500 usecs) or use a smarter protocol that makes it more universally usable, Oherwise their product is technically fantastic but practically unusable for Pcaxe users and the like.
G. If anyone has some smart solutions to overcome this that would be appreciated please.
Humidity is about the last thing we need to resolve for the sensor stations for our school rainforest ecosystems services value research program at
http://www.whirinakirainforest.info/weather/explanation.htm