Hi guys,

Following on from the thread when using a DHT11 sensor for humidity readings I've received my SHT11 / AM2302 sensor from E-bay.

My current routine for reading the DHT11 is

Code:
read_dht:

TRISA.1 = 0 '
high dht_data
low dht_data : pause 18' send 18ms low
high dht_data : pauseus 30 ' send 30us hi
TRISA.1 = 0
PulsIn PORTA.1, 1, dht
if dht < 9 then goto badresponse 
for x = 31 to 0 step-1
PulsIn PORTA.1, 1, dht[x] ' 1
next x
For x = 31 to 0 step-1 
if dht(x)>=9 and dht(x)<=21 then dht(x)=0 'if pulsewidth between 20 and 40uS then read as '0'
if dht(x)>=29 and dht(x)<=41 then dht(x)=1 'if pulsewidth between 60 and 80uS then read as '1'
next x
hum=dht[31]*128+dht[30]*64+dht[29]*32+dht[28]*16+dht[27]*8+dht[26]*4+dht[25]*2+dht[24]*1
return
The sensor uses the same 40 bit data stream as the DHT, but has twice the resolution. The data sheet (http://www.adafruit.com/datasheets/D...r%20AM2302.pdf) suggests that you convert the 16 bit decimal to decimal and then divide that by 10 to get the reading. As the sensor sends RH then Temp then checksum, what would be the simplest way of reading the first 16 bits rather then doing the multiply by 128, 64, 32, 16 etc