Shop OBEX P1 Docs P2 Docs Learn Events
Sensor SHT1X usage — Parallax Forums

Sensor SHT1X usage

ArchiverArchiver Posts: 46,084
edited 2003-07-06 19:06 in General Discussion
I am interested in using the Basic Stamp II to use with the Sensiron
SHT1X Temp/Humidity Sensor. The program by Jon Williams, dated 28
Sep 2002 looks perfect, EXCEPT, I would like to be able to use the
sensor/Basic Stamp II with an LCD Module rather than DEBUG to a PC.
I am just starting with programming and really need some help to
make these Temp/Humidity readings go to the LCD AND also to DEBUG so
I can be sure everything is correct. Has anyone ever done this? If
so, would you be willing to help me out!?
Kindest regards, Chuck Irwin

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-07-05 19:23
    You might want to experiment with LCD seperately first, maybe a keypad/LCD
    combo. Once you'd figured that out, adding in the SHT11 will be a breeze.

    The parallax website has examples of LCD keypad interfacing, check the
    downloads->documentation section.

    Original Message
    From: "no2k_4" <chuckirwin43@n...>
    To: <basicstamps@yahoogroups.com>
    Sent: Saturday, July 05, 2003 8:47 AM
    Subject: [noparse][[/noparse]basicstamps] Sensor SHT1X usage


    > I am interested in using the Basic Stamp II to use with the Sensiron
    > SHT1X Temp/Humidity Sensor. The program by Jon Williams, dated 28
    > Sep 2002 looks perfect, EXCEPT, I would like to be able to use the
    > sensor/Basic Stamp II with an LCD Module rather than DEBUG to a PC.
    > I am just starting with programming and really need some help to
    > make these Temp/Humidity readings go to the LCD AND also to DEBUG so
    > I can be sure everything is correct. Has anyone ever done this? If
    > so, would you be willing to help me out!?
    > Kindest regards, Chuck Irwin
    >
    >
    >
    > 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/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-05 19:46
    Chuck,

    Very simple. If you haven't used LCDs before, I would recommend a serial
    LCD, they are much easier to use. I have some code kicking around on another
    machine that uses the SHT and a serial LCD. I'll look around, send me your
    e-mail addy and I'll send you the code.

    Jonathan

    www.madlabs.info

    Original Message
    From: "no2k_4" <chuckirwin43@n...>
    To: <basicstamps@yahoogroups.com>
    Sent: Saturday, July 05, 2003 8:47 AM
    Subject: [noparse][[/noparse]basicstamps] Sensor SHT1X usage


    > I am interested in using the Basic Stamp II to use with the Sensiron
    > SHT1X Temp/Humidity Sensor. The program by Jon Williams, dated 28
    > Sep 2002 looks perfect, EXCEPT, I would like to be able to use the
    > sensor/Basic Stamp II with an LCD Module rather than DEBUG to a PC.
    > I am just starting with programming and really need some help to
    > make these Temp/Humidity readings go to the LCD AND also to DEBUG so
    > I can be sure everything is correct. Has anyone ever done this? If
    > so, would you be willing to help me out!?
    > Kindest regards, Chuck Irwin
    >
    >
    >
    > 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/
    >
    >
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-05 22:04
    Thanks very much! I have checked and did download some code which is an
    LCD_Demo and that works.....my problem is how to combine that code with the
    SHT1x code. I will check it again to insure I have not missed anything.
    Thanks very much for your help and attention!
    Kindest regards,
    Chuck Irwin
    p.s. This code is kind of like learning Greek for me!

    Original Message
    From: "pm" <pmeloy@s...>
    To: <basicstamps@yahoogroups.com>
    Sent: Saturday, July 05, 2003 14:23 PM
    Subject: Re: [noparse][[/noparse]basicstamps] Sensor SHT1X usage


    > You might want to experiment with LCD seperately first, maybe a keypad/LCD
    > combo. Once you'd figured that out, adding in the SHT11 will be a breeze.
    >
    > The parallax website has examples of LCD keypad interfacing, check the
    > downloads->documentation section.
    >
    >
    Original Message
    > From: "no2k_4" <chuckirwin43@n...>
    > To: <basicstamps@yahoogroups.com>
    > Sent: Saturday, July 05, 2003 8:47 AM
    > Subject: [noparse][[/noparse]basicstamps] Sensor SHT1X usage
    >
    >
    > > I am interested in using the Basic Stamp II to use with the Sensiron
    > > SHT1X Temp/Humidity Sensor. The program by Jon Williams, dated 28
    > > Sep 2002 looks perfect, EXCEPT, I would like to be able to use the
    > > sensor/Basic Stamp II with an LCD Module rather than DEBUG to a PC.
    > > I am just starting with programming and really need some help to
    > > make these Temp/Humidity readings go to the LCD AND also to DEBUG so
    > > I can be sure everything is correct. Has anyone ever done this? If
    > > so, would you be willing to help me out!?
    > > Kindest regards, Chuck Irwin
    > >
    > >
    > >
    > > 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/
    > >
    > >
    >
    >
    > 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/
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-05 22:23
    Hi Jonathan:
    I have not used LCD's before, but did pick one up from BGMicro which uses
    the Hitachi HD44780 Controller. I found some code listed under "Experiment
    #11: A Basic LCD Demonstration" on Parallax web site. I got that to work
    just fine! My problem is trying to combine that code with the SHT1X code.
    I am just learning this Basic Stamp II and I think I am way over my head.
    I have attached the two programs I have downloaded from the Parallax site,
    but I can't seem to figure out how to take the info from the SHT1X program
    and feed it to the LCD Display program.

    Thanks very much for your help!

    Kindest regards,
    Chuck Irwin

    Original Message
    From: "Jonathan Peakall" <jpeakall@m...>
    To: <basicstamps@yahoogroups.com>
    Sent: Saturday, July 05, 2003 14:46 PM
    Subject: Re: [noparse][[/noparse]basicstamps] Sensor SHT1X usage


    > Chuck,
    >
    > Very simple. If you haven't used LCDs before, I would recommend a serial
    > LCD, they are much easier to use. I have some code kicking around on
    another
    > machine that uses the SHT and a serial LCD. I'll look around, send me your
    > e-mail addy and I'll send you the code.
    >
    > Jonathan
    >
    > www.madlabs.info
    >
    >
    Original Message
    > From: "no2k_4" <chuckirwin43@n...>
    > To: <basicstamps@yahoogroups.com>
    > Sent: Saturday, July 05, 2003 8:47 AM
    > Subject: [noparse][[/noparse]basicstamps] Sensor SHT1X usage
    >
    >
    > > I am interested in using the Basic Stamp II to use with the Sensiron
    > > SHT1X Temp/Humidity Sensor. The program by Jon Williams, dated 28
    > > Sep 2002 looks perfect, EXCEPT, I would like to be able to use the
    > > sensor/Basic Stamp II with an LCD Module rather than DEBUG to a PC.
    > > I am just starting with programming and really need some help to
    > > make these Temp/Humidity readings go to the LCD AND also to DEBUG so
    > > I can be sure everything is correct. Has anyone ever done this? If
    > > so, would you be willing to help me out!?
    > > Kindest regards, Chuck Irwin
    > >
    > >
    > >
    > > 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/
    > >
    > >
    > >
    > >
    > >
    >
    >
    > 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/
    >
    >
    >


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-05 23:14
    Keep in mind that if you're going to use a parallel LCD and are NOT
    using a BS2p/BS2pe, you will have to send just one character at a time.
    Get familiar with the DIG operator -- this will come in handy. Also
    remember that you have to send ASCII codes to the display. Adding 48
    ("0") to a digit value will convert that digit to its ASCII code.

    -- Jon Williams
    -- Parallax



    Original Message
    From: chuckirwin43 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=cswaMbLOBTL48MOHp96GI700q1DOXnpYSSIFIEsKNz7MRDJamhYYfGbYzGSwgW28E_VWSdbU61_aBdEGLDPtxg]chuckirwin43@n...[/url
    Sent: Saturday, July 05, 2003 4:04 PM
    To: basicstamps@yahoogroups.com
    Subject: Re: [noparse][[/noparse]basicstamps] Sensor SHT1X usage


    Thanks very much! I have checked and did download some code which is an
    LCD_Demo and that works.....my problem is how to combine that code with
    the SHT1x code. I will check it again to insure I have not missed
    anything. Thanks very much for your help and attention! Kindest regards,
    Chuck Irwin p.s. This code is kind of like learning Greek for me!

    Original Message
    From: "pm" <pmeloy@s...>
    To: <basicstamps@yahoogroups.com>
    Sent: Saturday, July 05, 2003 14:23 PM
    Subject: Re: [noparse][[/noparse]basicstamps] Sensor SHT1X usage


    > You might want to experiment with LCD seperately first, maybe a
    > keypad/LCD combo. Once you'd figured that out, adding in the SHT11
    > will be a breeze.
    >
    > The parallax website has examples of LCD keypad interfacing, check the
    > downloads->documentation section.
    >
    >
    Original Message
    > From: "no2k_4" <chuckirwin43@n...>
    > To: <basicstamps@yahoogroups.com>
    > Sent: Saturday, July 05, 2003 8:47 AM
    > Subject: [noparse][[/noparse]basicstamps] Sensor SHT1X usage
    >
    >
    > > I am interested in using the Basic Stamp II to use with the Sensiron

    > > SHT1X Temp/Humidity Sensor. The program by Jon Williams, dated 28
    > > Sep 2002 looks perfect, EXCEPT, I would like to be able to use the
    > > sensor/Basic Stamp II with an LCD Module rather than DEBUG to a PC.
    > > I am just starting with programming and really need some help to
    > > make these Temp/Humidity readings go to the LCD AND also to DEBUG so

    > > I can be sure everything is correct. Has anyone ever done this? If

    > > so, would you be willing to help me out!? Kindest regards, Chuck
    > > Irwin
    > >
    > >
    > >
    > > 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/
    > >
    > >
    >
    >
    > 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/
    >
    >
    >


    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/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-06 03:45
    I have done it using a serial LCD module. Essentially, what you need to
    do is change each and every DEBUG command to a SEROUT command.
    (actually, COPY all the DEBUGs, PASTE them just below the DEBUGs, and
    then change DEBUG to SEROUT on every other DEBUG. That way everything
    will appear on the terminal and the LCD. When everything is cool, trash
    the DEBUG statements. I had to screw around with SEROUT parameters a
    bit, but that simply involved wasting an hour. Each LCD has it's own
    command codes (I think), so you would have to use the same LCD that I
    used to share my code. That said, I am using a MAtrix Orbital VFD2041
    (way-cool blue display), and would be glad to share my code if you
    thought it would help.

    On Saturday, July 5, 2003, at 11:47 AM, no2k_4 wrote:

    > I am interested in using the Basic Stamp II to use with the Sensiron
    > SHT1X Temp/Humidity Sensor. The program by Jon Williams, dated 28
    > Sep 2002 looks perfect, EXCEPT, I would like to be able to use the
    > sensor/Basic Stamp II with an LCD Module rather than DEBUG to a PC.
    > I am just starting with programming and really need some help to
    > make these Temp/Humidity readings go to the LCD AND also to DEBUG so
    > I can be sure everything is correct. Has anyone ever done this? If
    > so, would you be willing to help me out!?
    > Kindest regards, Chuck Irwin
    >
    >
    >
    > 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/
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-06 03:50
    FIRST, plug into the SHT1 code any LCD initialization code. Then,
    wherever you see a DEBUG command line in the SHT code, plug in a SEROUT
    command that starts with the LCD example code SEROUT but substitutes
    the variables from the DEBUT. Sorta' like mix and match. Believe me,
    screw around with it, you'll find that you don't need to know Greek
    (Geek?) to program Greek (Geek?).

    On Saturday, July 5, 2003, at 05:04 PM, chuckirwin43 wrote:

    > Thanks very much! I have checked and did download some code which is
    > an
    > LCD_Demo and that works.....my problem is how to combine that code
    > with the
    > SHT1x code. I will check it again to insure I have not missed
    > anything.
    > Thanks very much for your help and attention!
    > Kindest regards,
    > Chuck Irwin
    > p.s. This code is kind of like learning Greek for me!
    >
    >
    Original Message
    > From: "pm" <pmeloy@s...>
    > To: <basicstamps@yahoogroups.com>
    > Sent: Saturday, July 05, 2003 14:23 PM
    > Subject: Re: [noparse][[/noparse]basicstamps] Sensor SHT1X usage
    >
    >
    >> You might want to experiment with LCD seperately first, maybe a
    >> keypad/LCD
    >> combo. Once you'd figured that out, adding in the SHT11 will be a
    >> breeze.
    >>
    >> The parallax website has examples of LCD keypad interfacing, check the
    >> downloads->documentation section.
    >>
    >>
    Original Message
    >> From: "no2k_4" <chuckirwin43@n...>
    >> To: <basicstamps@yahoogroups.com>
    >> Sent: Saturday, July 05, 2003 8:47 AM
    >> Subject: [noparse][[/noparse]basicstamps] Sensor SHT1X usage
    >>
    >>
    >>> I am interested in using the Basic Stamp II to use with the Sensiron
    >>> SHT1X Temp/Humidity Sensor. The program by Jon Williams, dated 28
    >>> Sep 2002 looks perfect, EXCEPT, I would like to be able to use the
    >>> sensor/Basic Stamp II with an LCD Module rather than DEBUG to a PC.
    >>> I am just starting with programming and really need some help to
    >>> make these Temp/Humidity readings go to the LCD AND also to DEBUG so
    >>> I can be sure everything is correct. Has anyone ever done this? If
    >>> so, would you be willing to help me out!?
    >>> Kindest regards, Chuck Irwin
    >>>
    >>>
    >>>
    >>> 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/
    >>>
    >>>
    >>
    >>
    >> 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/
    >>
    >>
    >>
    >
    >
    > 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/
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-06 04:17
    mark,
    can you post it?
    Original Message
    From: "Mark Marpet" <marpetm@s...>
    To: <basicstamps@yahoogroups.com>
    Sent: Saturday, July 05, 2003 10:45 PM
    Subject: Re: [noparse][[/noparse]basicstamps] Sensor SHT1X usage


    > I have done it using a serial LCD module. Essentially, what you need to
    > do is change each and every DEBUG command to a SEROUT command.
    > (actually, COPY all the DEBUGs, PASTE them just below the DEBUGs, and
    > then change DEBUG to SEROUT on every other DEBUG. That way everything
    > will appear on the terminal and the LCD. When everything is cool, trash
    > the DEBUG statements. I had to screw around with SEROUT parameters a
    > bit, but that simply involved wasting an hour. Each LCD has it's own
    > command codes (I think), so you would have to use the same LCD that I
    > used to share my code. That said, I am using a MAtrix Orbital VFD2041
    > (way-cool blue display), and would be glad to share my code if you
    > thought it would help.
    >
    > On Saturday, July 5, 2003, at 11:47 AM, no2k_4 wrote:
    >
    > > I am interested in using the Basic Stamp II to use with the Sensiron
    > > SHT1X Temp/Humidity Sensor. The program by Jon Williams, dated 28
    > > Sep 2002 looks perfect, EXCEPT, I would like to be able to use the
    > > sensor/Basic Stamp II with an LCD Module rather than DEBUG to a PC.
    > > I am just starting with programming and really need some help to
    > > make these Temp/Humidity readings go to the LCD AND also to DEBUG so
    > > I can be sure everything is correct. Has anyone ever done this? If
    > > so, would you be willing to help me out!?
    > > Kindest regards, Chuck Irwin
    > >
    > >
    > >
    > > 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/
    > >
    > >
    > >
    >
    >
    > 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/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-06 18:27
    Mike-

    Here's the code. Be warned, that I ripped all of this out of a much
    larger program so to focus on the T&RH stuff; it does indeed run, but
    there are probably lots of loose ends (unused constants, etc.) Also,
    the LCD code is specific to the Matrix Orbital LCD (VFD2041) that I
    used, or at least, specific to Matriz Orbital LCDs. All that said, this
    will probably give you an idea of what to do. Most of this code was
    ripped off the Parallax web site (thank you very much Parallax). Get a
    copy of the LCD display manual and see how you can rip my code off,
    change it as little as possible, and make it do what you want it to do.
    Good luck, Mark


    '{$STAMP BS2p}

    '

    ' I/O Definitions, Temp/RH
    '


    ShtData CON 1 ' bi-directional data
    Clock CON 0
    '

    ' Constants, Temp/RH
    '


    ShtTemp CON %00011 ' read temperature
    ShtHumi CON %00101 ' read humidity
    ShtStatW CON %00110 ' status register
    write
    ShtStatR CON %00111 ' status register read
    ShtReset CON %11110 ' soft reset (wait 11
    ms after)

    Ack CON 0
    NoAck CON 1

    No CON 0
    Yes CON 1

    MoveTo CON 2 ' for DEBUG control
    ClrRt CON 11 ' clear DEBUG line to
    right

    DegSym CON 186 ' degrees symbol for
    DEBUG


    '

    ' Variables, Temp/RH
    '


    ioByte VAR Byte ' data from/to SHT1x
    ackBit VAR Bit ' ack/nak from/to
    SHT1x
    toDelay VAR Byte ' timeout delay timer
    timeOut VAR Bit ' timeout status

    soT VAR Word ' temp counts from
    SHT1x
    tC VAR Word ' temp - celcius
    tF VAR Word ' temp - fahrenheit

    soRH VAR Word ' humidity counts
    from SHT1x
    rhLin VAR Word ' humidity; linearized
    rhTrue VAR Word ' humidity; temp
    compensated

    status VAR Byte ' SHT1x status byte

    'Total 122 bits

    '

    ' Initialization, Temp/RH
    '


    InitializeTempRH:
    GOSUB SHT_Connection_Reset ' reset device
    connection

    PAUSE 250 ' let DEBUG window open

    '

    ' Initialization, LCD
    '

    SEROUT 15, 240, [noparse][[/noparse]254, 84] 'turns off cursor (254=>send command to LCD)
    SEROUT 15, 240, [noparse][[/noparse]254, 88] 'clears screen
    SEROUT 15, 240, [noparse][[/noparse]254, 67] 'auto line wrap on
    SEROUT 15, 240, [noparse][[/noparse]254, 71, 1,2] ' Places the data on Row 2 of the LCD
    ' for a 1-line LCD, change
    [noparse][[/noparse]254,71,1,2] to
    ' [noparse][[/noparse]254,71,1,1]
    SEROUT 15, 240, [noparse][[/noparse]"Tmp: F RH: %"]


    '

    ' Program Code
    '


    Sensor_Demo:
    GOSUB SHT_Measure_Temp
    DEBUG MoveTo, 0, 3
    DEBUG "tF...... "
    DEBUG DEC (tF / 10), ".", DEC1 tF, DegSym, ClrRt, CR

    GOSUB SHT_Measure_Humidity
    DEBUG "rhLin... "
    DEBUG DEC (rhLin / 10), ".", DEC1 rhLin, "%", ClrRt, CR, CR

    Heater_On:
    DEBUG "SHT1x heater on", CR
    status = %00000100 ' heater bit = On
    GOSUB SHT_Write_Status
    DEBUG "Waiting 2 seconds", CR
    PAUSE 2000

    Heater_Off:
    DEBUG "SHT1x heater off", CR, CR
    status = %00000000 ' heater bit = Off
    GOSUB SHT_Write_Status

    GOSUB SHT_Measure_Temp
    DEBUG "tF...... "
    DEBUG DEC (tF / 10), ".", DEC1 tF, DegSym, ClrRt, CR

    GOSUB SHT_Measure_Humidity
    DEBUG "rhLin... "
    DEBUG DEC (rhLin / 10), ".", DEC1 rhLin, "%", ClrRt, CR, CR

    PAUSE 5000

    Main1:
    DEBUG CLS
    DEBUG "SHT1x Demo", CR
    DEBUG "
    ", CR
    LoopDeLoop:
    Main2:
    GOSUB SHT_Measure_Temp
    SEROUT 15, 240, [noparse][[/noparse]254, 71, 6,2, DEC tF / 10, ".", DEC1 tF]
    ' **** See note above about displaying data on line 2 of the LCD

    GOSUB SHT_Measure_Humidity
    SEROUT 15, 240, [noparse][[/noparse]254, 71, 16,2, DEC rhTrue / 10, ".", DEC1 rhTrue]
    ' **** See note above about displaying data on line 2 of the LCD


    PAUSE 1000 ' minimum delay between T/RH readings
    GOTO LoopDeLoop

    '

    ' Subroutines, Temp/RH
    '


    ' connection reset: 9 clock cyles with ShtData high, then start sequence
    '
    SHT_Connection_Reset:
    SHIFTOUT ShtData, Clock, LSBFIRST, [noparse][[/noparse]$FFF\9]

    ' generates SHT1x "start" sequence
    ' _____ _____
    ' ShtData |_______|
    ' ___ ___
    ' Clock ___| |___| |___
    '
    SHT_Start:
    INPUT ShtData ' let pull-up take line
    high
    LOW Clock
    HIGH Clock
    LOW ShtData
    LOW Clock
    HIGH Clock
    INPUT ShtData
    LOW Clock
    RETURN


    ' measure temperature
    ' -- celcius = soT * 0.01 - 40
    ' -- fahrenheit = soT * 0.018 - 40
    '
    SHT_Measure_Temp:
    GOSUB SHT_Start ' alert device
    ioByte = ShtTemp ' temperature command
    GOSUB SHT_Write_Byte ' send command
    GOSUB SHT_Wait ' wait until
    measurement done
    ackBit = Ack ' another read follows
    GOSUB SHT_Read_Byte ' get MSB
    soT.HIGHBYTE = ioByte
    ackBit = NoAck ' last read
    GOSUB SHT_Read_Byte ' get LSB
    soT.LOWBYTE = ioByte

    ' Note: Conversion factors are multiplied by 10 to return the
    ' temperature values in tenths of degrees

    tC = soT / 10 - 400 ' convert to tenths C
    tF = soT ** 11796 - 400 ' convert to tenths F
    RETURN


    ' measure humidity
    '
    SHT_Measure_Humidity:
    GOSUB SHT_Start ' alert device
    ioByte = ShtHumi ' humidity command
    GOSUB SHT_Write_Byte ' send command
    GOSUB SHT_Wait ' wait until
    measurement done
    ackBit = Ack ' another read follows
    GOSUB SHT_Read_Byte ' get MSB
    soRH.HIGHBYTE = ioByte
    ackBit = NoAck ' last read
    GOSUB SHT_Read_Byte ' get LSB
    soRH.LOWBYTE = ioByte

    ' linearize humidity
    ' rhLin = (soRH * 0.0405) - (soRH^2 * 0.0000028) - 4
    '
    ' for the BASIC Stamp:
    ' rhLin = (soRH * 0.0405) - (soRH * 0.004 * soRH * 0.0007) - 4
    '
    ' Conversion factors are multiplied by 10 and then rounded to
    ' return tenths
    '
    rhLin = (soRH ** 26542)
    rhLin = rhLin - ((soRH ** 3468) * (soRH ** 3468) + 50 / 100)
    rhLin = rhLin - 40

    ' temperature compensated humidity
    ' rhTrue = (tC - 25) * (soRH * 0.00008 + 0.01) + rhLin
    '
    ' Conversion factors are multiplied by 100 to improve accuracy and
    then
    ' rounded off.
    '
    rhTrue = ((tC / 10 - 25) * (soRH ** 524 + 1) + (rhLin * 10)) + 5 / 10
    RETURN


    ' sends "status"
    '
    SHT_Write_Status:
    GOSUB SHT_Start ' alert device
    ioByte = ShtStatW ' write to status reg
    command
    GOSUB SHT_Write_Byte ' send command
    ioByte = status
    GOSUB SHT_Write_Byte
    RETURN


    ' returns "status"
    '
    SHT_Read_Status:
    GOSUB SHT_Start ' alert device
    ioByte = ShtStatW ' write to status reg
    command
    GOSUB SHT_Read_Byte ' send command
    ackBit = NoAck ' only one byte to read
    GOSUB SHT_Read_Byte
    RETURN


    ' sends "ioByte"
    ' returns "ackBit"
    '
    SHT_Write_Byte:
    SHIFTOUT ShtData, Clock, MSBFIRST, [noparse][[/noparse]ioByte] ' send byte
    SHIFTIN ShtData, Clock, LSBPRE, [noparse][[/noparse]ackBit\1] ' get ack bit
    RETURN


    ' returns "ioByte"
    ' sends "ackBit"
    '
    SHT_Read_Byte:
    SHIFTIN ShtData, Clock, MSBPRE, [noparse][[/noparse]ioByte] ' get byte
    SHIFTOUT ShtData, Clock, LSBFIRST, [noparse][[/noparse]ackBit\1] ' send ack bit
    INPUT ShtData ' release data line
    RETURN


    ' wait for device to finish measurement (pulls data line low)
    ' -- timeout after ~1/4 second
    '
    SHT_Wait:
    INPUT ShtData ' data line is input
    FOR toDelay = 1 TO 250 ' give ~1/4 second to
    finish
    timeOut = INS.LOWBIT(ShtData) ' scan data line
    IF (timeOut = No) THEN SHT_Wait_Done ' if low, we're done
    PAUSE 1
    NEXT

    SHT_Wait_Done:
    RETURN


    ' reset SHT1x with soft reset
    '
    SHT_Soft_Reset:
    GOSUB SHT_Connection_Reset ' reset the connection
    ioByte = ShtReset ' reset command
    ackBit = NoAck ' only one byte to send
    GOSUB SHT_Write_Byte ' send it
    PAUSE 11 ' wait at least 11 ms


    On Saturday, July 5, 2003, at 11:17 PM, Mike Mocenter wrote:

    > mark,
    > can you post it?
    >
    Original Message
    > From: "Mark Marpet" <marpetm@s...>
    > To: <basicstamps@yahoogroups.com>
    > Sent: Saturday, July 05, 2003 10:45 PM
    > Subject: Re: [noparse][[/noparse]basicstamps] Sensor SHT1X usage
    >
    >
    >> I have done it using a serial LCD module. Essentially, what you need
    >> to
    >> do is change each and every DEBUG command to a SEROUT command.
    >> (actually, COPY all the DEBUGs, PASTE them just below the DEBUGs, and
    >> then change DEBUG to SEROUT on every other DEBUG. That way everything
    >> will appear on the terminal and the LCD. When everything is cool,
    >> trash
    >> the DEBUG statements. I had to screw around with SEROUT parameters a
    >> bit, but that simply involved wasting an hour. Each LCD has it's own
    >> command codes (I think), so you would have to use the same LCD that I
    >> used to share my code. That said, I am using a MAtrix Orbital VFD2041
    >> (way-cool blue display), and would be glad to share my code if you
    >> thought it would help.
    >>
    >> On Saturday, July 5, 2003, at 11:47 AM, no2k_4 wrote:
    >>
    >>> I am interested in using the Basic Stamp II to use with the Sensiron
    >>> SHT1X Temp/Humidity Sensor. The program by Jon Williams, dated 28
    >>> Sep 2002 looks perfect, EXCEPT, I would like to be able to use the
    >>> sensor/Basic Stamp II with an LCD Module rather than DEBUG to a PC.
    >>> I am just starting with programming and really need some help to
    >>> make these Temp/Humidity readings go to the LCD AND also to DEBUG so
    >>> I can be sure everything is correct. Has anyone ever done this? If
    >>> so, would you be willing to help me out!?
    >>> Kindest regards, Chuck Irwin
    >>>
    >>>
    >>>
    >>> 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/
    >>>
    >>>
    >>>
    >>
    >>
    >> 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/
    >>
    >>
    >
    >
    > 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/
    >
    >
    >


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-06 19:06
    thanks, mark
    Original Message
    From: "Mark Marpet" <marpetm@s...>
    To: <basicstamps@yahoogroups.com>
    Sent: Sunday, July 06, 2003 1:27 PM
    Subject: Re: [noparse][[/noparse]basicstamps] Sensor SHT1X usage


    > Mike-
    >
    > Here's the code. Be warned, that I ripped all of this out of a much
    > larger program so to focus on the T&RH stuff; it does indeed run, but
    > there are probably lots of loose ends (unused constants, etc.) Also,
    > the LCD code is specific to the Matrix Orbital LCD (VFD2041) that I
    > used, or at least, specific to Matriz Orbital LCDs. All that said, this
    > will probably give you an idea of what to do. Most of this code was
    > ripped off the Parallax web site (thank you very much Parallax). Get a
    > copy of the LCD display manual and see how you can rip my code off,
    > change it as little as possible, and make it do what you want it to do.
    > Good luck, Mark
    >
    >
    >
    > '{$STAMP BS2p}
    >
    > '
    >
    >
    > ' I/O Definitions, Temp/RH
    > '
    >
    >
    >
    > ShtData CON 1 ' bi-directional data
    > Clock CON 0
    > '
    >
    >
    > ' Constants, Temp/RH
    > '
    >
    >
    >
    > ShtTemp CON %00011 ' read temperature
    > ShtHumi CON %00101 ' read humidity
    > ShtStatW CON %00110 ' status register
    > write
    > ShtStatR CON %00111 ' status register read
    > ShtReset CON %11110 ' soft reset (wait 11
    > ms after)
    >
    > Ack CON 0
    > NoAck CON 1
    >
    > No CON 0
    > Yes CON 1
    >
    > MoveTo CON 2 ' for DEBUG control
    > ClrRt CON 11 ' clear DEBUG line to
    > right
    >
    > DegSym CON 186 ' degrees symbol for
    > DEBUG
    >
    >
    > '
    >
    >
    > ' Variables, Temp/RH
    > '
    >
    >
    >
    > ioByte VAR Byte ' data from/to SHT1x
    > ackBit VAR Bit ' ack/nak from/to
    > SHT1x
    > toDelay VAR Byte ' timeout delay timer
    > timeOut VAR Bit ' timeout status
    >
    > soT VAR Word ' temp counts from
    > SHT1x
    > tC VAR Word ' temp - celcius
    > tF VAR Word ' temp - fahrenheit
    >
    > soRH VAR Word ' humidity counts
    > from SHT1x
    > rhLin VAR Word ' humidity; linearized
    > rhTrue VAR Word ' humidity; temp
    > compensated
    >
    > status VAR Byte ' SHT1x status byte
    >
    > 'Total 122 bits
    >
    > '
    >
    >
    > ' Initialization, Temp/RH
    > '
    >
    >
    >
    > InitializeTempRH:
    > GOSUB SHT_Connection_Reset ' reset device
    > connection
    >
    > PAUSE 250 ' let DEBUG window open
    >
    > '
    >
    >
    > ' Initialization, LCD
    > '
    >
    >
    > SEROUT 15, 240, [noparse][[/noparse]254, 84] 'turns off cursor (254=>send command to LCD)
    > SEROUT 15, 240, [noparse][[/noparse]254, 88] 'clears screen
    > SEROUT 15, 240, [noparse][[/noparse]254, 67] 'auto line wrap on
    > SEROUT 15, 240, [noparse][[/noparse]254, 71, 1,2] ' Places the data on Row 2 of the LCD
    > ' for a 1-line LCD, change
    > [noparse][[/noparse]254,71,1,2] to
    > ' [noparse][[/noparse]254,71,1,1]
    > SEROUT 15, 240, [noparse][[/noparse]"Tmp: F RH: %"]
    >
    >
    > '
    >
    >
    > ' Program Code
    > '
    >
    >
    >
    > Sensor_Demo:
    > GOSUB SHT_Measure_Temp
    > DEBUG MoveTo, 0, 3
    > DEBUG "tF...... "
    > DEBUG DEC (tF / 10), ".", DEC1 tF, DegSym, ClrRt, CR
    >
    > GOSUB SHT_Measure_Humidity
    > DEBUG "rhLin... "
    > DEBUG DEC (rhLin / 10), ".", DEC1 rhLin, "%", ClrRt, CR, CR
    >
    > Heater_On:
    > DEBUG "SHT1x heater on", CR
    > status = %00000100 ' heater bit = On
    > GOSUB SHT_Write_Status
    > DEBUG "Waiting 2 seconds", CR
    > PAUSE 2000
    >
    > Heater_Off:
    > DEBUG "SHT1x heater off", CR, CR
    > status = %00000000 ' heater bit = Off
    > GOSUB SHT_Write_Status
    >
    > GOSUB SHT_Measure_Temp
    > DEBUG "tF...... "
    > DEBUG DEC (tF / 10), ".", DEC1 tF, DegSym, ClrRt, CR
    >
    > GOSUB SHT_Measure_Humidity
    > DEBUG "rhLin... "
    > DEBUG DEC (rhLin / 10), ".", DEC1 rhLin, "%", ClrRt, CR, CR
    >
    > PAUSE 5000
    >
    > Main1:
    > DEBUG CLS
    > DEBUG "SHT1x Demo", CR
    > DEBUG "
    ", CR
    > LoopDeLoop:
    > Main2:
    > GOSUB SHT_Measure_Temp
    > SEROUT 15, 240, [noparse][[/noparse]254, 71, 6,2, DEC tF / 10, ".", DEC1 tF]
    > ' **** See note above about displaying data on line 2 of the LCD
    >
    > GOSUB SHT_Measure_Humidity
    > SEROUT 15, 240, [noparse][[/noparse]254, 71, 16,2, DEC rhTrue / 10, ".", DEC1 rhTrue]
    > ' **** See note above about displaying data on line 2 of the LCD
    >
    >
    > PAUSE 1000 ' minimum delay between T/RH readings
    > GOTO LoopDeLoop
    >
    > '
    >
    >
    > ' Subroutines, Temp/RH
    > '
    >
    >
    >
    > ' connection reset: 9 clock cyles with ShtData high, then start sequence
    > '
    > SHT_Connection_Reset:
    > SHIFTOUT ShtData, Clock, LSBFIRST, [noparse][[/noparse]$FFF\9]
    >
    > ' generates SHT1x "start" sequence
    > ' _____ _____
    > ' ShtData |_______|
    > ' ___ ___
    > ' Clock ___| |___| |___
    > '
    > SHT_Start:
    > INPUT ShtData ' let pull-up take line
    > high
    > LOW Clock
    > HIGH Clock
    > LOW ShtData
    > LOW Clock
    > HIGH Clock
    > INPUT ShtData
    > LOW Clock
    > RETURN
    >
    >
    > ' measure temperature
    > ' -- celcius = soT * 0.01 - 40
    > ' -- fahrenheit = soT * 0.018 - 40
    > '
    > SHT_Measure_Temp:
    > GOSUB SHT_Start ' alert device
    > ioByte = ShtTemp ' temperature command
    > GOSUB SHT_Write_Byte ' send command
    > GOSUB SHT_Wait ' wait until
    > measurement done
    > ackBit = Ack ' another read follows
    > GOSUB SHT_Read_Byte ' get MSB
    > soT.HIGHBYTE = ioByte
    > ackBit = NoAck ' last read
    > GOSUB SHT_Read_Byte ' get LSB
    > soT.LOWBYTE = ioByte
    >
    > ' Note: Conversion factors are multiplied by 10 to return the
    > ' temperature values in tenths of degrees
    >
    > tC = soT / 10 - 400 ' convert to tenths C
    > tF = soT ** 11796 - 400 ' convert to tenths F
    > RETURN
    >
    >
    > ' measure humidity
    > '
    > SHT_Measure_Humidity:
    > GOSUB SHT_Start ' alert device
    > ioByte = ShtHumi ' humidity command
    > GOSUB SHT_Write_Byte ' send command
    > GOSUB SHT_Wait ' wait until
    > measurement done
    > ackBit = Ack ' another read follows
    > GOSUB SHT_Read_Byte ' get MSB
    > soRH.HIGHBYTE = ioByte
    > ackBit = NoAck ' last read
    > GOSUB SHT_Read_Byte ' get LSB
    > soRH.LOWBYTE = ioByte
    >
    > ' linearize humidity
    > ' rhLin = (soRH * 0.0405) - (soRH^2 * 0.0000028) - 4
    > '
    > ' for the BASIC Stamp:
    > ' rhLin = (soRH * 0.0405) - (soRH * 0.004 * soRH * 0.0007) - 4
    > '
    > ' Conversion factors are multiplied by 10 and then rounded to
    > ' return tenths
    > '
    > rhLin = (soRH ** 26542)
    > rhLin = rhLin - ((soRH ** 3468) * (soRH ** 3468) + 50 / 100)
    > rhLin = rhLin - 40
    >
    > ' temperature compensated humidity
    > ' rhTrue = (tC - 25) * (soRH * 0.00008 + 0.01) + rhLin
    > '
    > ' Conversion factors are multiplied by 100 to improve accuracy and
    > then
    > ' rounded off.
    > '
    > rhTrue = ((tC / 10 - 25) * (soRH ** 524 + 1) + (rhLin * 10)) + 5 / 10
    > RETURN
    >
    >
    > ' sends "status"
    > '
    > SHT_Write_Status:
    > GOSUB SHT_Start ' alert device
    > ioByte = ShtStatW ' write to status reg
    > command
    > GOSUB SHT_Write_Byte ' send command
    > ioByte = status
    > GOSUB SHT_Write_Byte
    > RETURN
    >
    >
    > ' returns "status"
    > '
    > SHT_Read_Status:
    > GOSUB SHT_Start ' alert device
    > ioByte = ShtStatW ' write to status reg
    > command
    > GOSUB SHT_Read_Byte ' send command
    > ackBit = NoAck ' only one byte to read
    > GOSUB SHT_Read_Byte
    > RETURN
    >
    >
    > ' sends "ioByte"
    > ' returns "ackBit"
    > '
    > SHT_Write_Byte:
    > SHIFTOUT ShtData, Clock, MSBFIRST, [noparse][[/noparse]ioByte] ' send byte
    > SHIFTIN ShtData, Clock, LSBPRE, [noparse][[/noparse]ackBit\1] ' get ack bit
    > RETURN
    >
    >
    > ' returns "ioByte"
    > ' sends "ackBit"
    > '
    > SHT_Read_Byte:
    > SHIFTIN ShtData, Clock, MSBPRE, [noparse][[/noparse]ioByte] ' get byte
    > SHIFTOUT ShtData, Clock, LSBFIRST, [noparse][[/noparse]ackBit\1] ' send ack bit
    > INPUT ShtData ' release data line
    > RETURN
    >
    >
    > ' wait for device to finish measurement (pulls data line low)
    > ' -- timeout after ~1/4 second
    > '
    > SHT_Wait:
    > INPUT ShtData ' data line is input
    > FOR toDelay = 1 TO 250 ' give ~1/4 second to
    > finish
    > timeOut = INS.LOWBIT(ShtData) ' scan data line
    > IF (timeOut = No) THEN SHT_Wait_Done ' if low, we're done
    > PAUSE 1
    > NEXT
    >
    > SHT_Wait_Done:
    > RETURN
    >
    >
    > ' reset SHT1x with soft reset
    > '
    > SHT_Soft_Reset:
    > GOSUB SHT_Connection_Reset ' reset the connection
    > ioByte = ShtReset ' reset command
    > ackBit = NoAck ' only one byte to send
    > GOSUB SHT_Write_Byte ' send it
    > PAUSE 11 ' wait at least 11 ms
    >
    >
    >
    > On Saturday, July 5, 2003, at 11:17 PM, Mike Mocenter wrote:
    >
    > > mark,
    > > can you post it?
    > >
    Original Message
    > > From: "Mark Marpet" <marpetm@s...>
    > > To: <basicstamps@yahoogroups.com>
    > > Sent: Saturday, July 05, 2003 10:45 PM
    > > Subject: Re: [noparse][[/noparse]basicstamps] Sensor SHT1X usage
    > >
    > >
    > >> I have done it using a serial LCD module. Essentially, what you need
    > >> to
    > >> do is change each and every DEBUG command to a SEROUT command.
    > >> (actually, COPY all the DEBUGs, PASTE them just below the DEBUGs, and
    > >> then change DEBUG to SEROUT on every other DEBUG. That way everything
    > >> will appear on the terminal and the LCD. When everything is cool,
    > >> trash
    > >> the DEBUG statements. I had to screw around with SEROUT parameters a
    > >> bit, but that simply involved wasting an hour. Each LCD has it's own
    > >> command codes (I think), so you would have to use the same LCD that I
    > >> used to share my code. That said, I am using a MAtrix Orbital VFD2041
    > >> (way-cool blue display), and would be glad to share my code if you
    > >> thought it would help.
    > >>
    > >> On Saturday, July 5, 2003, at 11:47 AM, no2k_4 wrote:
    > >>
    > >>> I am interested in using the Basic Stamp II to use with the Sensiron
    > >>> SHT1X Temp/Humidity Sensor. The program by Jon Williams, dated 28
    > >>> Sep 2002 looks perfect, EXCEPT, I would like to be able to use the
    > >>> sensor/Basic Stamp II with an LCD Module rather than DEBUG to a PC.
    > >>> I am just starting with programming and really need some help to
    > >>> make these Temp/Humidity readings go to the LCD AND also to DEBUG so
    > >>> I can be sure everything is correct. Has anyone ever done this? If
    > >>> so, would you be willing to help me out!?
    > >>> Kindest regards, Chuck Irwin
    > >>>
    > >>>
    > >>>
    > >>> 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/
    > >>>
    > >>>
    > >>>
    > >>
    > >>
    > >> 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/
    > >>
    > >>
    > >
    > >
    > > 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/
    > >
    > >
    > >
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
    >
    >
    > 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/
    >
    >
Sign In or Register to comment.