Temperature and Humidity Sensor with a BS1
chazbrazil
Posts: 27
Being the minimalistic person I am, I've been trying to integrate the Sensirion SHT11 Sensor Module, a temperature and humidity sensor, with a BS1 Project Board. The sample code that came with the sensor module is made for BS2. I tried converting the syntax to BS1, and I'm getting no values back from the module. If anyone has had any experience with this module, any help would be appreciated.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
'{$STAMP BS1}
'{$PBASIC 1.0}
'DEFINITIONS
SYMBOL data = PIN1
SYMBOL clk = PIN0
'CONSTANTS
SYMBOL temp = %00011
SYMBOL humi = %00101
SYMBOL statw = %00110
SYMBOL statr = %00111
SYMBOL reset = %11110
SYMBOL ack = 0
SYMBOL noack = 1
SYMBOL no = 0
SYMBOL yes = 1
SYMBOL degsym = 186
'VARIABLES
SYMBOL iobyte = B1
SYMBOL ackbit = BIT0
SYMBOL todelay = B3
SYMBOL timeout = BIT1
SYMBOL soT = W4
SYMBOL status = B4
SYMBOL count = B5
Initialize:
· GOSUB SHT_Connection_Reset
· PAUSE 250
Main:
· DEBUG CLS, "SHT11 Sensor Demo", CR, "
", CR
· GOSUB SHT_Measure_Temp
· DEBUG %soT
· PAUSE 1000
· DEBUG CLS
· GOSUB Main
END
SHT_Connection_Reset:
· DIRS = %00000011
· FOR count = 1 TO 9
··· data = 1
··· PULSOUT clk, 1
· NEXT count
SHT_Start:
· INPUT data
· LOW clk
· HIGH clk
· LOW data
· LOW clk
· HIGH clk
· INPUT data
· LOW clk
· RETURN
SHT_Measure_Temp:
· GOSUB SHT_Start
· iobyte = temp
· GOSUB SHT_Write_byte
· DEBUG "test ", %iobyte, CR
· GOSUB SHT_Wait
· ackbit = ack
· GOSUB SHT_Read_Byte
· DEBUG "test ", %iobyte, CR
· B9 = iobyte
· ackbit = noack
· GOSUB SHT_Read_Byte
· DEBUG "test ", %iobyte, CR
· B8 = iobyte
· RETURN
SHT_Write_Byte:
· LOW clk
· DIRS = %00000011
· data = BIT15
· PULSOUT clk, 1
· data = BIT14
· PULSOUT clk, 1
· data = BIT13
· PULSOUT clk, 1
· data = BIT12
· PULSOUT clk, 1
· data = BIT11
· PULSOUT clk, 1
· data = BIT10
· PULSOUT clk, 1
· data = BIT9
· PULSOUT clk, 1
· data = BIT8
· PULSOUT clk, 1
· LOW clk
· DIRS = %00000001
· ackbit = data
· PULSOUT clk, 1
· RETURN
SHT_Wait:
· INPUT data
· timeout = no
· FOR todelay = 1 TO 250
··· IF data = 0 THEN escape1
··· PAUSE 1
· NEXT
· escape1:
··· IF todelay = 250 THEN to1
··· RETURN
to1:
· timeout = yes
· RETURN
SHT_Read_Byte:
· LOW clk
· DIRS = %00000001
· BIT15 = data
· PULSOUT clk, 1
· BIT14 = data
· PULSOUT clk, 1
· BIT13 = data
· PULSOUT clk, 1
· BIT12 = data
· PULSOUT clk, 1
· BIT11 = data
· PULSOUT clk, 1
· BIT10 = data
· PULSOUT clk, 1
· BIT9 = data
· PULSOUT clk, 1
· BIT8 = data
· PULSOUT clk, 1
· LOW clk
· DIRS = %00000011
· data = ackbit
· PULSOUT clk, 1
· INPUT data
· RETURN
Did you ever get your BS1 code debugged for the Sensiron?
I'd love to see it!
Thanks - Gregg
Were did you purchase the SHT11 module and what was its price? Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Rick
board-mounted sensor from Parallax I intend to use. I'm
trying to use the BS1 is I can -
Gregg