Pages: 1 [2] 3   Go Down
Author Topic: Sensirion Temp/Humidity sensor library help  (Read 9133 times)
0 Members and 1 Guest are viewing this topic.
Tokyo, Japan
Offline Offline
Jr. Member
**
Karma: 0
Posts: 91
Trackballer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think you are using arduino IDE 0016 or older.
And it's very likely that you didn't remove the Sensirion.o file after the modification.
Please remove it and re-verify.

The latest IDE 0017 fixed this kind of problem.
Quote
* Libraries are now compiled with the sketch, eliminating the delay when
  switching boards and the need to delete .o files when changing library
  source code.
http://arduino.cc/en/Main/ReleaseNotes
Logged

0
Offline Offline
Full Member
***
Karma: 1
Posts: 140
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Everything works fine now and "Yes" I used the Version 16.

Thanks fr your help: [smiley=dankk2.gif]
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 200
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
When you connect the SHT-xx to arduino via a short cable(about 10cm), the library works fine.
But if you hook up the sensor with very long cable, you will get corrupted data.
The reason is that, the default clock pulse width is too short for the long cable.
If you connect the Sensirion recommended resistors and capacitors this problem should be elminated.
Logged

Adelaide, Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can someone post their working code..??
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, amigos míos

I suggest you going to a post in Spanish where you can find my code: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1246400334

It's tested and works good. There are TWO parts of code, both are needed, just copy&paste together. There are several lines that are for another sensors, but there's no need to delete anything if you don't want to. It's not a library, it's just a set of functions, .. but who cares?

Regards
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 200
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Can someone post their working code?
A working code library has already been published at http://github.com/practicalarduino/SHT1x/
Use the example provided.
Logged

Marche
Offline Offline
Edison Member
*
Karma: 33
Posts: 2265
azioni semplici per risultati complessi
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

Quote
  #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()
{
  RTC.stop();
  RTC.set(DS1307_SEC,1);
  RTC.set(DS1307_MIN,59);
  RTC.set(DS1307_HR,22);
  RTC.set(DS1307_DOW,2);
  RTC.set(DS1307_DATE,18);
  RTC.set(DS1307_MTH,2);
  RTC.set(DS1307_YR,9);
  RTC.start();
  lcd.begin(16,2);
  lcd.clear();
}

  void loop()

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





Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 200
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Marche
Offline Offline
Edison Member
*
Karma: 33
Posts: 2265
azioni semplici per risultati complessi
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Full Member
***
Karma: 1
Posts: 200
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You should also run the SHT11 code on its own.

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

Marche
Offline Offline
Edison Member
*
Karma: 33
Posts: 2265
azioni semplici per risultati complessi
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, I use that library and I've tried to follow the example sketch. On their own they work fine, the problem happens when I try to combine both scripts. By using the script posted above, I've seen that if I comment the delays in the SHT1x.cpp file included in the library, the problem of the seconds seems disappeared but the sensor doesn't return values. Any ideas to make SHT11 and RTC work together?
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 200
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

At least now you have determined that each work in isolation, but not together. I tend to think it's a conflict between timers used in both applications/tasks.

Sounds like you are familiar with C Code, so I'd suggest looking at the timer code in each & working out why they conflict.

I could have a similar problem soon, when I have to combine code for a DS18B20, LCD display, and SHT15 all into the same application, so I'd appreciate you looking more at your problem.

Edit: The DS18B20 & SHT15 code is working! - will add LCD stuff asap.
« Last Edit: October 04, 2009, 12:41:42 am by novice » Logged

Marche
Offline Offline
Edison Member
*
Karma: 33
Posts: 2265
azioni semplici per risultati complessi
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Unfortunately I'm not so good with programming, I don't know what I have to do to modify the library (and if this is the right way to solve the problem).
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everybody,

I'm not so good in electronic (and in English !!).

After some issue with my SHT11 and Arduino Duemilanove, I finally found a way to be successfull.

First of all, with my oscilloscope I see that clock pin have less voltage than data pin ?

It seems that built-in AVR pull-up resistance was enabled on my clock pin and not on my data pin (probably due to previous testing).

So, I have change contructor to disable it on both :

Code:
Sensirion::Sensirion(uint8_t data, uint8_t clock)
{
  // Pins for software SPI
  _pinData = data;
  _pinClock = clock;
  
  pinMode(_pinData, INPUT);           // set pin to input
  digitalWrite(_pinData, LOW);        // turn off pullup resistors
  pinMode(_pinClock, INPUT);          // set pin to input
  digitalWrite(_pinClock, LOW);       // turn off pullup resistors
  
  // set DDR for software SPI pins
  pinMode(_pinClock, OUTPUT);
  pinMode(_pinData, OUTPUT);
  
  softReset();
}

Is it make sense ?

After, I have see in this thread that we have to use 3.3v power instead of 5v. I have connected vdd on 3.3v pin. But in this case, the data pin
and clock pin continue to use 5v, no ?

Because, very often the measure function returned 1 (communication error), I have inserted a resistance (330 ohm) on clock and data pin to reduce voltage.

And now, all works fine (without pull-up resistance on data pin).

Code:
Result : 0
Temperature: 28.54 C, Humidity: 53.3 %, Dewpoint: 18.4 C
Result : 0
Temperature: 28.54 C, Humidity: 53.3 %, Dewpoint: 18.4 C
Result : 0
Temperature: 28.55 C, Humidity: 53.3 %, Dewpoint: 18.5 C
Result : 0
Temperature: 28.55 C, Humidity: 52.97 %, Dewpoint: 18.3 C
Result : 0
Temperature: 28.55 C, Humidity: 52.97 %, Dewpoint: 18.3 C
Result : 0
Temperature: 28.55 C, Humidity: 52.97 %, Dewpoint: 18.3 C
Result : 0
Temperature: 28.55 C, Humidity: 53.0 %, Dewpoint: 18.4 C
Result : 0
Temperature: 28.58 C, Humidity: 52.97 %, Dewpoint: 18.5 C

Is it make sense ?

Best regards,
Pascal
Logged

UK
Offline Offline
Sr. Member
****
Karma: 1
Posts: 278
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just a quick note to say thanks for the help posted here, especially tasasaki who cracked the resolution issue which had me foxed for quite some time  smiley

I have this all working nicely now on a Seeeduino Stalker data logger and have posted a small write up along with the Arduino Sketch:

http://www.airsensor.co.uk/component/zoo/item/temperature-humidity-logger.html
Logged

Pages: 1 [2] 3   Go Up
Jump to: