View Full Version : Temp/Humidity Sensorhelp needed.
11-05-2009, 01: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.
11-05-2009, 02: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.
11-05-2009, 03: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.
11-05-2009, 03: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.
11-06-2009, 03:13 AM
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.
11-06-2009, 03: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?
11-06-2009, 09: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.
11-06-2009, 09: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?
DEBUG "SHT1x heater on", CR
status = %00000100 ' heater bit = On
DEBUG "Waiting 2 seconds", CR
DEBUG "SHT1x heater off", CR, CR
status = %00000000 ' heater bit = Off
DEBUG "tF...... "
DEBUG DEC (tF / 10), ".", DEC1 tF, DegSym, ClrRt, CR
DEBUG "rhLin... "
DEBUG DEC (rhLin / 10), ".", DEC1 rhLin, "%", ClrRt, CR, CR
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.
11-07-2009, 01: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
My SHT11 Module thread with testing code that reads two sensors and compares for pass/fail
My BS2p40 based SHT11 memory stick datalogger
SHT11 with Propeller and uSD card
And of course, see the link in my signature for my SHT11 module webpage and click on the code examples link.
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)
11-07-2009, 01:46 AM
Thanks. I appreciate the help.