I have been trying get the included example running but I dont get very far very quickly. I get this error when I try to compile the sample code without any mods:
C:\...\arduino-0012\hardware\cores\arduino/wiring.h:124: error: expected ',' or '...' before numeric constant
This is a bit over my head and would greatly appreciate any help.
I'm testing SimpleSensirion sketch with SHT71(almost the same as SHT11)
and having a problem concerned to resolution of temperature data.
I get sparse temperature data like the following:
Temperature: 24.0 C, Humidity: 34.44 %, Dewpoint: 7.37 C
Temperature: 26.55 C, Humidity: 43.42 %, Dewpoint: 13.11 C
Temperature: 29.11 C, Humidity: 52.14 %, Dewpoint: 18.30 C
Temperature: 29.11 C, Humidity: 52.14 %, Dewpoint: 18.30 C
Temperature: 26.55 C, Humidity: 34.67 %, Dewpoint: 9.71 C
Temperature: 26.55 C, Humidity: 34.67 %, Dewpoint: 9.71 C
Temperature: 26.55 C, Humidity: 25.56 %, Dewpoint: 5.25 C
Temperature: 26.55 C, Humidity: 25.56 %, Dewpoint: 5.25 C
Temperature: 26.55 C, Humidity: 25.56 %, Dewpoint: 5.25 C
Temperature: 24.0 C, Humidity: 25.38 %, Dewpoint: 2.99 C
It seems to me that the data has only 4 bit resolution...
I found another problem of the library and the answer.
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.
You can easily fix the problem by only modifying two lines in the library file.
at hardware/libraries/Sensirion/Sensirion.cpp file,
With this fix, I can get correct data with using a 40 meter cable! Probably I can use more long cables.
Though I have not found the best width of the pulse, 300 and 100 usec delay doesn't cause any problems.
note: You have to remove the old Sensirion.o file after the modification.
I've been using a program from Sparkfun(a Wiring program based on Maurice Ribbel's) without any problem with cable lenght of 2ft during the last couple of months.
Since I am a noobie, the program you have cited seems to me different from the above program.
In this case, I wish to know how should I change the code as you suggested in your code. http://wiring.org.co/learning/examples/SHT15sparkfun.html
I have inserted a portion of the program, which seems to me sort of relevant to the portion you have mentioned(which might or might not at all relevant)
--portion of code ---
[//commands for reading/sending data to a SHTx sensor
int shiftIn(int dataPin, int clockPin, int numBits) {
int ret = 0;
for (int i=0; i<numBits; ++i) {
digitalWrite(clockPin, HIGH);
//delay(10); not needed
ret = ret*2 + digitalRead(dataPin);
digitalWrite(clockPin, LOW);
}
return(ret);
}
You should insert delay commands after almost all the digitalWrite commands so that you can control the width of the pulses.
That is a bit troublesome job, I recommend that you try to use the library instead of modifying your code.
First of all, why not read the library file?
You can download the library from http://www.target23.de/data/Sensirion_20081128.zip.
I'm also playing with this sensor and have communication working fairly well. However, I occasionally get a problem where the temperature sensor returns 255 for one byte. I haven't implemented the CRC, but it is sending back FF for the CRC, so it seems like a data communication error.
I can't figure out the conditions that cause this behavior. Has anyone else had this happen?
I had the same problem with our sensor Sensirion, we couldn't read the second data word. We solved it like you by putting some delays in the original code. I don't know if you arrived to a definitive code, but if you want here is my code: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1246400334/10#10
NOTE: it's such a long code that I had to put it in 2 posts. Just copy&paste both parts in the same file.
It works 100% sure. It's in Spanish, but I don't think it's a problem to work with. Besides, I included some functions for dew point (rocio), real humidity and more..
REALLY IMPORTANT: don't forget the pull up resistance (view data sheet) connecting DATA and Vdd, because w/out it you won't be able to read the second word, getting worse accuracy.
Also important: I believe the sensor works better with Vdd = 5volt than 3.3, what do u think?
A question: I have checked that the first value is not true in the sense the Sensirion hasn't stabilized yet. Anyone has made some test to know the minimum milliseconds to wait (in the start up) to have real stable results from the beginning?????
If someone wants to make a good library, I'll be pleased, let me know.
PS: I hate ****ing Sensirion sensor. It took us several days to write a good code. I don't think it's logic to sell a sensor with such a estrange communication protocol without a good code made by the people inside Sensirion: "We won't do the code, all the geeks will make it in the 2.0 web.." it's really kind, really kind :-? :-? But I can say it works really really well (with a good code). However it's expensive. Before buying it, think about Sencera's humidity sensor + LM35 temperature sensor.
@tasasaki
I have the same issue with the resolution. But I cant get your code working to get the full resolution. I (G)edit the cpp file in hardware/libraries/ and saved the change.
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.
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.
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.
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?