SHT_75 with picbasic pro


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326

    Default SHT_75 with picbasic pro

    Good day to all of you !

    I am going to interface the temperature _ humidity sensor type SHT_75 fron Sensirion to the Pic micro.
    I will like to know if there is a pic basic pro code to read this sensor and the routines to compute:
    > temperature in C° having + and - signs
    > temperature compensated RH ( + lin too !) in %
    > dew point in C° having + and - signs
    Thanks in advance for any assistance.
    Best regards,

    Ambrogio

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Never used on, but a quick lppk at the data sheet makes me think I2C or SHIFTIN might work.
    Here is a little about both for working with an EEPROM, maybe it will get you started?
    http://www.picbasic.co.uk/forum/cont...-EEPROM-Part-1
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default SHT_75 with picbasic pro

    Thanks mackrackit:
    I do not have any problem to talk with the SHT_75.
    I am able to get signed temperature tto.
    My problem is to compute RHtc with picbasic pro and to compute DEW POINT with its sign.
    Thanks for help
    Ambrogio
    IW2FVO

    Quote Originally Posted by mackrackit View Post
    Never used on, but a quick lppk at the data sheet makes me think I2C or SHIFTIN might work.
    Here is a little about both for working with an EEPROM, maybe it will get you started?
    http://www.picbasic.co.uk/forum/cont...-EEPROM-Part-1

  4. #4
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Post SHT_75 with picbasic pro

    Good day to all of you ,

    I am going to interface the Sensirion SHT_75 Temperature_Humidity sensor to my pic micro.
    I would like to know how to compute the RH termally compensate and how to compute the dew point. I rerad Srh @12 bit and St @14 bit.
    I expect that the RHtc will range from 0 to 99% RH
    The dew point temperature in C° will have the sign ( + or - ).

    I thank you in advance for any assistance on the coding .

    regards,
    Ambrogio
    IW2FVO

  5. #5
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    A quick google search got me to here for some basic stamp code. It may help. You could also search sht75 on this site for some more hits.

    http://www.emesystems.com/OL2sht1x.htm

    Please don't double post. I moved your post to this thread, even though it is pretty much the same as the first post.

    Code:
    '{$STAMP BS2}
    ' SHT15.bs2 version C
    ' (c) 2002, 2004 Tracy Allen, http://www.emesystems.com
    ' access the Sensirion model sht11 or sht15
    ' humidity and temperature chip
    ' temperature to xx.x degrees Celsius, RH to xx.x %
    ' Repeatedly shows raw data and converted values on debug screen.
    ' version B, corrects glaring error in humidity computation
    ' also adjusts timeout to allow use with faster stamps too.
    ' version C updates the math for temperature compensation of %RH
    ' and enables display of negative temperatures
    ' hookup sht11 or sht15 as follows for this program
    '
    ' STAMP                 SENSIRION
    '               220
    ' p1 ----o-----/\/\---o--pin 3 sck, clock
    '                     |
    '        ;---/\/\-----' pull-down
    '        | 4.7k
    ' Vss--o-o---------------pin 1 common
    '      |
    '     ===  0.1uf
    '      |             
    ' Vdd--o-o---------------pin 4 +5 volts
    '        |    4.7k
    '        '---/\/\-----; pull-up
    '                     |
    '              220    |
    ' p0 ----------/\/\---o--pin 2 dta, data
    '                       
    '
    ' The following code does not implement the CRC checking
     
     
    sck PIN 1
    dta PIN 0 ' note, 5k-10k pull-up, also 330ohm between the dta on stamp to dta on sht
    dtain var in0
     
    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 (be sure to 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 * 10
    RHtc VAR Word ' for temperature compensation of RH
     
    initialize:
     outs=0
     dirs=%1111111111111101
     GOSUB shtrst ' reset communication with sht
     
    DO
     getTemperature:
     cmd=shtTR ' temperature command to sht
     GOSUB shtget16
     degC=result+5/10-400 ' from 100ths to 10ths of a degree with rounding
     DEBUG tab,REP "-"\degC.bit15,DEC ABS degC/10,".",DEC1 ABS degC
     getHumidity:
     cmd=shtRH ' humidity command to sht
     GOSUB shtget16
     RH=(26542-(54722**result+result))**result-40
     ' temperature compensation follows:
     RHtc=655+(result*5)+(result**15917) ' intermediate factor
     RHtc=(RHtc**(degC+2480))-(RHtc**2730)+RH ' compensated value
     DEBUG tab, DEC result,tab,"%RH=",DEC RH/10,".",DEC1 RH
     DEBUG tab,"%RHtc=",DEC RHtc/10,".",DEC1 RHtc,cr
     PAUSE 1000
    LOOP
     
    ' initializes communication with sht 
    shtRst:
     SHIFTOUT dta,sck,lsbfirst,[$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,[r1] ' msbyte
     low dta ' acknowledge
     pulsout sck,10
     input dta
     shiftin dta,sck,msbpre,[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,[cmd]
     input dta ' allow acknowledge
     pulsout sck,10
    return
     
    shtWait:
     ' wait for sht to pull data pin low
     ' or for time out
     result=4096
     DO
     result=result-1
     LOOP WHILE dta & result.bit11
     RETURN
    </pre>
    Last edited by ScaleRobotics; - 28th November 2010 at 15:02.
    http://www.scalerobotics.com

  6. #6
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default SHT_75 with picbasic pro

    Thanks very much for the code.
    I am searching now for the dew point computation in picbasic pro !

    Thanks a lot for the help

    Ambrogio
    IW2FVO


    Quote Originally Posted by scalerobotics View Post
    A quick google search got me to here for some basic stamp code. It may help. You could also search sht75 on this site for some more hits.

    http://www.emesystems.com/OL2sht1x.htm

    Please don't double post. I moved your post to this thread, even though it is pretty much the same as the first post.

    Code:
    '{$STAMP BS2}
    ' SHT15.bs2 version C
    ' (c) 2002, 2004 Tracy Allen, http://www.emesystems.com
    ' access the Sensirion model sht11 or sht15
    ' humidity and temperature chip
    ' temperature to xx.x degrees Celsius, RH to xx.x %
    ' Repeatedly shows raw data and converted values on debug screen.
    ' version B, corrects glaring error in humidity computation
    ' also adjusts timeout to allow use with faster stamps too.
    ' version C updates the math for temperature compensation of %RH
    ' and enables display of negative temperatures
    ' hookup sht11 or sht15 as follows for this program
    '
    ' STAMP                 SENSIRION
    '               220
    ' p1 ----o-----/\/\---o--pin 3 sck, clock
    '                     |
    '        ;---/\/\-----' pull-down
    '        | 4.7k
    ' Vss--o-o---------------pin 1 common
    '      |
    '     ===  0.1uf
    '      |             
    ' Vdd--o-o---------------pin 4 +5 volts
    '        |    4.7k
    '        '---/\/\-----; pull-up
    '                     |
    '              220    |
    ' p0 ----------/\/\---o--pin 2 dta, data
    '                       
    '
    ' The following code does not implement the CRC checking
     
     
    sck PIN 1
    dta PIN 0 ' note, 5k-10k pull-up, also 330ohm between the dta on stamp to dta on sht
    dtain var in0
     
    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 (be sure to 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 * 10
    RHtc VAR Word ' for temperature compensation of RH
     
    initialize:
     outs=0
     dirs=%1111111111111101
     GOSUB shtrst ' reset communication with sht
     
    DO
     getTemperature:
     cmd=shtTR ' temperature command to sht
     GOSUB shtget16
     degC=result+5/10-400 ' from 100ths to 10ths of a degree with rounding
     DEBUG tab,REP "-"\degC.bit15,DEC ABS degC/10,".",DEC1 ABS degC
     getHumidity:
     cmd=shtRH ' humidity command to sht
     GOSUB shtget16
     RH=(26542-(54722**result+result))**result-40
     ' temperature compensation follows:
     RHtc=655+(result*5)+(result**15917) ' intermediate factor
     RHtc=(RHtc**(degC+2480))-(RHtc**2730)+RH ' compensated value
     DEBUG tab, DEC result,tab,"%RH=",DEC RH/10,".",DEC1 RH
     DEBUG tab,"%RHtc=",DEC RHtc/10,".",DEC1 RHtc,cr
     PAUSE 1000
    LOOP
     
    ' initializes communication with sht 
    shtRst:
     SHIFTOUT dta,sck,lsbfirst,[$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,[r1] ' msbyte
     low dta ' acknowledge
     pulsout sck,10
     input dta
     shiftin dta,sck,msbpre,[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,[cmd]
     input dta ' allow acknowledge
     pulsout sck,10
    return
     
    shtWait:
     ' wait for sht to pull data pin low
     ' or for time out
     result=4096
     DO
     result=result-1
     LOOP WHILE dta & result.bit11
     RETURN
    </pre>

  7. #7
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Here is some code for the SHT11 for calculating dewpoint. I have not compared datasheets to know how similar (or not) they are. But this may help:

    http://www.picbasic.co.uk/forum/show...=3851#post3851

    That is quite the equation! From NavMicroSystems post above:
    Code:
    '** Dewpoint Calculation
        ' See: SENSIRION Application Note "Dewpoint Calculation"
        ' logEW = (0.66077+7.5*T/(237.3+T)+(log(RH)-2)
          ' DP = ((0.66077-logEW)*237.3)/(logEW-8.16077)
    
    DewPoint:
      
      TempDP=Temp/10
      logEW=6608
      sign=TempDP.bit15
      wz=ABS TempDP
      wx=(7*wz)+(wz/2)                              
      wy=2373+wz
      wj=wx/wy
       For ix=15 to 0 step -1
        wx=(wx//wy)<<1
        wz.bit0(ix)=wx/wy
       Next
      wx=(-sign^((wj*10000)+(wz**10000)))+sign        
      logEW=wx+logEW
      wx=RHtc
      wj=(NCD wx) - 1
      wx=wx<<(15-wj)
      wz=0
      For ix=14 to 0 step -1
        wy=wx**wx
        wz.bit0(ix)=wy.bit15
        bt=~wy.bit15
        wx=(wy<
       Next
      
      wx=((wj*4000)**49321)+(wz**6021)
      logEW=wx+logEW-30000            
      sign=logEW.bit15
      logEW=(-sign^(((ABS logEW)+2)/4))+sign
      wx=1652-logEW
      sign=~wx.bit15
      wx=ABS wx
      wy=20402-logEW
      wj=wx/wy
      
       For ix=15 to 0 step -1
        wx=(wx//wy)<<1
        wz.bit0(ix)=wx/wy
       Next
      
      DP=((23730**wz)+5)/10
      DP=(-sign^DP)+sign
    And attached is an application note for dew point calculations.
    Attached Images Attached Images
    Last edited by ScaleRobotics; - 29th November 2010 at 15:21.
    http://www.scalerobotics.com

  8. #8
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default sht_75 with picbasic pro

    Hi scalerobotics,

    yes, the sht_11 has the same interface characteristics of the sht_75 so the code would be OK,

    Thanks for helping me,

    Regards,
    Ambrogio
    IW2FVO

    Quote Originally Posted by scalerobotics View Post
    Here is some code for the SHT11 for calculating dewpoint. I have not compared datasheets to know how similar (or not) they are. But this may help:

    http://www.picbasic.co.uk/forum/show...=3851#post3851

  9. #9
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default BS2 sht15.bs2 version C

    Good day to all in the forum.

    I am using the sht15.bs2 program together with the sht_75 sensor.
    I found that the temperature compensated relative humidity RHtc is not correct for temperature below 0 degC.
    I think that there is a problem in the code related to the use of the degC variable;
    This variable becomes negative if the temperature result is less than 4000 ( this is equivalent to 0degC ): in the RHtc computation this negative value could generate problem...

    I will appreciate very much any help or comment .
    Thanks
    Ambrogio
    Iw2fvo

  10. #10
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    iw2fvo , I believe that would be 0% RH. (freezing) Check out this site for more info...
    http://www.techtoys.com.hk/8051/AT89...SHTxx_demo.pdf

    Dave Purola,
    N8NTA

  11. #11
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default SHT_75 with picbasic pro

    Hi Dave,

    Thanks a lot for your reply on the matter.
    I will try to better clarify the problem that I have using the SHT15.bs2 ver.C program from Tracy Allen ( emesystems).

    Point _1.
    The program reads the raw temperature and store it on the " result " word variable.
    The temperature is obtained using the following : degC=result+5/10-400.
    This means that if the result is 5000 we have +10°C, if the result is 4000 temp is 0°C
    and if 3000 the temp is -10°C. I modified the program in order to "display" the minus sign
    when result is less then 4000. Result is the 14 bit raw temperature delivered by the sensor.
    Up to here everythings is correct and my system shows the correct temperature. I did some comparison with the airport control tower close to my home : it is consistent.

    Point _2
    the program then reads the raw RH (12 bit ) and stores that value on the "result" word variable.
    RH is then obtained as follows: RH=(26542-(54772**RESULT+RESULT))**RESULT-40.
    At this point everything is ok to me : my PIC micro gives me the correct RH value.

    Point_3
    The program computes now the temperature compensated RH in two steps:
    First step > RHtc=655+(RESULT*5)+(RESULT**15917)
    Second Step > RHtc=(RHtc**(degC+2480))-(RHtc**2730)+RH
    >>> At this point the RHtc is correct only if the temperature is above 0°C or, if the raw temperature data from the sensor is more than 4000 !.
    If the temperature is negative e.g. -1.7 °C the RHtc is not correct. It is about 172%.
    The control tower gives me T=-1.7°C , rh=85% and Dew point of -3.9°C.
    >>> This is my problem.

    I will appreciate very much if someone can give me an help to solve the troble.
    May be that some other programmer ( I am not a programmer ! ) have already solved it !
    Thanks in advance

    Regards,
    73!
    Ambrogio
    IW2FVO

    P.s.: English is not my first language and I am not sure to have express my problem correctly: I am Italian !


    Quote Originally Posted by Dave View Post
    iw2fvo , I believe that would be 0% RH. (freezing) Check out this site for more info...
    http://www.techtoys.com.hk/8051/AT89...SHTxx_demo.pdf

    Dave Purola,
    N8NTA

  12. #12
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    iw2fvo, It is not possible to have this sensor or that equation to give you acurate results below freezing. Please read this artical: http://www.rhsystems.net/papers/RH_WMO.pdf. I have used a chilled mirror in the past for this type of measurement sampling air from a test chanber at - 20 F. However the type of sensor you are using is limited as far as humidity measurements and that is why the formula is not acurate below 0C.

    Dave Purola,
    N8NTA

  13. #13
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default SHT_75 with picbasic pro

    Dave,
    thanks a lot for the document you have indicated to me.
    I will read it carefully.
    I noted that all the weather station here on the web and the control towers broadcast RH even if the temperature is below 0°C. All of them diclare a consistent RH. At this point I do not understand well. I must study a little bit more.
    At the same time I am notice that my Oregon weather station gives a correct RH for negative temperature too.
    The SHT15.BS2 program has a bug somewhere : I would like to know if someone solved it !
    Please let me know... just in case you know a fix.
    Thanks again Dave for the help.
    73 !
    Ambrogio
    IW2FVO
    North Italy


    Quote Originally Posted by Dave View Post
    iw2fvo, It is not possible to have this sensor or that equation to give you acurate results below freezing. Please read this artical: http://www.rhsystems.net/papers/RH_WMO.pdf. I have used a chilled mirror in the past for this type of measurement sampling air from a test chanber at - 20 F. However the type of sensor you are using is limited as far as humidity measurements and that is why the formula is not acurate below 0C.

    Dave Purola,
    N8NTA

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts