Sensirion / Prop Proto eratic temp / humidity readings fluctuating
TinkerGeek
Posts: 7
Hi,
I'm trying to run my first tests on the Sensirion SHT11 temp/humidity sensor on my Propeller Proto USB board. When I run the SensirionDemoFull.spin object, and I view the the results in the ParallaxSerialTerminal, I get three lines of incorrect readings followed by one correct. This behavior repeats. As you can see below, I keep my office nice and toasty at 73 deg F and the humidity is around 28% so I think these are right, but where is the -11.2 degrees and -.8% humidity coming from?
MSG,Sensirion SHT-11 Demo
Temp_raw, RH_raw, TC_float, TF_float, RH_float, DewPtC_float, DewPtF_float, TF_fixpt, RH_fixpt, status_byte
CLEARDATA
DATA, 6282, 853, 23.1, 73.6, 28.0%, 3.6, 38.4, 73, 27, 00000000,
DATA, 6288, 852, 23.2, 73.7, 27.9%, 3.6, 38.5, 73, 27, 00000000,
DATA, 1572, 54,-24.0,-11.2, -0.8%, 0.0, 0.0, 73, 28, 00000011,
DATA, 1572, 54,-24.0,-11.2, -0.8%, 0.0, 0.0, 73, 28, 00000011,
DATA, 1572, 54,-24.0,-11.2, -0.8%, 0.0, 0.0, 73, 28, 00000011,
DATA, 6289, 853, 23.2, 73.7, 28.0%, 3.6, 38.5, 73, 27, 00000000,
DATA, 1573, 54,-24.0,-11.1, -0.8%, 0.0, 0.0, 73, 27, 00000011,
DATA, 1572, 53,-24.0,-11.2, -0.8%, 0.0, 0.0, 73, 28, 00000011,
DATA, 1572, 54,-24.0,-11.2, -0.8%, 0.0, 0.0, 73, 28, 00000011,
DATA, 6292, 852, 23.2, 73.8, 27.9%, 3.6, 38.6, 73, 27, 00000000,
Thanks for any help.
-Roger
I'm trying to run my first tests on the Sensirion SHT11 temp/humidity sensor on my Propeller Proto USB board. When I run the SensirionDemoFull.spin object, and I view the the results in the ParallaxSerialTerminal, I get three lines of incorrect readings followed by one correct. This behavior repeats. As you can see below, I keep my office nice and toasty at 73 deg F and the humidity is around 28% so I think these are right, but where is the -11.2 degrees and -.8% humidity coming from?
MSG,Sensirion SHT-11 Demo
Temp_raw, RH_raw, TC_float, TF_float, RH_float, DewPtC_float, DewPtF_float, TF_fixpt, RH_fixpt, status_byte
CLEARDATA
DATA, 6282, 853, 23.1, 73.6, 28.0%, 3.6, 38.4, 73, 27, 00000000,
DATA, 6288, 852, 23.2, 73.7, 27.9%, 3.6, 38.5, 73, 27, 00000000,
DATA, 1572, 54,-24.0,-11.2, -0.8%, 0.0, 0.0, 73, 28, 00000011,
DATA, 1572, 54,-24.0,-11.2, -0.8%, 0.0, 0.0, 73, 28, 00000011,
DATA, 1572, 54,-24.0,-11.2, -0.8%, 0.0, 0.0, 73, 28, 00000011,
DATA, 6289, 853, 23.2, 73.7, 28.0%, 3.6, 38.5, 73, 27, 00000000,
DATA, 1573, 54,-24.0,-11.1, -0.8%, 0.0, 0.0, 73, 27, 00000011,
DATA, 1572, 53,-24.0,-11.2, -0.8%, 0.0, 0.0, 73, 28, 00000011,
DATA, 1572, 54,-24.0,-11.2, -0.8%, 0.0, 0.0, 73, 28, 00000011,
DATA, 6292, 852, 23.2, 73.8, 27.9%, 3.6, 38.6, 73, 27, 00000000,
Thanks for any help.
-Roger
Comments
While I won't be much help technically I would suggest that you post your program code for others to digest and decipher. We used the same sensor on a BOE with a Basic stamp and other friends on the forum were really helpful.
I suspect that since you're getting a valid reading every fourth line the problem may simply be in the program code and not a wiring problem. Otherwise you wouldn't get any good reading at all. The fact that there's a repeating pattern in your readings supports my suspicions.
I really don't write program code all that well but I'm pretty sure that if you post your code, someone will help you figure it out. Good luck and please keep us all posted.
Regards,
Mark
ARLISS Team New Hampshire
:cool:
I am using the code from the object exchange without modifications. It can be found here: http://obex.parallax.com/objects/637/
Thanks,
Roger
Thanks for the reply. I work as a .net developer but am VERY green when it comes to micro controllers. I'm still trying to learn spin. I tried un-commenting line 85 but I'm still getting the bad values.
I did find a workaround though. I noticed that the last term in the output is the Status Byte. All of the bad lines has a status of 00000011 .... and all the good lines ends in 00000000. So I made an if statement so that I can grab good values only. I forgot to mention that my goal is to output the temp and humidity to an LCD. So my if loop only sends good values to LCD when it sees status of 00000000. See the code below. (If there is a better way to structure this PLEASE let me know)
Thanks,
Roger
PUB main | count,tmp,rawTemp, rawHumidity, tempC, rh, dewC, TF_fp, RH_fp
LCD.Init( E, RS, RW, DBHigh, DBLow )
LCD.usDelay( 5_000_000 ) ' time enough to switch to PST
serial.start(31, 30, 0, 9600) 'start(rxpin, txpin, mode, baudrate)
serial.rxFlush
'term.start(31, 30, 0, 115200)
f.start ' start floating point object
sht.start(SHT_DATA, SHT_CLOCK) ' start sensirion object
waitcnt(clkfreq*3+cnt)
sht.config(33,sht#off,sht#yes,sht#hires) 'configure SHT-11
'term.tx(CLS)
' read SHT-11 sensor and update (note: need to set baud to 57K if want output data to PLX-DAQ)
LCD.RawSetPos( $00 ) ' "first" line
LCD.PrintStr(String("Sensirion SHT-11",10,13))
LCD.usDelay( 2_000_000 )
repeat
'term.Str(String("DATA,"))
rawTemp := f.FFloat(sht.readTemperature)
rawHumidity := f.FFloat(sht.readHumidity)
tempC := celsius(rawTemp)
'term.str(fp.FloatToFormat(fahrenheit(tempC), 5, 1))
'term.str(string("F,"))
rh := humidity(tempC, rawHumidity)
'term.str(fp.FloatToFormat(rh, 5, 1))
'term.str(string("%, "))
dewC := dewpoint(tempC, rh)
TF_fp:=sht.getTemperatureF
RH_fp:=sht.getHumidity
status:=sht.readStatus
'term.str(string(13))
if sht.readStatus==00000000
LCD.CLEAR
LCD.RawSetPos( $00 ) ' "first" line
LCD.PrintStr( string("TEMP:"))
LCD.PrintStr(fp.FloatToFormat(fahrenheit(tempC), 5, 1))
LCD.PrintStr( string("F") )
LCD.RawSetPos( $40 ) ' "second" line
LCD.PrintStr( string("REL HUM:") )
LCD.PrintStr(fp.FloatToFormat(rh, 5, 1))
LCD.PrintStr(string("%"))
LCD.usDelay( 2_000_000 )
if count//4 'toggle every 4 cycles
sht.config(33,sht#off,sht#no,sht#lores) '3 fast, loRes measurements
else
sht.config(33,sht#off,sht#yes,sht#hires) '1 slow, hiRes measurement
count++
' waitcnt (clkfreq*2+cnt) 'display every 2 seconds
http://forums.parallax.com/showthread.php?123805-Sensirion-SHT-11-driver-and-reference-circuit
I haven't looked closely, but it appears that you have adopted the demo ("SensirionDemo_full"), not just the object ("Sensirion_full").
In the demo, you will find this code, which is what makes it print out 4 records, 3 ostensibly at low resolution and 1 at high resolution. I suggest you jettison the three and keep the one.
After issuing a measurement command (‘00000101’ for
relative humidity, ‘00000011’ for temperature) the
controller has to wait for the measurement to complete.
This takes a maximum of 20/80/320 ms for a 8/12/14bit
measurement. The time varies with the speed of the
internal oscillator and can be lower by up to 30%. To
signal the completion of a measurement, the SHT1x pulls
data line low and enters Idle Mode. The controller must
wait for this Data Ready signal before restarting SCK to
readout the data. Measurement data is stored until
readout, therefore the controller can continue with other
tasks and readout at its convenience.
So, if your status byte is 00000000 then the device is idle and you are able to get a valid reading.
Now this is a stupid question... but I would like to post an improved code snipet but I can't figure out how to put it in a "code" window like you did.
Can you tell me or point me to the doc that explains it?
Thanks!
Roger
[ CODE]sht.config(33,sht#off,sht#yes,sht#hires) '1 slow, hiRes measurement[ /CODE]
The system interprets this as a formatting command and displays it like this:
Here is a version from the OBEX with almost 2000 downloads that may or may not provide more desirable results.
http://obex.parallax.com/objects/21/
As a secondary note, always double check your wiring, and make sure that the components are seated properly and have adequate connections.