Humidity & Temperature Sensmitter SHT11 (-75)
Hi,
Is there anybody who used this new sensor
http://www.sensirion.com
with stamp2 und have some code??
It would make it more easy to start.
Thanks Heinz Germany
[noparse][[/noparse]Non-text portions of this message have been removed]
Is there anybody who used this new sensor
http://www.sensirion.com
with stamp2 und have some code??
It would make it more easy to start.
Thanks Heinz Germany
[noparse][[/noparse]Non-text portions of this message have been removed]
Comments
The below worked for me.
Mit freundlichen Gr
it's nice to get Your quick respond
Thanks and "liebe Gr
For the record, here is another program that services the sht11 or
sht15. It's a little shorter than Steve's, because it ignores the
CRC calculation, and it uses shiftout and shiftin instead of bit
banging. So, different ways to do the same thing. By the way,
Steve, thanks for turning me on to this Sensirion chip. It is very
sensitive and a marvel of engineering.
-- regards
Tracy Allen
electronically monitored ecosystems
http://www.emesystems.com
mailto:tracy@e...
'{$STAMP BS2}
' (c) Tracy Allen, http://www.emesystems.com
' access the Sensirion model sht11 or sht15
' humidity and temperature chip
' temperature to xx.xx degrees Celsius, RH to xx.x %
' hookup sht11 or sht15 as follows for this program
' Stamp SHT1x
' Vss
pin 1
330 ohm isolation resistor, required
' p1
/\/\---o
pin 2 dta, data
' Vdd--/\/\
'
' 4.7k pullup resistor, required
' p0
pin 3 sck, clock
' Vdd
pin 4 +5 volts
'
' The following code does not implement the CRC checking
sck con 0
dta con 1 ' note, 5k-10k pullup, also 330ohm between the dta on
stamp to dta on sht
dtain var in1
shtTR con 3 ' read temperature
shtRH con 5 ' read humidity
shtSW con 6 ' status register write
shtSR con 7 ' status register read
shtS0 con 30 ' restore status register defaults (then delay 11
milliseconds)
cmd var byte
result var word ' raw result from sht, also used as counter
r0 var result.byte0
r1 var result.byte1
degC var word ' degrees Celsius * 100
RH var word ' %RH
RHtc var word ' for temperature compensation of RH
initialize:
outs=0
dirs=%1111111111111101
gosub shtrst ' reset communication with sht
mainloop:
getTemperature:
cmd=shtTR ' temperature command to sht
gosub shtget16
degC=result-4000
debug tab,dec result, tab,"degC=",dec degC/100,".",dec2 degC
getHumidity:
cmd=shtRH ' humidity command to sht
gosub shtget16
RH=(26542-(2**result))**result-40
' temperature comp (unverified--needs testing)
RHtc=52**result+6554
RHtc=(RHtc**(degC/100+248))-(RHtc**248)+RH
debug tab, dec result,tab,"%RH=",dec RH/10,".",dec1 RH
debug tab,"%RHtc=",dec RHtc/10,".",dec1 RHtc,cr
pause 1000
goto mainloop:
shtRst: ' initializes communication with sht
shiftout dta,sck,lsbfirst,[noparse][[/noparse]$ffff\16]
return
' get 16 bits of data, enter with command in "cmd"
shtget16:
gosub shtcmd ' send the command "cmd"
gosub shtwait ' wait for command to finish
shiftin dta,sck,msbpre,[noparse][[/noparse]r1] ' msbyte
low dta ' acknowledge
pulsout sck,10
input dta
shiftin dta,sck,msbpre,[noparse][[/noparse]r0] ' lsbyte
input dta ' terminate communication
pulsout sck,10
return
' send start sequence and command
shtcmd:
shtStart: ' send the start sequence
' dta: ~~~~~|_____|~~~~~~
' sck: ___|~~~|_|~~~~|____
' while dta is low, clock goes low and then high
input dta ' pullup high
high sck
low dta
low sck
high sck
input dta
low sck
shtcmd1: ' send the command
shiftout dta,sck,msbfirst,[noparse][[/noparse]cmd]
input dta ' allow acknowledge
pulsout sck,10
return
shtWait:
' wait for sht to pull data pin low
' wait 50-220ms for command to finish
' or time out
result=1024
shtwait2:
result=result-1
if dtain & result.bit9 then shtwait2
if result>512 then donewait
debug 7 ' bell signals timeout error
donewait:
return
Your response is quicker then I am able to start
Heinz Germany
Original Message
From: "Tracy Allen" <tracy@e...>
To: <basicstamps@yahoogroups.com>
Sent: Monday, August 19, 2002 10:01 PM
Subject: Re: [noparse][[/noparse]basicstamps] Humidity & Temperature Sensmitter SHT11 (-75)
> Heinz and Steve,
>
> For the record, here is another program that services the sht11 or
> sht15. It's a little shorter than Steve's, because it ignores the
> CRC calculation, and it uses shiftout and shiftin instead of bit
> banging. So, different ways to do the same thing. By the way,
> Steve, thanks for turning me on to this Sensirion chip. It is very
> sensitive and a marvel of engineering.
>
> -- regards
> Tracy Allen
> electronically monitored ecosystems
> http://www.emesystems.com
> mailto:tracy@e...
>
>
> '{$STAMP BS2}
> ' (c) Tracy Allen, http://www.emesystems.com
> ' access the Sensirion model sht11 or sht15
> ' humidity and temperature chip
> ' temperature to xx.xx degrees Celsius, RH to xx.x %
> ' hookup sht11 or sht15 as follows for this program
> ' Stamp SHT1x
> ' Vss
pin 1
> 330 ohm isolation resistor, required
> ' p1
/\/\---o
pin 2 dta, data
> ' Vdd--/\/\
'
> ' 4.7k pullup resistor, required
> ' p0
pin 3 sck, clock
> ' Vdd
pin 4 +5 volts
> '
> ' The following code does not implement the CRC checking
>
>
> sck con 0
> dta con 1 ' note, 5k-10k pullup, also 330ohm between the dta on
> stamp to dta on sht
> dtain var in1
> shtTR con 3 ' read temperature
> shtRH con 5 ' read humidity
> shtSW con 6 ' status register write
> shtSR con 7 ' status register read
> shtS0 con 30 ' restore status register defaults (then delay 11
> milliseconds)
> cmd var byte
> result var word ' raw result from sht, also used as counter
> r0 var result.byte0
> r1 var result.byte1
> degC var word ' degrees Celsius * 100
> RH var word ' %RH
> RHtc var word ' for temperature compensation of RH
>
> initialize:
> outs=0
> dirs=%1111111111111101
> gosub shtrst ' reset communication with sht
>
> mainloop:
> getTemperature:
> cmd=shtTR ' temperature command to sht
> gosub shtget16
> degC=result-4000
> debug tab,dec result, tab,"degC=",dec degC/100,".",dec2 degC
> getHumidity:
> cmd=shtRH ' humidity command to sht
> gosub shtget16
> RH=(26542-(2**result))**result-40
> ' temperature comp (unverified--needs testing)
> RHtc=52**result+6554
> RHtc=(RHtc**(degC/100+248))-(RHtc**248)+RH
> debug tab, dec result,tab,"%RH=",dec RH/10,".",dec1 RH
> debug tab,"%RHtc=",dec RHtc/10,".",dec1 RHtc,cr
> pause 1000
> goto mainloop:
>
> shtRst: ' initializes communication with sht
> shiftout dta,sck,lsbfirst,[noparse][[/noparse]$ffff\16]
> return
>
> ' get 16 bits of data, enter with command in "cmd"
> shtget16:
> gosub shtcmd ' send the command "cmd"
> gosub shtwait ' wait for command to finish
> shiftin dta,sck,msbpre,[noparse][[/noparse]r1] ' msbyte
> low dta ' acknowledge
> pulsout sck,10
> input dta
> shiftin dta,sck,msbpre,[noparse][[/noparse]r0] ' lsbyte
> input dta ' terminate communication
> pulsout sck,10
> return
>
> ' send start sequence and command
> shtcmd:
> shtStart: ' send the start sequence
> ' dta: ~~~~~|_____|~~~~~~
> ' sck: ___|~~~|_|~~~~|____
> ' while dta is low, clock goes low and then high
> input dta ' pullup high
> high sck
> low dta
> low sck
> high sck
> input dta
> low sck
> shtcmd1: ' send the command
> shiftout dta,sck,msbfirst,[noparse][[/noparse]cmd]
> input dta ' allow acknowledge
> pulsout sck,10
> return
>
> shtWait:
> ' wait for sht to pull data pin low
> ' wait 50-220ms for command to finish
> ' or time out
> result=1024
> shtwait2:
> result=result-1
> if dtain & result.bit9 then shtwait2
> if result>512 then donewait
> debug 7 ' bell signals timeout error
> donewait:
> return
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and Body
of the
message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>