SHT75

General discussion on mikroC.
Author
Message
dariush_abbasi
Posts: 120
Joined: 11 May 2008 18:47

SHT75

#1 Post by dariush_abbasi » 07 Jul 2009 11:15

Hi friends.
Please help me.
I desperately disappointed with SHT75.
I need the 0.01 resolution and i checked nearly all of programs about SHT on this forum and i have worked for several days but still no response.
My microchip is 18f452,my clock is 8M.
My LCD works properly and i connect sht as its datasheet.DATA->RB2 with pull-up.SCK->RB1 and two others to +5v and GND.
Thanks in advance.
This is my program but nothing shown on LCD.

Code: Select all


/*******************************************************************************
      Filename   : SHT11_testing.c

      Author      : LIAU WEI CHUN
      Email        : wcl14u@gmail.com
      Revision    : Demo Revised 1.0b
      Date         : 29 Feb 2008
      Compiled by: Mikro C v8.0.0.0



      PIC 16F877A~4MHz.

      History    : Changes made to the original Keil's lib.
                 - Reconfigure data pin, sck pin & data port condition.
                 - Added data port condition: input/output
                 - _nop_() function -> Delay_us()


*******************************************************************************/


typedef union
{ unsigned int i;
  float f;
} value;


//------------------------------------------------------------------------------
// modul-var
//------------------------------------------------------------------------------
//enum {TEMP,HUMI};

//#include "initlcd.h"

#define TEMP 0
#define HUMI 1

#define PORT_COND TRISB.F2    //data port condition: input/output
#define DATA PORTB.F2         //SHT11 DATA pin
#define SCK PORTB.F1          //STH11 SCK pin
#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

#define MEMORY_ADDRESS  0xA0


/************************************************************
       Filename   : initlcd.c
       Description: Initializations of LCD & Sound.
************************************************************/

void Initlcd(void)
 {
  ADCON1 = 0xff;
  PORTA = 0x00;          //initialize/clear PORTA
  PORTB = 0x00;          //initialize PORTB
  PORTC = 0x00;          //initialize PORTC
  PORTD = 0x00;          //initialize PORTD

  TRISA = 0;             //PORTA = output.
  TRISB = 0;
  TRISC = 0;
  TRISD = 0;             //PORTD = output.
  TRISE = 0;             //PORTE = output.


  //Lcd_Config(&PORTD, 0, 1, 7, 5, 4, 3, 2);
  Lcd_Init(&PORTD);
  Lcd_Cmd(LCD_CLEAR);       // Clear display
  Lcd_Cmd(LCD_CURSOR_OFF);  // Turn cursor off


 }

char* Out_temp()
 {
     char str[]="Temp:" absolute MEMORY_ADDRESS;
     return str;
 }

  char* Out_humi()
 {
     char str[]="Humi:" absolute MEMORY_ADDRESS;
     return str;
 }


//------------------------------------------------------------------------------
char s_write_byte(unsigned char value)
//------------------------------------------------------------------------------
// writes a byte on the Sensibus and checks the acknowledge
{
   unsigned char i,error=0;

   PORT_COND = 0;        //SHT11 WRITE


   for (i=0x80;i>0;i/=2) //shift bit for masking
   {
     Delay_us(2);
     if (i & value)
         DATA=1; //masking value with i , write to SENSI-BUS
     else
         DATA=0;
     SCK=1; //clk for SENSI-BUS
     
     Delay_us(2);   //pulswith approx. 5 us
     
     SCK=0;
   }

   DATA=1; //release DATA-line

   PORT_COND = 1;    //SHT11 READ

   Delay_us(2);

   SCK=1; //clk #9 for ack
   
   Delay_us(2);
   error = DATA; //check ack (DATA will be pulled down by SHT11)
   
   SCK=0;
   
   return error; //error=1 in case of no acknowledge
}


//----------------------------------------------------------------------------------
char s_read_byte(unsigned char ack)
//----------------------------------------------------------------------------------
// reads a byte form the Sensibus and gives an acknowledge in case of "ack=1"
{
   unsigned char i,val=0;

   PORT_COND = 1;        //SHT11 READ


   DATA=1; //release DATA-line

   for (i=0x80;i>0;i/=2) //shift bit for masking
   {
     Delay_us(2);
     SCK=1; //clk for SENSI-BUS

     if (DATA) val=(val | i); //read bit
     Delay_us(2);
     
     SCK=0;
   }

   Delay_us(2);
   PORT_COND = 0;        //SHT11 WRITE
   Delay_us(2);
   
   DATA=!ack; //in case of "ack==1" pull down DATA-Line
   SCK=1; //clk #9 for ack
   Delay_us(2); //pulswith approx. 5 us
   SCK=0;
   Delay_us(2);
   DATA=1; //release DATA-line
   
   return val;
}


//----------------------------------------------------------------------------------
void s_transstart(void)
//----------------------------------------------------------------------------------
// generates a transmission start
//       _____         ________
// DATA:      |_______|
//           ___     ___
// SCK : ___|   |___|   |______
{
   PORT_COND = 0;   //SHT11 WRITE

   DATA=1;
   SCK=0;   //Initial state
   Delay_us(2);
   SCK=1;
   Delay_us(2);
   DATA=0;
   Delay_us(2);
   SCK=0;
   Delay_us(2);
   SCK=1;
   Delay_us(2);
   DATA=1;
   Delay_us(2);
   SCK=0;
}


//----------------------------------------------------------------------------------
void s_connectionreset(void)
//----------------------------------------------------------------------------------
// communication reset: DATA-line=1 and at least 9 SCK cycles followed by transstart
//       _____________________________________________________         ________
// DATA:                                                      |_______|
//          _    _    _    _    _    _    _    _    _        ___     ___
// SCK : __| |__| |__| |__| |__| |__| |__| |__| |__| |______|   |___|   |______
{
   unsigned char i;

   PORT_COND = 0;  //SHT11 WRITE


   DATA=1; SCK=0;  //Initial state

   for(i=0;i<9;i++) //9 SCK cycles
   {
     Delay_us(2);
     SCK=1;
     Delay_us(2);
     SCK=0;
   }
   
   Delay_us(2);

   s_transstart(); //transmission start
}


//----------------------------------------------------------------------------------
char s_softreset(void)
//----------------------------------------------------------------------------------
// resets the sensor by a softreset
{
   unsigned char error=0;

   s_connectionreset(); //reset communication

   error+=s_write_byte(RESET); //send RESET-command to sensor
   return error; //error=1 in case of no response form the sensor
}


//----------------------------------------------------------------------------------
char s_read_statusreg(unsigned char *p_value, unsigned char *p_checksum)
//----------------------------------------------------------------------------------
// reads the status register with checksum (8-bit)
{
   unsigned char error=0;

   s_transstart(); //transmission start

   error=s_write_byte(STATUS_REG_R); //send command to sensor

   //Delay_us(100);
   
   *p_value=s_read_byte(ACK); //read status register (8-bit)
   *p_checksum=s_read_byte(noACK); //read checksum (8-bit)

   return error; //error=1 in case of no response form the sensor
}


//----------------------------------------------------------------------------------
char s_write_statusreg(unsigned char *p_value)
//----------------------------------------------------------------------------------
// writes the status register with checksum (8-bit)
{
   unsigned char error=0;

   s_transstart(); //transmission start

   error+=s_write_byte(STATUS_REG_W);//send command to sensor
   error+=s_write_byte(*p_value); //send value of status register

   return error; //error>=1 in case of no response form the sensor
}


//----------------------------------------------------------------------------------
char s_measure(unsigned char *p_value, unsigned char *p_checksum, unsigned char mode)
//----------------------------------------------------------------------------------
// makes a measurement (humidity/temperature) with checksum
{
   unsigned error=0;
   unsigned int i;

   s_transstart(); //transmission start

   switch(mode)
   { //send command to sensor
   case TEMP : error+=s_write_byte(MEASURE_TEMP); break;   //temp
   case HUMI : error+=s_write_byte(MEASURE_HUMI); break;   //humidity
   default : break;
   }

   PORT_COND = 1;  //SHT11 READ


   for (i = 0; i < 65535 && DATA; i++) Delay_us(10); //wait until sensor has finished the measurement
   
   //while (DATA == 1) Delay_us(1);

   if(DATA) error+=1; // or timeout (~2 sec.) is reached

   *(p_value+1)=s_read_byte(ACK); //read the second byte (LSB)
   *(p_value) =s_read_byte(ACK); //read the first byte (MSB)



   *p_checksum =s_read_byte(noACK); //read checksum

   return error;
}

/*
//----------------------------------------------------------------------------------
void init_uart()
//----------------------------------------------------------------------------------
// Initializes the UART so the final data can be sent away, e.g. to a PC
//9600 bps @ 11.059 MHz
{     SCON = 0x52;
      TMOD = 0x20;
      TCON = 0x69;
      TH1 = 0xfd;
}
*/

//----------------------------------------------------------------------------------------
void calc_sth11(float *p_humidity ,float *p_temperature)
//----------------------------------------------------------------------------------------
// calculates temperature [C] and humidity [%RH]
// input : humi [Ticks] (12 bit)
// temp [Ticks] (14 bit)
// output: humi [%RH]
// temp [C]
{  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
   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=t*0.01-40; //calc. Temperature from ticks to [C]

   rh_lin=C3*rh*rh + C2*rh + C1; //calc. Humidity from ticks to [%RH]

   rh_true=(t_C-25)*(T1+T2*rh)+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]
}


//--------------------------------------------------------------------
float calc_dewpoint(float h,float t)
//--------------------------------------------------------------------
// calculates dew point
// input: humidity [%RH], temperature [C]
// output: dew point [C]
{  float k,dew_point ;

   k = (log10(h)-2)/0.4343 + (17.62*t)/(243.12+t);

   dew_point = 243.12*k/(17.62-k);

   return dew_point;
}

//----------------------------------------------------------------------------------
void main()
//----------------------------------------------------------------------------------
// sample program that shows how to use SHT11 functions
// 1. connection reset
// 2. measure humidity [ticks](12 bit) and temperature [ticks](14 bit)
// 3. calculate humidity [%RH] and temperature [C]
// 4. calculate dew point [C]
// 5. print temperature, humidity, dew point


{  value humi_val,temp_val;

   float dew_point;
   unsigned char error,checksum;
   //unsigned int i;

   char temp[13];
   char humi[13];


   Initlcd();    //Initialize LCD

   s_connectionreset();
   Delay_ms(20);

   while(1)
   {

     error=0;

     error+=s_measure((unsigned char*) &humi_val.i,&checksum,HUMI);
     //measure humidity

     error+=s_measure((unsigned char*) &temp_val.i,&checksum,TEMP);
     //measure temperature

     if(error!=0) s_connectionreset(); //in case of an error: connection reset
     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

       //send final data to serial interface (UART)

       Lcd_Out(1,1,Out_temp());
       Lcd_Out(2,1,Out_humi());

       FloatToStr(temp_val.f, temp);
       Lcd_Out(1,6,temp);

       FloatToStr(humi_val.f, humi);
       Lcd_Out(2,6,humi);


     }
//----------wait approx. 0.8s to avoid heating up SHTxx----------------------
//-----------------------------------------------------------------------------------
     Delay_ms(1000);

   }

}



barbarossa
Posts: 37
Joined: 25 Jan 2007 14:18
Location: Sweden, Tågarp

#2 Post by barbarossa » 11 Jul 2009 20:57

You can get the resolution but you can't get the accuracy from the SHT**

I have modified the sensirion example code somewhat and added the possibility to set the constants. I have not worked out any calibration scheme yet, but it will be based on the data sheet below.

http://www.omega.com/temperature/z/pdf/z103.pdf

My code is in "work in progress" status, so it is not pretty. Keep me posted If you make any improvement.

edit compiler version: MikroC Pro 2.15

Code: Select all

/*
Tested on PIC16F690 at 8MHZ internal oscillator.

PIC16F690
(PIC18F14K50)


          _______    _______
         |       `-´        |
+5V     -| VDD          VSS |- GND
NC      -| RA5          RA0 |- PK2
NC      -| RA4          RA1 |- PK2
PK2     -| MCLR/RA3     RA2 |- NC
NC      -| RC5          RC0 |- LCD D4
NC      -| RC4          RC1 |- LCD D5
LCD D7  -| RC3          RC2 |- LCD D6
LCD EN  -| RC6          RB4 |- SHT DATA
LCD RS  -| RC7       RX/RB5 |- MAX
MAX     -| RB7/TX       RB6 |- SHT SCK
         |__________________|

By just using the constants from the datasheet the accuracy of the SHT** is no
better than a honeywell HIH4000 and a LM335. In order to get ANY accuracy the
SHT** must be individually calibrated.

Set calibration constants with serial port by writing "# *\r"
where # is a number in the range from 0 to 6, which indicates the constant
(see below) and * is a floating point number

To read a calibration constant write only "#\r"

0 c1
1 c2
2 c3
3 t1
4 t2
5 d1
6 d2


Only one Command per while loop is possible (1/second)


checksum and dewpoint calculation has been omitted from the Sensirion example
code



*/
enum {TEMP,HUMI};
#define FALSE            0
#define TRUE             1
#define DATA_T           TRISB.F4
#define DATA_P           PORTB.F4
#define SCK_T            TRISB.F6
#define noACK            0
#define ACK              1
                                //adr  command  r/w
#define MEASURE_TEMP     0x03   //000   0001    1
#define MEASURE_HUMI     0x05   //000   0010    1

//LCD pin conf
sbit LCD_RS at RC7_bit;
sbit LCD_EN at RC6_bit;
sbit LCD_D4 at RC0_bit;
sbit LCD_D5 at RC1_bit;
sbit LCD_D6 at RC2_bit;
sbit LCD_D7 at RC3_bit;

sbit LCD_RS_Direction at TRISC7_bit;
sbit LCD_EN_Direction at TRISC6_bit;
sbit LCD_D4_Direction at TRISC0_bit;
sbit LCD_D5_Direction at TRISC1_bit;
sbit LCD_D6_Direction at TRISC2_bit;
sbit LCD_D7_Direction at TRISC3_bit;



unsigned char in_string[16]={0},in_i=0,in_stop=FALSE;


////////////////////////////////////////////////////////////////////////////////
void interrupt()
{
   char tmp_chr;
   tmp_chr=Uart1_Read();
   if (tmp_chr=='\r') in_stop=TRUE;
   else if (in_stop==FALSE)
   {
      in_string[in_i]=tmp_chr;
      in_i++;
   }
}
////////////////////////////////////////////////////////////////////////////////

void Write_Float(float tmp_var)
{
   char tmp_string[16];
   FloatToStr(tmp_var,tmp_string);
   Uart1_Write_Text(tmp_string);
   Uart1_Write('\r');

}
////////////////////////////////////////////////////////////////////////////////
void Write_Int(unsigned int tmp_int)
{
   char tmp_string[16];
   IntToStr(tmp_int,tmp_string);
   Uart1_Write_Text(tmp_string);
   Uart1_Write('\r');

}
////////////////////////////////////////////////////////////////////////////////
void Write_LCD(unsigned char row, unsigned char col,float tmp_var)
{
   char tmp_string[16];
   FloatToStr(tmp_var,tmp_string);
   LCD_Out(row,col,tmp_string);
}

////////////////////////////////////////////////////////////////////////////////
void Command(float *var)
{
   unsigned char i=0,position,tmp_string[16];
   if ((in_string[0]>='0')&&  (in_string[0]<='6') )
   {
     position=in_string[0]-48;
     while(in_string[i])
     {
        tmp_string[i]=in_string[i+2];
        i++;
     }
     if (i>1) var[position]=atof(tmp_string);  //if position is followed by float
     else Write_Float(var[position]);
   }
}

////////////////////////////////////////////////////////////////////////////////




//------------------------------------------------------------------------------
char s_write_byte(unsigned char value)
//------------------------------------------------------------------------------
// writes a byte on the Sensibus and checks the acknowledge
{
  unsigned char i,error=0;
  for (i=0x80;i>0;i/=2)             //shift bit for masking
  {
    if (i & value) DATA_T=1;          //masking value with i , write to SENSI-BUS
    else DATA_T=0;
    SCK_T=1;                          //clk for SENSI-BUS
    asm nop;asm nop;asm nop;        //pulswith approx. 5 us
    SCK_T=0;
  }
  DATA_T=1;                           //release DATA_T-line
  SCK_T=1;                            //clk #9 for ack
  error=DATA_P;                       //check ack (DATA_T will be pulled down by SHT11)

  SCK_T=0;
  return error;                     //error=1 in case of no acknowledge
}

//------------------------------------------------------------------------------
char s_read_byte(char ack)
//------------------------------------------------------------------------------
{    unsigned char i, val = 0;
     for (i=0x80;i>0;i/=2)
     {
         SCK_T = 1;
         if (DATA_P) val = (val | i);
         SCK_T = 0;
     }
     DATA_T = !ack;
     SCK_T = 1;
     asm nop;asm nop;asm nop;
     SCK_T = 0;
     DATA_T = 1;


     return val;
}
//----------------------------------------------------------------------------------
void s_transstart(void)
//----------------------------------------------------------------------------------
// generates a transmission start
//         _____         ________
// DATA_T:      |_______|
//             ___     ___
// SCK_T : ___|   |___|   |______
{
   DATA_T=1;
   SCK_T=0;                   //Initial state
   asm nop;
   SCK_T=1;
   asm nop;
   DATA_T=0;
   asm nop;
   SCK_T=0;
   asm nop;asm nop;asm nop;
   SCK_T=1;
   asm nop;
   DATA_T=1;
   asm nop;
   SCK_T=0;
}

//----------------------------------------------------------------------------------
void s_connectionreset(void)
//----------------------------------------------------------------------------------
// communication reset: DATA_T-line=1 and at least 9 SCK_T cycles followed by transstart
//         _____________________________________________________         ________
// DATA_T:                                                      |_______|
//            _    _    _    _    _    _    _    _    _        ___     ___
// SCK_T : __| |__| |__| |__| |__| |__| |__| |__| |__| |______|   |___|   |______
{
  unsigned char i;
  DATA_T=1; SCK_T=0;                    //Initial state
  for(i=0;i<9;i++)                  //9 SCK_T cycles
  { SCK_T=1;
    SCK_T=0;
  }
  s_transstart();                   //transmission start
}


//----------------------------------------------------------------------------------
char s_measure(unsigned char *p_value,unsigned char mode)
//----------------------------------------------------------------------------------
// makes a measurement (humidity/temperature) without checksum
{
  unsigned error=0;
  unsigned int i;

  s_transstart();                   //transmission start
  switch(mode)
  {                     //send command to sensor
    case TEMP   : error+=s_write_byte(MEASURE_TEMP); break;
    case HUMI   : error+=s_write_byte(MEASURE_HUMI); break;
    default     : break;
  }
  for (i=0;i<65535;i++) if(DATA_P==0) break; //wait until sensor has finished the measurement
  if(DATA_P) error+=1;                // or timeout (~? sec.) is reached
  *(p_value+1)=s_read_byte(ACK);    //read the first byte (MSB)
  *(p_value)=s_read_byte(noACK);    //read the second byte (LSB)
  return error;
}

void calc_sth11(float *p_h ,float *p_t, float *var)
{
  float h, t;            // rh:      Humidity [Ticks] 12 Bit
              // t:       Temperature [Ticks] 14 Bit
  h=*p_h;
  t=*p_t;
  
  t=var[5]+var[6]*t;                  //calc. temperature from ticks to [°C]
  h=(t-25)*(var[3]+var[4]*h)+var[0]+var[1]*h+var[2]*h*h;

  if(h>100) h=100;       //cut if the value is outside of
  if(h<0.1) h=0.1;       //the physical possible range

  *p_t=t;                //return temperature [°C]
  *p_h=h;                //return humidity[%RH]
}



////////////////////////////////////////////////////////////////////////////////
void main()
{
   unsigned int h_raw,t_raw;
   unsigned char i,error;
   float h_val,t_val,cal[7];
   
   OSCCON=0x71;
   ANSEL=0;
   ANSELH=0;
   TRISB=0;
   PORTB=0;
   TRISC=0;
   Uart1_Init(38400);
   for (i=0;i<28;i++) *((char *)&cal + i)=Eeprom_Read(i);
   Lcd_Init();
   Lcd_Cmd(_LCD_CLEAR);
   Lcd_Cmd(_LCD_CURSOR_OFF);
   Lcd_Out(1,1,"H");
   Lcd_Out(2,1,"T");
   PIE1=0x20;
   INTCON=0xC0;
   while (1)
   {
      error=FALSE;
      error+=s_measure((unsigned char*) &h_raw,HUMI);  //measure humidity
      error+=s_measure((unsigned char*) &t_raw,TEMP);  //measure temperature
      if(error) s_connectionreset();
      else
      {
         Write_Int(h_raw);
         Write_Int(t_raw);
         h_val=h_raw;
         t_val=t_raw;
         calc_sth11(&h_val,&t_val,cal);            //calculate humidity, temperature
         Write_Float(h_val);
         Write_Float(t_val);
         Write_LCD(1,2,h_val);
         Write_LCD(2,2,t_val);

      }
      if (in_stop==TRUE)                            //interpret commands
      {
         Command(cal);
         for(i=0;i<16;i++) in_string[i]='\0';        //clear string and flags
         in_stop=FALSE;
         in_i=0;
      }
      delay_ms(1000); // to be changed to timer interrupt
      
   }
}

barbarossa
Posts: 37
Joined: 25 Jan 2007 14:18
Location: Sweden, Tågarp

#3 Post by barbarossa » 11 Jul 2009 21:29

by the way

Are you using the default pin config for the LCD?


quote from your initlcd function:

Code: Select all

  //Lcd_Config(&PORTD, 0, 1, 7, 5, 4, 3, 2);
  Lcd_Init(&PORTD); 

dariush_abbasi
Posts: 120
Joined: 11 May 2008 18:47

#4 Post by dariush_abbasi » 12 Jul 2009 07:48

Hi.
Thanks a lot barbarossa for your help.
Yes,i have used the default configuration for LCD not as comment,and my LCD works properly without some part of code and when i add those parts my LCD malfunction.
I am using 18f452 with 8M clock.Do you think that your code works with my chip and clock as well?
I'll check your code.
I have been using the DS18B20 for my temperature controller and its resolution is almost 0.1f and its accuracy is good.
Do you think is it worth to venture into SHT75?because you said that its accuracy is not that much good!
Again thanks a lot for your reply and help.

dariush_abbasi
Posts: 120
Joined: 11 May 2008 18:47

#5 Post by dariush_abbasi » 12 Jul 2009 08:52

Hi.
I don't know why my compiler(Mikroc PRO 1.65)doesn't compile the following two lines:

Code: Select all

   ANSEL = 0;
   ANSELH = 0;
and says:
Undeclared identifier 'ANSEL' in expression
Undeclared identifier 'ANSELH' in expression

barbarossa
Posts: 37
Joined: 25 Jan 2007 14:18
Location: Sweden, Tågarp

#6 Post by barbarossa » 12 Jul 2009 11:10

There are a few differences between PIC16 and PIC18. The ANSEL register is one of them.

I forgot to mention that, instead of bit banging the port bits I bit bang the tris bits in my code. For PIC18, bit banging is different than PIC16. Use the lat register for write and port for read, unless you do like I and bit bang the tris reg..

The advantage of the SHT** over the Honeywell HIH4000 is that the SHT** is digital, so you don't have to worry about analog design. On the other hand Sensirion uses a non-standard protocol, so it requires more work.

I guess you can get an accuracy below 1% if you calibrate the sensor and that goes for both the HIH4000 and the SHT**. Uncalibrated, you have to settle for ~3% accuracy.

It really depends on required accuracy, amount of money and amount of time. If you need better than 1% accuracy you must have a dew point sensor, which costs $5000. On the other hand it is factory calibrated on delivery. Second choice of RH sensor is a Hygroclip S from Rotronic with 1% accuracy, which is $200. Third choice is SHT*5 or HIH4000 and I think you can achieve <1% accuracy if you calibrate them.

dariush_abbasi
Posts: 120
Joined: 11 May 2008 18:47

#7 Post by dariush_abbasi » 12 Jul 2009 11:26

So how should i change your code for my 18f452?
thanks in advance.

barbarossa
Posts: 37
Joined: 25 Jan 2007 14:18
Location: Sweden, Tågarp

#8 Post by barbarossa » 12 Jul 2009 13:37

definition of SCK_T, DATA_T, DATA_P, LCD configuration and the register settings in main

barbarossa
Posts: 37
Joined: 25 Jan 2007 14:18
Location: Sweden, Tågarp

#9 Post by barbarossa » 12 Jul 2009 13:41

Eeprom library might need a word for address instad of byte.

dariush_abbasi
Posts: 120
Joined: 11 May 2008 18:47

#10 Post by dariush_abbasi » 18 Jul 2009 20:34

Hi.
I couldn't compile your code even with 16f series,so I'm using keil compiler with 89s52 and its accuracy is good.
I still don't know what is wrong with my code in Mikroc??!!

barbarossa
Posts: 37
Joined: 25 Jan 2007 14:18
Location: Sweden, Tågarp

#11 Post by barbarossa » 18 Jul 2009 21:33

My code is for MikroC Pro.

//A

dariush_abbasi
Posts: 120
Joined: 11 May 2008 18:47

#12 Post by dariush_abbasi » 19 Jul 2009 04:31

Yes,I'm using Mikroc Pro as well.
Thanks again and again for your help and replies.
Last edited by dariush_abbasi on 19 Jul 2009 04:53, edited 1 time in total.

dariush_abbasi
Posts: 120
Joined: 11 May 2008 18:47

#13 Post by dariush_abbasi » 19 Jul 2009 04:52

Your code is just compiled with 16f690.
Would you please change it for 18f452?because i don't have access to that chip and i can't do it myself.
My sincere gratitude to you.

barbarossa
Posts: 37
Joined: 25 Jan 2007 14:18
Location: Sweden, Tågarp

#14 Post by barbarossa » 19 Jul 2009 12:43

Well, I am not going to do that, but I may be able to help you if you make an effort of defining your problem.

Post your MikroC Pro code.

dariush_abbasi
Posts: 120
Joined: 11 May 2008 18:47

#15 Post by dariush_abbasi » 19 Jul 2009 19:24

Thanks a lot my dear friend.
I'm going to use 89s52 instead of PIC because Mikroc bothers me a lot.
Again thanks a lot for your precious time which you spent for me.
Be prosperous.

Post Reply

Return to “mikroC General”