599 Menlo Drive, Suite 100
Rocklin, California 95765, USA
Office:
(916) 624-8333
Fax:
(916) 624-8003
General:
info@parallax.com
Technical:
support@parallax.com
Web Site:
www.parallax.com
Educational:
www.stampsinclass.com
Sensirion SHT11 Sensor Module (#28018)
Precision Temperature and Humidity Measurement
Introduction
When it comes to precision temperature and humidity measurement, Sensirion (www.sensirion.com) has
simplified the process their SHT1x sensor series. Through a two-wire serial interface, both temperature
and humidity can be read with excellent response time and accuracy. Parallax has simplified the use of
the SHT11 by mounting it in a user-friendly 8-pin DIP module. The module includes a data-line pull-up
and series limiter making it possible to connect directly to the BASIC or Javelin Stamp.
Features
•
•
•
•
•
Temperature range: -40 °F (-40 °C) to +254.9 °F (+123.8 °C)
Temp. accuracy: +/- 0.5 °C @ 25 °C
Humidity range: 0 to 100% RH
Absolute RH accuracy: +/- 3.5% RH
Low power consumption (typically 30 µW)
Connections
The SHT11 is interfaced to the Stamp over two I/O pins. The 4.7 kΩ pull-down resistor on the clock is
optional but may be required if your application experiences sensor lock-up.
Vdd
SHT11 Sensor Module
330
Ω
Data
1
4.7 kΩ
8
2
SHT11
7
Clock
3
6
4.7 kΩ
4
5
Vss
Vss
Parallax, Inc. • Sensirion SHT11 Sensor Module (#28018) • 07/2003
1
BASIC Stamp Application
The following BASIC Stamp application will read the SHT11 sensor module and display sensor counts,
converted temperature and calibrated humidity.
When running, the program output will appear as
shown below:
' =========================================================================
'
'
File...... SHT11_Demo.BS2
'
Purpose... Interface to Sensirion SHT11 temperature/humidity sensor
'
Author.... Parallax
'
E-mail.... support@parallax.com
'
Started...
'
Updated... 19 JUL 2003
'
'
{$STAMP BS2}
'
{$PBASIC 2.5}
'
' =========================================================================
' -------------------------------------------------------------------------
' Program Description
' -------------------------------------------------------------------------
'
Parallax, Inc. • Sensirion SHT11 Sensor Module (#28018) • 07/2003
2
'
'
'
'
'
'
'
'
'
'
'
'
This program demonstrates the interface and conversion of SHT11/15 data
to usable program values. This program uses advanced math features of
PBASIC, specifically the ** operator.
For detailed application information on the use and application of the
** operator, see Dr. Tracy Allen's web page at this link:
-- http://www.emesystems.com/BS2math1.htm
For SHT11/15 documentation and app notes, visit:
-- http://www.sensirion.com
' -------------------------------------------------------------------------
' Revision History
' -------------------------------------------------------------------------
' -------------------------------------------------------------------------
' I/O Definitions
' -------------------------------------------------------------------------
ShtData
Clock
PIN
PIN
1
0
' bi-directional data
' -------------------------------------------------------------------------
' Constants
' -------------------------------------------------------------------------
ShtTemp
ShtHumi
ShtStatW
ShtStatR
ShtReset
Ack
NoAck
No
Yes
DegSym
CON
CON
CON
CON
CON
CON
CON
CON
CON
CON
%00011
%00101
%00110
%00111
%11110
0
1
0
1
186
' degrees symbol for DEBUG
'
'
'
'
'
read temperature
read humidity
status register write
status register read
soft reset
' -------------------------------------------------------------------------
' Variables
' -------------------------------------------------------------------------
Parallax, Inc. • Sensirion SHT11 Sensor Module (#28018) • 07/2003
3
ioByte
ackBit
toDelay
timeOut
soT
tC
tF
soRH
rhLin
rhTrue
status
VAR
VAR
VAR
VAR
VAR
VAR
VAR
VAR
VAR
VAR
VAR
Byte
Bit
Byte
Bit
Word
Word
Word
Word
Word
Word
Byte
'
'
'
'
data from/to SHT11
ack/nak from/to SHT11
timeout delay timer
timeout status
' temp counts from SHT11
' temp - Celcius
' temp - Fahrenheit
' humidity counts
' humidity; linearized
' humidity; compensated
' status byte
' -------------------------------------------------------------------------
' EEPROM Data
' -------------------------------------------------------------------------
' -------------------------------------------------------------------------
' Initialization
' -------------------------------------------------------------------------
Initialize:
GOSUB SHT_Connection_Reset
PAUSE 250
DEBUG CLS,
"SHT11 Sensor Demo", CR,
"-----------------", CR
' reset device connection
' let DEBUG window open
' -------------------------------------------------------------------------
' Program Code
' -------------------------------------------------------------------------
Main:
DO
GOSUB SHT_Measure_Temp
DEBUG CRSRXY, 0, 3,
"soT...... ", DEC soT, CR,
"tC....... ", DEC (tC / 10), ".", DEC1 tC, DegSym, " ", CR,
"tF....... ", DEC (tF / 10), ".", DEC1 tF, DegSym, " "
GOSUB SHT_Measure_Humidity
DEBUG CRSRXY, 0, 7,
"soRH..... ", DEC soRH, CR,
Parallax, Inc. • Sensirion SHT11 Sensor Module (#28018) • 07/2003
4
"rhLin.... ", DEC (rhLin / 10), ".", DEC1 rhLin, "% ", CR,
"rhTrue... ", DEC (rhTrue / 10), ".", DEC1 rhTrue, "% "
PAUSE 1000
LOOP
END
' -------------------------------------------------------------------------
' Subroutines
' -------------------------------------------------------------------------
' connection reset: 9 clock cyles with ShtData high, then start sequence
'
SHT_Connection_Reset:
SHIFTOUT ShtData, Clock, LSBFirst, [$FFF\9]
' generates SHT11 "start" sequence
'
_____
_____
' ShtData
|_______|
'
___
___
' Clock
___|
|___|
|___
'
SHT_Start:
INPUT ShtData
LOW Clock
HIGH Clock
LOW ShtData
LOW Clock
HIGH Clock
INPUT ShtData
LOW Clock
RETURN
' let pull-up take high
' measure temperature
' -- celcius = raw * 0.01 - 40
' -- fahrenheit = raw * 0.018 - 40
'
SHT_Measure_Temp:
GOSUB SHT_Start
ioByte = ShtTemp
GOSUB SHT_Write_Byte
GOSUB SHT_Wait
ackBit = Ack
GOSUB SHT_Read_Byte
soT.HighByte = ioByte
ackBit = NoAck
GOSUB SHT_Read_Byte
'
'
'
'
'
'
alert device
temperature command
send command
wait for measurement
another read follows
get MSB
' last read
' get LSB
Parallax, Inc. • Sensirion SHT11 Sensor Module (#28018) • 07/2003
5