Shop OBEX P1 Docs P2 Docs Learn Events
Temp/Humidity Sensorhelp needed. — Parallax Forums

Temp/Humidity Sensorhelp needed.

NWUpgradesNWUpgrades Posts: 292
edited 2009-11-06 17:46 in BASIC Stamp
Could someone take a look at the attached code and tell me what if anything needs to be changed to make the Sensirion temp/humidity sensor to make it work with a BS2sx,· other than the stamp directive? I have tried this with and without the resistor, and all I get is the debug showing temp and humidity are 0. Thanks if you can help.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-04 18:37
    There's nothing that I can see in the program that should make any significant difference other than the need to have the proper Stamp directive for the BS2sx. There's nothing that uses Stamp-specific timing constants although everything would run faster using a BS2sx. Perhaps there's something wrong with how you have things wired? Go through your wiring and make up a schematic (showing what you actually have, not what you think you should have), then post that.
  • NWUpgradesNWUpgrades Posts: 292
    edited 2009-11-04 19:26
    I got it!!! Thanks Mike. Some times it helps to triple and quadruple check my work. The wire for Pin 8 was 1 slot off. All is well. Thanks again.
  • NWUpgradesNWUpgrades Posts: 292
    edited 2009-11-04 19:47
    Mike, Could you take a look at the attached code and let me know where I can place the IF THEN statement that I have on line 219? I thought this was the correct location, but the FREQOUT is constant. If there is an easier way then I way to do this I would be happy to use it. Basically what I want to do is send a signal when the temp reaches a certain point. This is for my Robotic Leg project and I want to monitor the temp and humidity to avoid any elctronic failures.
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2009-11-05 19:13
    NWU,

    You have,
    IF tF > 100  THEN ...
    



    That sets the threshold at 10.0 degrees Fahrenheit, because tF is in units of 0.1 degree. I'd guess you want tF>1000 for 100 degrees.

    Note also that the program wll have to take additional steps if there is a chance that the temperature will go below zero degrees Fahrenheit.
    .

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • NWUpgradesNWUpgrades Posts: 292
    edited 2009-11-05 19:25
    Aha!!! Great. That helps dramatically. There is no chance that it would go below zero, so no worries there. I used 100 just for a start point. There should not even be a chance of it getting to that. Another issue I have though is that I connected 4 wires to the sensor so it is not on the proto bread board. The temp is showing as between 73.2 and 73.6 degrees. Problem is that it is only 67 degrees in my house. Any idea on wht this would happen? Also, is there possibly a way to shorten the code in this program to keep it from taking up so much space?
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2009-11-06 01:10
    There is a lot you can do to shorten the program.

    -- Remove the code section starting with the label Sensor_Demo:, up to but not including PAUSE 5000 before label Main:. This demo code is probably superfluous.

    -- In the Main: routine, once things are working, you can get rid of the display of soT and soRH, and rhLin, and only display the final temperature (either F or C) and humidity.

    -- Delete the entire subroutines, SHT_Write_Status and SHT_Read_Status and SHT_Soft_Reset. They are not called.

    The above changes should free up quite a few bytes. It appears you are using a BS2sx, which has eight program slots available, but the current program only uses slot zero. It is a slightly more advanced technique, but you can recast the low level routines to return the temperature and humidity as a cross-slot call. That would free up even more code for your main loop. Also, cross slot calls are good for separating initialization and menu code from the main loop code.

    As to the higher than expected temperature readings, I don't know. The Sensor_Demo routine turns the internal heater on for a few seconds, but then turns it back off (off is the default). You can experiment with leaving it on. Are you sure the room temperature is 67? Radiant heat sources and gradients from floor to ceiling can have quite a strong effect.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • NWUpgradesNWUpgrades Posts: 292
    edited 2009-11-06 01:29
    Thanks for explaining this. I was just getting ready to post another question regarding the heater. What is it used for and do I need to use this code?

    Heater_On:
    DEBUG "SHT1x heater on", CR
    status = %00000100 ' heater bit = On
    GOSUB SHT_Write_Status
    DEBUG "Waiting 2 seconds", CR
    PAUSE 2000

    Heater_Off:
    DEBUG "SHT1x heater off", CR, CR
    status = %00000000 ' heater bit = Off
    GOSUB SHT_Write_Status

    GOSUB SHT_Measure_Temp
    DEBUG "tF...... "
    DEBUG DEC (tF / 10), ".", DEC1 tF, DegSym, ClrRt, CR

    GOSUB SHT_Measure_Humidity
    DEBUG "rhLin... "
    DEBUG DEC (rhLin / 10), ".", DEC1 rhLin, "%", ClrRt, CR, CR

    PAUSE 5000

    Also, The temp in my office is 67 degrees constant, verified by both the thermostat and an external thermometer. I think the issue may have to do with the sensor heater. Thanks for the help.
  • WBA ConsultingWBA Consulting Posts: 2,934
    edited 2009-11-06 17:30
    Here's a few links of my history with playing around with the SHT11/SHT15. Maybe something on one of them will be helpful.

    BS2 thread about reading multiple sensors. Some code attached is streamlined for SHT11 usage
    http://forums.parallax.com/showthread.php?p=826300

    My SHT11 Module thread with testing code that reads two sensors and compares for pass/fail
    http://forums.parallax.com/showthread.php?p=690671

    My BS2p40 based SHT11 memory stick datalogger
    http://forums.parallax.com/showthread.php?p=792332

    SHT11 with Propeller and uSD card
    http://forums.parallax.com/showthread.php?p=843250

    And of course, see the link in my signature for my SHT11 module webpage and click on the code examples link.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andrew Williams
    WBA Consulting
    WBA-TH1M Sensirion SHT11 Module
    Special Olympics Polar Bear Plunge, Mar 20, 2010
  • NWUpgradesNWUpgrades Posts: 292
    edited 2009-11-06 17:46
    Thanks. I appreciate the help.
Sign In or Register to comment.