Go Down

Topic: Sensirion Temp/Humidity sensor library help (Read 9 times) previous topic - next topic


Can someone post their working code?

A working code library has already been published at http://github.com/practicalarduino/SHT1x/
Use the example provided.


Hi all! I have a problem with a SHT11 sensor. I tell you my configuration: arduino duemilanove, a 2x16 lcd display, a DS1307 (RTC) and a SHT11 sensor. What I want to do is write the time given by the RTC in the first row of the display and in the second row I want to write the temperature and the humidity collected by the SHT11 sensor.  I wrote few lines of code and I saw that the time shown in the display is not accurate, in fact every minute it skips 5 or 6 seconds. I think it happens because in the library that I'm using there are some delays(). I thought so because in another project I had the same problem and I solved it changing the delay() function with millis(). In this case the delay() is in the library, not in the script, how could I fix this problem? I post a simplified version of the script I'm working on, I hope someone can help me, I'm a newbie and please excuse me if I've made some mistakes when i wrote this post, I'm italian. Here comes the script:


  #include <WProgram.h>
  #include <Wire.h>
  #include <DS1307.h>
  #include <LiquidCrystal.h>
  #include <SHT1x.h>
  #define dataPin  12
  #define clockPin 13
  SHT1x sht1x(dataPin, clockPin);
  float temp_c;
  float humidity;
  LiquidCrystal lcd(2,3,4,5,6,7,8);
  int rtc[7];
  void setup()

  void loop()

  temp_c = sht1x.readTemperatureC();
  humidity = sht1x.readHumidity();
  lcd.setCursor(0,0); // 1st row display
  lcd.print(rtc[2]); // hours
  lcd.print(rtc[1]); // minutes
  lcd.print(rtc[0]); // seconds
  lcd.setCursor(0,1); // 2nd row display
  lcd.print(" U=");


You've got 2 things running, the RTC & the Senirion.
Comment one out (the SHT11) & then see if the RTC works.

Use a process of elimination.


If I comment the SHT11 code, the time runs well.


You should also run the SHT11 code on its own.

Did you use the "working code library" I mentioned above?.

Go Up