sht11 sensor
challenger said:
Has any body written Picbasic code they can share for this sensor yet?
I dont know what communications protocall to use with this sensor.
I2C doesnt work.
r
here is some picbasic code for the sht11
only to read humidity (temp doesnt interest me for now...) the protocol is NOT I2C, but something like. you have to emulate yourself this pseudo i2c- see the picbasic code below
mysda var PORTC.6
myscl var PORTC.7
hread con %00000101 ' lecture humiditÈ sur sht11
humid var word
humidchk var byte
h1 var word
h2 var word
h3 var word
sht11_init: ' initialisation du sht11
Output mysda
Output myscl
High mysda
Low myscl
For i=1 to 10
High myscl
Pause 1
Low myscl
Pause 1
Next i
Call sht11_ts
return
sht11_ts: ' transmission start
High myscl
Pause 1
Low mysda
Pause 1
Low myscl
Pause 1
High myscl
Pause 1
High mysda
Pause 1
Low myscl
return
sht11_readhumid: ' lecture humiditÈ sur sht11
Call sht11_ts
Shiftout mysda,myscl,1,[hread\8] ' sortie commande lire humiditÈ
Input mysda ' attente ack
Low myscl
While mysda=1
Wend
Pulsout myscl,10 ' envoi ack
While mysda=0
Wend
While mysda=1 ' attente de la fin de la mesure
Wend
Low myscl
ShiftIn mysda,myscl,0,[humid.highbyte\8]
Low mysda
Pulsout myscl,10 ' envoi ack
ShiftIn mysda,myscl,0,[humid.lowbyte\8]
Low mysda
Pulsout myscl,10 ' envoi ack
ShiftIn mysda,myscl,0,[humidchk\8]
High mysda
Pulsout myscl,10 ' envoi ack
Input mysda
Input myscl ' retour en haute impÈdance
return