Shop OBEX P1 Docs P2 Docs Learn Events
What's wrong with my SHT11? — Parallax Forums

What's wrong with my SHT11?

jmspaggijmspaggi Posts: 629
edited 2010-03-12 19:17 in General Discussion
Hi there,

I just installed a SHT11 sensor I bought few months ago and I'm receiving "strange" values.

rawTemp = 771
rawHumidity = 460
Celcius = -323
RelHumidity = 140
TcHumidity = 113

If I place it in a warmer place, I get higher value for the temp. If I place it in the fridge, I get lower value.

rawTemp = 12
rawHumidity = 800
Celcius = -399
RelHumidity = 266
TcHumidity = 218

The code is pretty straight forward.

            Sht11 sht11 = new Sht11(CPU.pin9, CPU.pin8);
            int rawTemp = sht11.rawTemp();
            int rawHumidity = sht11.rawHumidity();
            System.out.print("rawTemp = ");
            System.out.println(rawTemp);
            System.out.print("rawHumidity = ");
            System.out.println(rawHumidity);
            System.out.print("Celcius = ");
            System.out.println(sht11.celsius(rawTemp));
            System.out.print("RelHumidity = ");
            System.out.println(sht11.relHumidity(rawHumidity));
            System.out.print("TcHumidity = ");
            System.out.println(sht11.tcHumidity(sht11.celsius(rawTemp), rawHumidity, sht11.relHumidity(rawHumidity)));




I have install the resistor for the clock pin to Vss and there is no other components on those CPU.pinx.

The only thing is that sensor is at about 40 feet from the Javelin.

Any clue what the issue can be? If it's the distance, can I add delays everywhere on the code to make it slower?

Thanks,

JM

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-03-10 14:11
    If you use the Parallax SHT11 module (Parallax part #28018)
    then the resistors are already in the module.

    Have you tried the testprogram (or your own program)
    with the sensor close to the javelin?
    What results do you get then?

    regards peter
  • jmspaggijmspaggi Posts: 629
    edited 2010-03-10 14:41
    Hi Peter,

    So I removed all the resistors attached to the module, and moved it close to the Javelin with 20cm long only cables.

    Result:
    09:41:04
    rawTemp = 972
    rawHumidity = 540
    Celcius = -303
    RelHumidity = 171
    TcHumidity = 142

    But it's moving...
    09:42:36
    rawTemp = 2048
    rawHumidity = 194
    Celcius = -195
    RelHumidity = 38
    TcHumidity = 26

    I don't always get the same information.
    09:43:58
    rawTemp = 2177
    rawHumidity = 130
    Celcius = -182
    RelHumidity = 12
    TcHumidity = 3


    Are you sure the 3 resistors are build in?

    Based on this document, we still need to add on 4.7K resistor. http://www.parallax.com/Portals/0/Downloads/docs/prod/acc/SensirionDocs.pdf
  • jmspaggijmspaggi Posts: 629
    edited 2010-03-10 17:09
    Hi Peter,

    I just did some test and found something strange.

    I have connected the SHT11 close to the javelin board, and it's working fine.

    BUT...

    If I keep the SHT11 connected to the javelin board, and I connect the line which is 40 feet long, it's not working anymore, even if there is nothing connected at the end of the 40 feet line.

    I verified the line, and there is nothing wrong with it. No short-circuit, everything is well.

    So it look like the line is generating some dirt on the signal which is why the sensor is failing.

    If I disconnect the line, SHT11 is working fine. As soon as I connect the line, not working anymore.

    So the issue is really there. It's only appenning with the data pin. Clock pin seems not to cause any issue.

    What can I do to reduce the noise on this line? Should I put some pull-up or pull-down on the SHT11 side (40 feet away)? Or on the javelin side?

    Any clue?

    Thanks,

    JM
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-03-10 18:40
    The long wire is picking up noise, that's for sure.
    You can try using shielded cable with the shield connected to GND.
    Since the data wire has a reletive high impedance it will always pickup
    noise. The shield hopefully eliminates most of the·noise.

    regards peter
  • jmspaggijmspaggi Posts: 629
    edited 2010-03-10 18:49
    Ok. I will try that. Will have to re-wire the 3 floors [noparse]:([/noparse] anyway, don't really have the choice.

    Thanks,

    JM
  • WBA ConsultingWBA Consulting Posts: 2,935
    edited 2010-03-11 00:12
    Sounds like you have a noise issue that is contaminating your results. If you look at the datasheet from Sensirion for the SHT11, you will see notes for a pullup for the data line and pulldown for the clock line which keep these signals cleaner at longer distances. Also, I am unfamiliar with the Javelin Stamp, so you may have propagation delay issues. Slowing down the clocking rate of the SHT11 will help with noise in any manner. The SHT11 can be clocked as slow as you want.

    Sensirion SHT11 page with datasheet:
    www.sensirion.com/en/01_humidity_sensors/02_humidity_sensor_sht11.htm

    Webpage for my SHT11 module that has the aformentioned resistors built-in:
    www.aestheticacoustics.com/sht11_01.htm
    I have used my module with 208 feet of Cat5 cable without issues.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andrew Williams
    WBA Consulting
    WBA-TH1M Sensirion SHT11 Module
    Special Olympics Polar Bear Plunge, Mar 20, 2010
  • jmspaggijmspaggi Posts: 629
    edited 2010-03-11 13:13
    Hi Andrew,

    Thanks for the feedback regarding the Cat5 cable.

    Parallas module already has one 4.7K resistors and one 330. If I'm still not able to make it works with the Cat5 cable, I will probably try your module.

    My other solution will be to add one Javelin to the 3rd floor, and an RS-485 connection between the 2, but that's way more expensive than the actual solution...

    I will keep the forum, posted.

    Thanks,

    JM
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-03-11 14:23
    Andrew may have a point. The sht11 class uses the CPU.shiftIn and CPU.shiftOut
    methods, which are native and they operate on 50kHz or so. Due to long cable
    (and therefore increased capacitance) that frequency may be·too high.

    Attached is a modified sht11 class that replaces the shiftIn and shiftOut methods
    by discrete writePin() methods, plus it adds a delay after each pin toggle.

    The new constructor is

    static sht11slow mySht11 = new sht11slow(datapin,clockpin,delay);

    delay is specified in milliseconds. You may want to to try this.

    The class goes into same folder as sht11.java

    regards peter
  • WBA ConsultingWBA Consulting Posts: 2,935
    edited 2010-03-11 17:06
    Excellent! I was actually right about something......

    As far as the Parallax SHT11 module, you can easily add the pulldown for the clock as shown on page one of the Parallax Datasheet.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andrew Williams
    WBA Consulting
    WBA-TH1M Sensirion SHT11 Module
    Special Olympics Polar Bear Plunge, Mar 20, 2010
  • jmspaggijmspaggi Posts: 629
    edited 2010-03-12 01:54
    Hi Peter,

    Thanks for the code.

    I'm getting an error when I try to compile.

    writeByte contains a constant out of range.

    How can I fix that?

    Thanks,

    JM
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-03-12 02:01
    Change the line
    ····· if ((data & 0x8000) != 0) CPU.writePin(datapin,true);
    into
    ····· if ((data & (short)0x8000) != 0) CPU.writePin(datapin,true);

    regards peter
  • jmspaggijmspaggi Posts: 629
    edited 2010-03-12 02:15
    Thanks for the prompt update.

    I pushed the new code, and it's strange, because I'm getting:

    rawTemp =6658
    rawHumidity =1219
    Celcius =266
    RelHumidity =412
    TcHumidity =413

    With 20cm or with 50 feet...

    I tried with 0, 10 and 100 for the delay.

    I will try with the previous class to see if that's the cause.

    JM
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-03-12 02:29
    Your reference is class sht11.java with short wires to the sensor.
    Whatever rawTemp that gives should also be given
    by class sht11slow.java with either short or long wires.

    If sht11slow.java gives a rawTemp that is much different
    then I probably made an error converting the shift methods.

    Edit: celsius = 266 means 26.6 degrees. That could be right
    if heater is on.

    regards peter
    ·
  • jmspaggijmspaggi Posts: 629
    edited 2010-03-12 03:16
    Hahaha!

    You're right! I forgot that I have to divide by 10... SHT11 heater is not on, but my fireplace is, and it's pretty warm at home...

    I placed a DS1620 as close as possible of the SHT11 to compare, and I have celius = 287 for the sht11 and celcius = 260 for the DS1620.

    It's not a big difference. The 2 sensors are about 10cm away. 3 celcius is realistic for the error, even if it's still to much for me.

    Also, I tried with and without the 50 feet wire and get the same result. That's a good news. I'm using 1 for the delay.

    Do you know which one of the DS1620 and SHT11 is the more accurate?

    Thanks again for your help.

    JM
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-03-12 03:32
    sht11
  • jmspaggijmspaggi Posts: 629
    edited 2010-03-12 19:17
    Perfect, thanks.

    After 1 night, the difference between the 2 sensors is still 2 to 3 degrees. (21.8 vs 23.8)

    That should be enought for my application.

    Thanks again for your help.

    JM
Sign In or Register to comment.