PDA

View Full Version : Temp/Humidity Sensorhelp needed.



NWUpgrades
11-05-2009, 12:47 AM
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.

Mike Green
11-05-2009, 01:37 AM
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.

NWUpgrades
11-05-2009, 02:26 AM
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.

NWUpgrades
11-05-2009, 02:47 AM
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 Allen
11-06-2009, 02:13 AM
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 (http://www.emesystems.com)

NWUpgrades
11-06-2009, 02:25 AM
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 Allen
11-06-2009, 08:10 AM
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 (http://www.emesystems.com)

NWUpgrades
11-06-2009, 08:29 AM
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 Consulting
11-07-2009, 12:30 AM
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 (http://www.aestheticacoustics.com/sht11_01.htm)
Special Olympics Polar Bear Plunge, Mar 20, 2010 (http://www.kintera.org/faf/donorReg/donorPledge.asp?ievent=322002&lis=1&kntae322002=BDAEE98623FB443591C072E356710D6B&supId=265642883)

NWUpgrades
11-07-2009, 12:46 AM
Thanks. I appreciate the help.