Shop OBEX P1 Docs P2 Docs Learn Events
Temperature and Humidity Sensor with a BS1 — Parallax Forums

Temperature and Humidity Sensor with a BS1

chazbrazilchazbrazil Posts: 27
edited 2007-01-19 14:04 in BASIC Stamp
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 SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-04-04 14:30
    You should post your code.· The BASIC Stamp 2 uses SHIFTIN/SHIFTOUT and the BASIC Stamp 1 does not have this command.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • chazbrazilchazbrazil Posts: 27
    edited 2006-04-04 18:49
    Chris Savage (Parallax) said...
    You should post your code.· The BASIC Stamp 2 uses SHIFTIN/SHIFTOUT and the BASIC Stamp 1 does not have this command.

    'tempReader.bs1
    '{$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
  • chazbrazilchazbrazil Posts: 27
    edited 2006-04-10 13:49
    If anyone has any code pertaining to a BS1 and the sensiron temp/humi sensor, please help me out!
  • gcarlsongcarlson Posts: 8
    edited 2007-01-18 03:53
    ChazBrazil,

    Did you ever get your BS1 code debugged for the Sensiron?

    I'd love to see it!

    Thanks - Gregg
  • KatyBriKatyBri Posts: 171
    edited 2007-01-19 04:47
    chazbrazil-

    Were did you purchase the SHT11 module and what was its price? Thanks
  • RDL2004RDL2004 Posts: 2,554
    edited 2007-01-19 13:52
    Parallax sells one version already on a breakout board, which should be easier to use, but for just the sensor chip alone, Newark InOne (·http://www.newark.com/jsp/home/homepage.jsp ) has them in stock. They are $22. Be sure when you search for them to spell Sensirion correctly. I left out the second i the first time and they didn't show up.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Rick
  • gcarlsongcarlson Posts: 8
    edited 2007-01-19 14:04
    I was able to sample one from Sensiron, but I also have a
    board-mounted sensor from Parallax I intend to use. I'm
    trying to use the BS1 is I can -

    Gregg
Sign In or Register to comment.