اطلاعیه

Collapse
No announcement yet.

سنسور دما و رطوبت SHT75

Collapse
X
 
  • فیلتر
  • زمان
  • Show
Clear All
new posts

    سنسور دما و رطوبت SHT75

    با سلام خدمت تمام اساتید گل
    کسی راجع به این سنسور اطلاعاتی داره ؟
    آخرین قیمت روز ؟
    با تشکر
    یا حق
    گیرم گلاب ناب شما اصل قمصر است/اما چه سود، حاصل گلآ‌های پرپر است!-از آن زمان که آیینهآ‌گردان شب شُدید*آیینه دل از دَم دوران مکدر است-وقتی بهار، وصله ناجور فصلآ‌هاست*وقتی تبر، مدافع حق صنوبر است-وقتی به دادگاه عدالت، طناب دار*بر صدر میآ‌نشیند و قاضی و داور است-از من مخواه شعرِ تر، ای بیآ‌خبر ز درد!*شعری که خون از آن نچکد ننگ دفتر است!-ای از تبار هرچه سیاهی، سرشتآ‌تان*رنگ جهنم است تمام بهشتآ‌تان
    "گزیده ابیاتی چند از بیداد خراسانی"

    #2
    پاسخ : سنسور دما و رطوبت SHT75

    سلام
    من دیروز خریدم 27000 تومن .
    بالاترین دقت رو بین سری sht داره .
    و بر اساس i2c کار نمیکنه .
    نوفن پردازش هوشمند

    دیدگاه


      #3
      پاسخ : سنسور دما و رطوبت SHT75

      اینم برنامه راه اندازی سنسور با بسکام


      '------------------------------------------------------------------------------
      ' Programma Naam : SHT6.bas
      ' Programma Datum : 20 jan 2002
      ' Designed by : Sensirion
      ' Adapted for 89S8252/BASCOM : Z.Otten http://home.hccnet.nl/z.otten
      ' Goal : Measuring the temperature and humidity with the
      ' Sensor : SHT11 humidity and temperature sensor :
      ' Protocol : I2C and 2 wire sensirion bus
      ' Processor : AT89S8252
      '------------------------------------------------------------------------------
      '****************bascom compiler options: memory byte end to B0 hex ***
      ' -----------------------------------------------------------------------------
      $regfile = "89S8252.dat"
      $crystal = 24000000
      $baud = 9600
      $large

      '$wait
      '$sim

      '-----------------------Subroutines
      'LCD Display
      Declare Sub Lcd_init
      Declare Sub Lcd_reg(r As Integer)
      Declare Sub Lcd_char(g As Integer)
      Declare Sub Lcd_txt(t As String)
      Declare Sub Make20char(t As String)

      'SHT11 humidity and temperature sensor
      Declare Sub S_write_byte(value As Byte)
      Declare Sub S_read_byte(r As Byte)
      Declare Sub S_transstart()
      Declare Sub S_connectionreset()
      Declare Sub S_softreset()
      Declare Sub S_readstatus()
      Declare Sub S_writstatus(value As Byte)
      Declare Sub S_measure_t()
      Declare Sub S_measure_h()
      Declare Sub S_calc()

      'Variables and constants
      Dim I As Byte , R As Byte
      Dim G As Integer , D As Integer , E As Integer
      Dim F As Bit
      Dim T As String * 20
      Dim L As String * 1

      Dim Value As Byte , Msb As Byte , Lsb As Byte
      Dim Tc As Single , Hum As Single , Rh As Single , Rh_t As Single
      Dim Rh_true As Single , X As Single , S1 As Single , S2 As Single , S3 As Single
      Dim Logex As Single
      Dim Error As Byte , P_value As Byte , P_checksum As Byte

      'Variables calc log
      Dim Z As Single , Zsq As Single
      Dim Temp As Single , Tmp1 As Single , Tmp2 As Single
      Dim Exp As Integer

      'Constants for calculating log10 and ln
      Const Loge = 0.434294482
      Const Log2 = 0.693147180559945
      Const Ln10 = 2.30258509299404
      Const Sqrto2 = 0.707106781186548
      Const Fp0 = -0.240139179559211e2
      Const Fp1 = 0.309572928215377e2
      Const Fp2 = -0.963769093368687e1
      Const Fp3 = 0.421087371217980
      Const Fq0 = -0.120069589779605e2
      Const Fq1 = 0.194809660700890e2
      Const Fq2 = -0.891110902798312e1

      Config Debounce = 50ms
      Config I2cdelay = 20 'default is 1 !

      Sht_data Alias P0.6 'DATA Sensibus SHTxx
      Sht_sck Alias P0.7 'SCK Sensibus SHTxx
      Sht_led Alias P0.5 'LED alarm


      '*************************************
      '***********Main program**************
      '*************************************
      ' read temperature and humidity
      ' calculate teh dew point
      ' and show results on LCD display

      'first say hello to the world..
      For I = 1 To 5
      Sht_led = 0
      Waitms 200
      Sht_led = 1
      Waitms 200
      Next I

      Error = 0
      Call Lcd_init

      Do

      'T = "* demo SHT11 sensor *"
      'Call Maak20regel(t)
      'Call Lcd_txt(t)
      'Waitms 255

      'calculating temperature
      Call S_measure_t() 'read temperature ticks from SHT11
      If Error = 0 Then
      T = "" 'calculate/compensate/calibrate
      Tc = Msb * 256
      Tc = Tc + Lsb
      Tc = Tc / 100
      Tc = Tc - 40 'TC in degrees celcius
      T = Fusing(tc , ###.##) + " degrees"
      Call Make20char(t)
      Call Lcd_txt(t)
      Waitms 255
      Else
      Call S_connectionreset()
      End If

      'calculating humidity
      Call S_measure_h() 'read humidity ticks from SHT11
      If Error = 0 Then
      Rh = Msb * 256 'calculate/compensate
      Rh = Rh + Lsb 'see SHT11 data sheet
      Hum = -4.0
      X = 0.0405 * Rh
      Hum = Hum + X
      X = Rh * Rh
      X = X * -0.0000028
      Hum = Hum + X
      'Hum is the humidity in % to display
      T = Fusing(hum , ###.##) + " %RH"
      Call Make20char(t)
      Call Lcd_txt(t)
      Waitms 255
      Else
      Call S_connectionreset()
      End If

      'calculating temperature compensated humidity
      Rh_t = 0.00008 * Rh 'temperature compensated humidity
      Rh_t = Rh_t - 0.01 'see SHT11 data sheet
      Tc = Tc - 25
      Rh_t = Tc * Rh_t
      Tc = Tc + 25
      Rh_t = Rh_t + Hum
      T = Fusing(rh_t , ###.##) + " %RH(t)"
      Call Make20char(t)
      Call Lcd_txt(t)

      'calculates Dew Point in Degrees C:
      'Tc = 25
      'Rh_t = 10
      'result : dew = -8.69
      Logex = 7.5 * Tc
      X = 237.3 + Tc
      Logex = Logex / X
      Logex = Logex + 0.66077
      X = Rh_t
      Gosub Log10
      X = X - 2
      Logex = Logex + X
      X = Logex - 0.66077
      X = X * 237.3
      Tc = 0.66077 + 7.5
      Tc = Tc - Logex
      Tc = X / Tc 'dew point (degrees C)
      T = Fusing(tc , ###.##) + " Dew C"
      Call Make20char(t)
      Call Lcd_txt(t)

      Waitms 255
      Waitms 255

      Loop
      '----------------------End main Program

      '--------------- Begin subroutine
      ' Subroutine to initialise the LCD-display
      Sub Lcd_init()
      I2cstop
      Waitms 100
      I2cstart
      I2cwbyte 72 ' PCF8574A to LCD
      Waitms 15
      Call Lcd_reg(&H3)
      Waitms 4
      Call Lcd_reg(&H3)
      Waitms 1
      Call Lcd_reg(&H3)
      Waitms 4
      Call Lcd_reg(&H2)
      Waitms 1
      Call Lcd_reg(&H2)
      Call Lcd_reg(&H8)
      Waitms 1
      Call Lcd_reg(&H0)
      Call Lcd_reg(&H8)
      Waitms 1
      Call Lcd_reg(&H0)
      Call Lcd_reg(&Hc)
      Waitms 1
      Call Lcd_reg(&H0)
      Call Lcd_reg(&H1)
      Waitms 1
      ' Initialisation complete

      I2cstop
      End Sub

      ' Subroutine to send a string to the LCD-display
      Sub Lcd_txt(t As String )
      I2cstart
      I2cwbyte 72 ' PCF8574A to LCD
      ' If placed in the string that you send to the LCD-display
      ' you can use the functions below:
      ' \A = 01 Clear display RAM and send Cursor home to 80h
      ' \B = 02 Return cursor home, align display with DRAM
      ' \C = 04 Shift left display and cursor
      ' \D = 05 Shift right display from current cursor position
      ' \E = 06 Shift right display and cursor
      ' \F = 07 Shift left display from current cursor position
      ' \G = 08 Set display, cursor and blinking off
      ' \H = 0C Enable display only (no cursor)
      ' \I = 0D Enable display and blinking cursor
      ' \J = 0E Enable display and underline cursor
      ' \K = 10 Shift cursor 1 character left
      ' \L = 14 Shift cursor 1 character right
      ' \M = 18 Shift display and cursor 1 character left
      ' \N = 1C Shift display and cursor 1 character right
      ' \O = to the second line

      F = 0
      For E = 1 To Len(t) - 1
      L = Mid(t , E , 1)
      If L = "\" Then
      F = 1
      Else
      If F = 0 Then
      G = Asc(l)

      Call Lcd_char(g)
      Else
      If L = "A" Then
      Call Lcd_reg(&H0)
      Call Lcd_reg(&H1)
      Elseif L = "B" Then
      Call Lcd_reg(&H0)
      Call Lcd_reg(&H2)
      Elseif L = "C" Then
      Call Lcd_reg(&H0)
      Call Lcd_reg(&H4)
      Elseif L = "D" Then
      Call Lcd_reg(&H0)
      Call Lcd_reg(&H5)
      Elseif L = "E" Then
      Call Lcd_reg(&H0)
      Call Lcd_reg(&H6)
      Elseif L = "F" Then
      Call Lcd_reg(&H0)
      Call Lcd_reg(&H7)
      Elseif L = "G" Then
      Call Lcd_reg(&H0)
      Call Lcd_reg(&H8)
      Elseif L = "H" Then
      Call Lcd_reg(&H0)
      Call Lcd_reg(&Hc)
      Elseif L = "I" Then
      Call Lcd_reg(&H0)
      Call Lcd_reg(&Hd)
      Elseif L = "J" Then
      Call Lcd_reg(&H0)
      Call Lcd_reg(&He)
      Elseif L = "K" Then
      Call Lcd_reg(&H10)
      Call Lcd_reg(&H0)
      Elseif L = "L" Then
      Call Lcd_reg(&H1)
      Call Lcd_reg(&H4)
      Elseif L = "M" Then
      Call Lcd_reg(&H1)
      Call Lcd_reg(&H8)
      Elseif L = "N" Then
      Call Lcd_reg(&H1)
      Call Lcd_reg(&Hc)
      Elseif L = "O" Then
      Call Lcd_reg(&H0)
      Call Lcd_reg(&H2)
      For I = 1 To 40
      Call Lcd_reg(&H1)
      Call Lcd_reg(&H4)
      Next I
      End If
      F = 0
      End If
      End If
      Next E
      I2cstop
      End Sub

      ' Subroutine to send a function to the LCD-display
      Sub Lcd_reg(r As Integer)
      I2cwbyte R
      R = R + 128
      I2cwbyte R
      R = R - 128
      I2cwbyte R
      End Sub

      ' Subroutine to send a character to the LCD-display
      Sub Lcd_char(g As Integer)
      D = G : G = G And &B11110000
      Rotate G , Right , 4
      I2cwbyte G
      G = G + &B10010000
      I2cwbyte G
      G = G - &B10010000
      I2cwbyte G
      G = D : G = G And &B00001111
      I2cwbyte G
      G = G + &B10010000
      I2cwbyte G
      G = G - &B10010000
      I2cwbyte G
      End Sub


      Sub Make20char(t As String)
      D = Len(t)
      If D < 20 Then
      While D <= 19
      T = T + " "
      D = D + 1
      Wend
      Else
      T = Left(t , 20)
      D = Len(t)
      End If
      End Sub

      'SHT bus
      Sub S_write_byte(value As Byte)
      G = 128
      Error = 0
      For I = 1 To 8
      R = Value And G
      If R = G Then
      Sht_data = 1
      Else
      Sht_data = 0
      End If
      Sht_sck = 1
      Sht_sck = 0
      G = G \ 2
      Next I
      Sht_data = 1
      Sht_sck = 1
      Waitms 1
      Error = Sht_data 'error = 1 if no acknowledge
      Sht_sck = 0
      If Error = 1 Then Sht_led = 0 Else Sht_led = 1
      End Sub

      Sub S_read_byte(r As Byte)
      Value = 0
      Sht_data = 1
      G = 128
      For I = 1 To 8
      Sht_sck = 1
      If Sht_data = 1 Then Value = Value + G
      Sht_sck = 0
      G = G \ 2
      Next I
      If R = 1 Then Sht_data = 0 Else Sht_data = 1
      Sht_sck = 1
      Waitms 3
      Sht_sck = 0
      Sht_data = 1
      End Sub

      Sub S_transstart()
      Sht_data = 1
      Sht_sck = 0
      Waitms 1
      Sht_sck = 1
      Waitms 1
      Sht_data = 0
      Waitms 1
      Sht_sck = 0
      Waitms 3
      Sht_sck = 1
      Waitms 1
      Sht_data = 1
      Waitms 1
      Sht_sck = 0
      End Sub

      Sub S_connectionreset()
      Sht_data = 1
      Sht_sck = 0
      For I = 1 To 9
      Sht_sck = 1
      Sht_sck = 0
      Next I
      Call S_transstart()
      End Sub

      Sub S_softreset()
      Error = 0
      Call S_connectionreset()
      Call S_write_byte(15)
      End Sub

      Sub S_readstatus()
      Error = 0
      Call S_transstart()
      Call S_write_byte(7)
      Call S_read_byte(1)
      P_value = Value
      Call S_read_byte(0)
      P_checksum = Value
      End Sub

      Sub S_writestatus(value As Byte)
      Error = 0
      Call S_transstart()
      Call S_write_byte(6)
      Call S_write_byte(value)
      End Sub

      Sub S_measure_t()
      Call S_transstart()
      Call S_write_byte(3)
      Wait 1
      Call S_read_byte(1)
      Msb = Value
      Call S_read_byte(1)
      Lsb = Value
      Call S_read_byte(0) 'ticks = 256 * Msb + Lsb
      P_checksum = Value
      End Sub

      Sub S_measure_h()
      Call S_transstart()
      Call S_write_byte(5)
      Wait 1
      Call S_read_byte(1)
      Msb = Value
      Call S_read_byte(1)
      Lsb = Value
      Call S_read_byte(0) 'ticks = 256 * Msb + Lsb
      P_checksum = Value
      End Sub

      'sub calculating logarithm
      Log10:
      Exp = 0
      If X >= 1.0 Then
      While X >= 1.0
      Incr Exp 'exp = exp + 1
      X = X / 2
      Wend
      Elseif X < 0.5 Then
      While X < 0.5
      Decr Exp 'exp = exp - 1
      X = 2 * X
      Wend
      End If

      While X < 0.5
      X = X * 2
      Decr Exp
      Wend

      If X < Sqrto2 Then
      X = X * 2
      Decr Exp
      End If

      ' z = (x-1)/(x+1);
      Tmp1 = X - 1
      Tmp2 = X + 1
      Z = Tmp1 / Tmp2
      Zsq = Z * Z

      ' Temp = ((fp3 * Zsq + Fp2) * Zsq + Fp1) * Zsq + Fp0
      Tmp1 = Fp3 * Zsq
      Tmp1 = Tmp1 + Fp2
      Tmp1 = Tmp1 * Zsq
      Tmp1 = Tmp1 + Fp1
      Tmp1 = Tmp1 * Zsq
      Tmp1 = Tmp1 + Fp0
      Temp = Tmp1

      ' Temp = Temp / (((1.0 * Zsq + Fq2) * Zsq + Fq1) * Zsq + Fq0)
      Tmp1 = 1.0 * Zsq
      Tmp1 = Tmp1 + Fq2
      Tmp1 = Tmp1 * Zsq
      Tmp1 = Tmp1 + Fq1
      Tmp1 = Tmp1 * Zsq
      Tmp1 = Tmp1 + Fq0
      Temp = Temp / Tmp1

      ' Temp = Temp * Z + Exp * Log2
      Tmp1 = Exp * Log2
      Temp = Temp * Z
      Temp = Temp + Tmp1
      Tmp1 = Temp * Loge

      X = Tmp1

      Return

      End

      '-------------------End subroutines
      نوفن پردازش هوشمند

      دیدگاه


        #4
        پاسخ : سنسور دما و رطوبت SHT75

        به به اینجا هم که آخر دنیاست (مشهد )
        امروز رفتم سوال کردم گفتن 32000 تومان
        واقعآ که

        حالا این سنسور با توجه به قیمتی که داره چجوریه ؟
        گیرم گلاب ناب شما اصل قمصر است/اما چه سود، حاصل گلآ‌های پرپر است!-از آن زمان که آیینهآ‌گردان شب شُدید*آیینه دل از دَم دوران مکدر است-وقتی بهار، وصله ناجور فصلآ‌هاست*وقتی تبر، مدافع حق صنوبر است-وقتی به دادگاه عدالت، طناب دار*بر صدر میآ‌نشیند و قاضی و داور است-از من مخواه شعرِ تر، ای بیآ‌خبر ز درد!*شعری که خون از آن نچکد ننگ دفتر است!-ای از تبار هرچه سیاهی، سرشتآ‌تان*رنگ جهنم است تمام بهشتآ‌تان
        "گزیده ابیاتی چند از بیداد خراسانی"

        دیدگاه


          #5
          پاسخ : سنسور دما و رطوبت SHT75

          تا جاییی که من می دونم قیمت این سنسور 3 هزار تومنه ولی من با کد ویژن نتونستم اون رو راه بیندازم که برنامه ای داره؟

          دیدگاه


            #6
            پاسخ : سنسور دما و رطوبت SHT75

            سلام
            سری های SHT همه بالای 15000 تومان هست این مدل 28000 تومن هست

            دیدگاه


              #7
              پاسخ : سنسور دما و رطوبت SHT75

              سلام

              این قطعه به چه صورت کار می کند؟؟؟
              شکل سنسور رو میشه بزارید؟؟؟

              دیدگاه


                #8
                پاسخ : سنسور دما و رطوبت SHT75

                ببخشید هنرش چیه این سنسور؟! :biggrin:

                دیدگاه


                  #9
                  پاسخ : سنسور دما و رطوبت SHT75

                  سلام
                  هنر اصلی این سنسور این هست که میتونه هم دما وهم رطوبت روبه شما بده در ضمن این سنسور از دقت بسیار بالایی برخور دار است و تا 0.1 درجه سانتی گراد برای دما دقت داره

                  دیدگاه


                    #10
                    پاسخ : سنسور دما و رطوبت SHT75

                    با سلامی بعد از مدتها دوری...
                    راستش خیلی وقت پیش من به قیمت 27000 تومان خریداری کردم و همون شب جواب گرفتم ازش.الان نمیدونم قیمتش چنده ولی سنسور توپیه.من که ازش راضیم.
                    امیدوارم کار شما رو هم راه بندازه.
                    یا حق
                    گیرم گلاب ناب شما اصل قمصر است/اما چه سود، حاصل گلآ‌های پرپر است!-از آن زمان که آیینهآ‌گردان شب شُدید*آیینه دل از دَم دوران مکدر است-وقتی بهار، وصله ناجور فصلآ‌هاست*وقتی تبر، مدافع حق صنوبر است-وقتی به دادگاه عدالت، طناب دار*بر صدر میآ‌نشیند و قاضی و داور است-از من مخواه شعرِ تر، ای بیآ‌خبر ز درد!*شعری که خون از آن نچکد ننگ دفتر است!-ای از تبار هرچه سیاهی، سرشتآ‌تان*رنگ جهنم است تمام بهشتآ‌تان
                    "گزیده ابیاتی چند از بیداد خراسانی"

                    دیدگاه


                      #11
                      پاسخ : سنسور دما و رطوبت SHT75

                      سلام دوست عزیز
                      ببخشید شما گفتید که از سنسورsht75 نتیجه گرفتید میشه لطف کنید برنامه و شماتیک مدارتونو بزارید
                      خیلی ممنونتون

                      دیدگاه


                        #12
                        پاسخ : سنسور دما و رطوبت SHT75

                        درود
                        قیمت این سنسور 26000 تومانه اینم دیتاشیت این سنسور شاید به کارت بیاد http://www.alldatasheet.com/datasheet-pdf/pdf/91103/ETC/SHT75.html

                        دیدگاه


                          #13
                          پاسخ : سنسور دما و رطوبت SHT75

                          دوستان میتونید با این برنامه سنسور SHT75 رو با بیسکام راه اندازی کنید

                          http://www.azhardari.mihanblog.com/post/188

                          دیدگاه


                            #14
                            پاسخ : سنسور دما و رطوبت SHT75

                            من با این برنامه جواب گرفتم.
                            کد:
                            /*********************************************
                            Pin 1 GND
                            Pin 2 Data (PB0)
                            Pin 3 Serial Clock (PB1)
                            Pin 4 VDD (2.4V to 5.5V)
                            
                            *********************************************/
                            
                            #include <mega32.h>
                            #include <stdio.h>
                            #include <delay.h>
                            #include <math.h>
                            #include <stdlib.h>
                            // Alphanumeric LCD Module functions
                            #asm
                            .equ __lcd_port=0x1B ;PORTB
                            #endasm
                            #include <lcd.h>
                            
                            // Declare your global variables here
                            
                            typedef union
                            { unsigned int i; float f;} value;
                            
                            
                            enum {TEMP,HUMI};
                            
                            sfrb PINB = 0x16;
                            sfrb PORTB = 0x18;
                            sfrb DDRB = 0x17;
                            
                            #define SHT_DATA_OUT DDRB.0
                            #define SHT_DATA_IN PINB.0
                            #define SHT_SCK PORTB.1
                            #define noACK 0
                            #define ACK 1
                            //adr command r/w
                            #define STATUS_REG_W 0x06 //000 0011 0
                            #define STATUS_REG_R 0x07 //000 0011 1
                            #define MEASURE_TEMP 0x03 //000 0001 1
                            #define MEASURE_HUMI 0x05 //000 0010 1
                            #define RESET 0x1e //000 1111 0
                            
                            const float C1=-4.0; // for 12 Bit
                            const float C2=+0.0405; // for 12 Bit
                            const float C3=-0.0000028; // for 12 Bit
                            const float T1=+0.01; // for 14 Bit @ 5V
                            const float T2=+0.00008; // for 14 Bit @ 5V
                            
                            //SHT Functions
                            char SHT_WriteByte(unsigned char valuep);
                            char SHT_ReadByte(unsigned char ack);
                            void s_transstart(void);
                            void s_connectionreset(void);
                            char s_softreset(void);
                            char s_measure(unsigned char *p_value, unsigned char *p_checksum, unsigned char mode);
                            void calc_sth11(float *p_humidity ,float *p_temperature);
                            float calc_dewpoint(float h,float t);
                            
                            unsigned char key=16,uch_TempTime_Number=0;
                            int intTemp1=0,intTime1=0,intTemp2=0,intTime2=0,intTemp3=0,intTime3=0;
                            int intTemp4=0,intTime4=0,intTemp5=0,intTime5=0,intTemp6=0,intTime6=0;
                            
                            
                            
                            
                            
                            
                            void print_temp_humy (void)
                            {
                            char str_hum_temp[10];
                            
                            value humi_val, temp_val;
                            unsigned char error, checksum, status;
                            float dew_point;
                            error=0;
                            error+=s_measure((unsigned char*) &humi_val.i,&checksum,HUMI);
                            error+=s_measure((unsigned char*) &temp_val.i,&checksum,TEMP);
                            if(error!=0) s_connectionreset();
                            else{
                            humi_val.f=(float)humi_val.i; //converts integer to float
                            temp_val.f=(float)temp_val.i; //converts integer to float
                            calc_sth11(&humi_val.f,&temp_val.f); //calculate humidity, temperature
                            dew_point=calc_dewpoint(humi_val.f,temp_val.f); //calculate dew point
                            }   
                            temp_val.f+=10;
                            ftoa(temp_val.f,0,str_hum_temp);
                            lcd_clear();
                            lcd_putsf("Tempreature: ");
                            lcd_puts(str_hum_temp);
                            ftoa(humi_val.f,0,str_hum_temp);
                            lcd_gotoxy(0,1);
                            lcd_putsf("Humydity: ");
                            lcd_puts(str_hum_temp);
                            }
                            
                            void main(void)
                            {
                            // Declare your local variables here
                            
                            
                            
                            
                            PORTA=0x00;
                            DDRA=0x00;
                            PORTB=0x00;
                            DDRB=0x00;
                            
                            DDRC=0x0F;
                            PORTC=0xF0;
                            
                            DDRD=0x0F;
                            PORTD=0xF0;
                            
                            TCCR0=0x00;
                            TCNT0=0x00;
                            TCCR1A=0x00;
                            TCCR1B=0x00;
                            TCNT1H=0x00;
                            TCNT1L=0x00;
                            OCR1AH=0x00;
                            OCR1AL=0x00;
                            OCR1BH=0x00;
                            OCR1BL=0x00;
                            ASSR=0x08;
                            TCCR2=0x05;
                            TCNT2=0x00;
                            OCR2=0x00;
                            //GIMSK=0x00;
                            MCUCR=0x00;
                            TIMSK=0x40;
                            ACSR=0x80;
                            
                            // Setup Sensibus Pins
                            
                            PORTB.1 = 0; // ClockLow
                            DDRB.1 = 1; // SCK is an output
                            
                            PORTB.0 = 0; // Always Zero
                            // Toggle DDRB.0 for Data
                            
                            // LCD module initialization
                            lcd_init(16);
                            
                            Start:
                            
                            s_softreset();
                            print_temp_humy();
                            
                            while (1)
                            {
                            delay_ms(500);
                            print_temp_humy();
                            
                            
                            
                            goto Start;
                            }
                            
                            }
                            
                            
                            //----------------------------------------------------------------------------------
                            // tulis byte ke SHT
                            //----------------------------------------------------------------------------------
                            char SHT_WriteByte(unsigned char valuep)
                            {
                            unsigned char i,error=0;
                            for (i=0x80;i>0;i/=2)
                            {
                            if (i & valuep) SHT_DATA_OUT=0;
                            else SHT_DATA_OUT=1;
                            SHT_SCK=1;
                            delay_us(5); //pulswith approx. 5 us
                            SHT_SCK=0;
                            }
                            SHT_DATA_OUT=0; //release DATA-line
                            SHT_SCK=1; //clk #9 for ack
                            error=SHT_DATA_IN; //check ack (DATA will be pulled down by SHT11)
                            SHT_SCK=0;
                            return error; //error=1 in case of no acknowledge
                            }
                            
                            //----------------------------------------------------------------------------------
                            // baca byte dari SHT, dan berikan ACK
                            //----------------------------------------------------------------------------------
                            char SHT_ReadByte(unsigned char ack)
                            {
                            unsigned char i,val=0;
                            SHT_DATA_OUT=0; //release DATA-line
                            for (i=0x80;i>0;i/=2)
                            {
                            SHT_SCK=1;
                            if (SHT_DATA_IN) val=(val | i); //read bit
                            SHT_SCK=0;
                            }
                            SHT_DATA_OUT=ack; //in case of "ack==1" pull down DATA-Line
                            SHT_SCK=1; //clk #9 for ack
                            delay_us(5); //pulswith approx. 5 us
                            SHT_SCK=0;
                            SHT_DATA_OUT=0; //release DATA-line
                            return val;
                            }
                            
                            //----------------------------------------------------------------------------------
                            // kondisi start
                            // _____ ________
                            // DATA: |_______|
                            // ___ ___
                            // SCK : ___| |___| |______
                            //----------------------------------------------------------------------------------
                            void s_transstart(void)
                            {
                            SHT_DATA_OUT=0;
                            SHT_SCK=0; //Initial state
                            delay_us(1);
                            SHT_SCK=1;
                            delay_us(1);
                            SHT_DATA_OUT=1;
                            delay_us(1);
                            SHT_SCK=0;
                            delay_us(5);
                            SHT_SCK=1;
                            delay_us(1);
                            SHT_DATA_OUT=0;
                            delay_us(1);
                            SHT_SCK=0;
                            }
                            
                            //----------------------------------------------------------------------------------
                            // reset koneksi, 9 clock diikuti dengan kondisi start
                            // _____________________________________________________ ________
                            // DATA: |_______|
                            // _ _ _ _ _ _ _ _ _ ___ ___
                            // SCK : __| |__| |__| |__| |__| |__| |__| |__| |__| |______| |___| |______
                            //----------------------------------------------------------------------------------
                            
                            void s_connectionreset(void)
                            {
                            unsigned char i;
                            SHT_DATA_OUT=0; SHT_SCK=0; //Initial state
                            for(i=0;i<9;i++) //9 SCK cycles
                            {
                            SHT_SCK=1;
                            delay_us(1);
                            SHT_SCK=0;
                            }
                            s_transstart(); //transmission start
                            }
                            
                            //----------------------------------------------------------------------------------
                            // reset SHT-nya !!
                            //----------------------------------------------------------------------------------
                            
                            char s_softreset(void)
                            {
                            unsigned char error=0;
                            s_connectionreset(); //reset communication
                            error+=SHT_WriteByte(RESET); //send RESET-command to sensor
                            return error; //error=1 in case of no response form the sensor
                            }
                            
                            //----------------------------------------------------------------------------------
                            // pengukuran data
                            //----------------------------------------------------------------------------------
                            char s_measure(unsigned char *p_value, unsigned char *p_checksum, unsigned char mode)
                            {
                            unsigned error=0;
                            unsigned int i;
                            
                            s_transstart(); //transmission start
                            switch(mode){ //send command to sensor
                            case TEMP : error+=SHT_WriteByte(MEASURE_TEMP); break;
                            case HUMI : error+=SHT_WriteByte(MEASURE_HUMI); break;
                            default : break;
                            }
                            for (i=0;i<65535;i++) if(SHT_DATA_IN==0) break; //wait until sensor has finished the measurement
                            if(SHT_DATA_IN) error+=1; // or timeout (~2 sec.) is reached
                            *(p_value+1) =SHT_ReadByte(ACK); //read the first byte (MSB)
                            *(p_value) =SHT_ReadByte(ACK); //read the second byte (LSB)
                            *p_checksum =SHT_ReadByte(noACK); //read checksum
                            return error;
                            }
                            
                            //----------------------------------------------------------------------------------------
                            // hitung temperature [°C] and humidity [%RH]
                            // input : humi [Ticks] (12 bit)
                            // temp [Ticks] (14 bit)
                            // output: humi [%RH]
                            // temp [°C]
                            //----------------------------------------------------------------------------------------
                            
                            void calc_sth11(float *p_humidity ,float *p_temperature)
                            {
                            
                            //float rh=*p_humidity; // rh: Humidity [Ticks] 12 Bit
                            //float t=*p_temperature; // t: Temperature [Ticks] 14 Bit
                            float rh_lin; // rh_lin: Humidity linear
                            float rh_true; // rh_true: Temperature compensated humidity
                            float t_C; // t_C : Temperature [°C]
                            
                            t_C=*p_temperature*0.01 - 40; //calc. temperature from ticks to [°C]
                            rh_lin=C3*(*p_humidity)*(*p_humidity) + C2*(*p_humidity) + C1; //calc. humidity from ticks to [%RH]
                            rh_true=(t_C-25)*(T1+T2*(*p_humidity))+rh_lin; //calc. temperature compensated humidity [%RH]
                            if(rh_true>100)rh_true=100; //cut if the value is outside of
                            if(rh_true<0.1)rh_true=0.1; //the physical possible range
                            
                            *p_temperature=t_C; //return temperature [°C]
                            *p_humidity=rh_true; //return humidity[%RH]
                            }
                            
                            //--------------------------------------------------------------------
                            // calculates dew point
                            // input: humidity [%RH], temperature [°C]
                            // output: dew point [°C]
                            //--------------------------------------------------------------------
                            
                            float calc_dewpoint(float h,float t)
                            {
                            float logEx,dew_point;
                            logEx=0.66077+7.5*t/(237.3+t)+(log10(h)-2);
                            dew_point = (logEx - 0.66077)*237.3/(0.66077+7.5-logEx);
                            return dew_point;
                            }

                            دیدگاه


                              #15
                              پاسخ : سنسور دما و رطوبت SHT75

                              نوشته اصلی توسط ARST
                              و بر اساس i2c کار نمیکنه .
                              پروتکل ارتباطیش چی ؟

                              دیدگاه

                              لطفا صبر کنید...
                              X