Application of digital temperature and humidity sensor SHT11 in 51 single chip microcomputer system

Publisher:美人如玉剑如虹Latest update time:2011-12-28 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Overview

The measurement of temperature and humidity is widely used in warehouse management, manufacturing, meteorological observation, scientific research and daily life. Traditional analog humidity sensors generally require the design of signal conditioning circuits and need to go through complex calibration and calibration processes. Therefore, the measurement accuracy is difficult to guarantee, and the linearity, repeatability, interchangeability, consistency and other aspects are often unsatisfactory. SHT11 is a new temperature and humidity sensor based on CMOSensTM technology launched by Swiss Sensiration. The sensor combines CMOS chip technology with sensor technology to give full play to their powerful complementary advantages.

2 Performance characteristics

The main features of the SHT11 temperature and humidity sensor are as follows:

●Integrate temperature and humidity sensor, signal amplification and conditioning, A/D conversion, and I2C bus interface into one chip (CMOSensTM technology);

●Can give full calibrated relative humidity and temperature output;

●With industrial standard I2C bus digital output interface;

●With dew point value calculation and output function;

●Excellent long-term stability;

●The output resolution of humidity value is 14 bits, the output resolution of temperature value is 12 bits, and can be programmed to 12 bits and 8 bits;

●Small size (7.65×5.08×23.5mm), surface mountable;

●It has reliable CRC data transmission verification function;

●The calibration coefficients loaded on the chip can ensure 100% interchangeability;

●The power supply voltage range is 2.4~5.5V;

●Current consumption: 550μA when measuring, 28μA on average, and 3μA when sleeping. The SHT11 temperature and humidity sensor adopts SMD (LCC) surface mount package, and the pin arrangement is shown in Figure 1. The pin description is as follows:

(1) GND: ground terminal;

(2) DATA: bidirectional serial data line;

(3) SCK: serial clock input;

(4) VDD power supply terminal: 0.4~5.5V power supply terminal;

(5-8) NC: empty pin.

3 Working principle

The humidity detection of SHT11 uses a capacitive structure, and adopts a "microstructure" detection electrode system with different protections and a polymer cover layer to form the capacitance of the sensor chip. In addition to maintaining the original characteristics of the capacitive humidity sensor, it can also resist the influence from the outside world. Because it combines the temperature sensor and the humidity sensor into a single entity, the measurement accuracy is high and the dew point can be accurately obtained. At the same time, there will be no error caused by the change of temperature gradient between the temperature and humidity sensors. CMOSensTM technology not only combines the temperature and humidity sensors together, but also integrates the signal amplifier, analog/digital converter, calibration data storage, standard I2C bus and other circuits into one chip. The internal structure block diagram of the SHT11 sensor is shown in Figure 2.

Each sensor of SHT11 is calibrated in an extremely accurate humidity chamber. The calibration coefficients of SHT11 sensors are pre-stored in OTP memory. The calibrated relative humidity and temperature sensors are connected to a 14-bit A/D converter, which can send the converted digital temperature and humidity values ​​to the two-wire I2C bus device, thereby converting the digital signal into a serial digital signal that complies with the I2C bus protocol.

Because the sensor and the circuit are combined together, the sensor has much better performance than other types of humidity sensors. First, the increase in sensor signal strength enhances the sensor's anti-interference performance and ensures the long-term stability of the sensor, while the simultaneous completion of A/D conversion reduces the sensor's sensitivity to interference noise. Secondly, the calibration data loaded in the sensor chip ensures that each humidity sensor has the same function, that is, it has 100% interchangeability. Finally, the sensor can be directly connected to any type of microprocessor or microcontroller system through the I2C bus, thereby reducing the hardware cost of the interface circuit and simplifying the interface method.

3.1 Output characteristics

(1) Humidity value output

SHT11 can directly output digital humidity value through I2C bus, and its relative humidity digital output characteristic curve is shown in Figure 3. As can be seen from Figure 3, the output characteristic of SHT11 is nonlinear to a certain extent. In order to compensate for the nonlinearity of the humidity sensor, the humidity value can be corrected according to the following formula:

RHlinear=c1+c2SORH+c3SORH2

Where SORH is the relative humidity measurement value of the sensor, and the coefficients are as follows:

12-bit: SORH: c1 = -4, c2 = 0.0405, c3 = -2.8 × 10-6

8-bit: SORH: c1 = -4, c2 = 0.648, c3 = -7.2 × 10-4

(2) Temperature value output

Since the linearity of the SHT11 temperature sensor is very good, the temperature digital output can be converted into the actual temperature value using the following formula:

T=d1+d2SOT

When the power supply voltage is 5V and the resolution of the temperature sensor is 14 bits, d1=-40?d2=0.01. When the resolution of the temperature sensor is 12 bits, d1=-40?d2=0.04.

(3) Dew point calculation

The dew point value of the air can be obtained based on the relative humidity and temperature values. The specific calculation formula is as follows:

LogEW=(0.66077+7.5T/(237.3+T)+[log10(RH)-2]

Dp=[(0.66077-logEW)×237.3]/(logEW-8.16077)

3.2 Command and Interface Timing

The SHT11 sensor has a total of 5 user commands. The specific command formats are listed in Table 1. The following introduces the specific command sequence and command timing.

Table 1 SHT11 sensor command list

Order Coding

illustrate

Measuring temperature 00011 Temperature measurement
Measuring humidity 00101 Humidity measurement
Read register status 00111 "Read" Status Register
Write register status 00110 "Write" Status Register
Soft Start 11110 Restart the chip, clear the error record of the status recorder, and enter the next command after 11 milliseconds

(1) Transmission starts

When initializing the transmission, the "transmission start" command should be issued first. This command can change DATA from high level to low level when SCK is high, and increase DATA when the next SCK is high.

The following command sequence contains three address bits (currently only supports "000") and five command bits. When the ACK bit of the DATA pin is at a low level, it means that SHT11 has received the command correctly.

(2) Connection reset sequence

If the communication with the SHT11 sensor is interrupted, the following signal sequence will reset the serial port: when the DATA line is at a high level, trigger SCK more than 9 times (including 9 times), and then send a "transmission start" command.

Table 2 SHT11 status register type and description

Bit type illustrate Default
7 reserve 0
6 read Industrial inspection limit (low voltage inspection) X
5 reserve 0
4 reserve 0
3 For testing only, not for use 0
2 Read/Write heating 0 close
1 Read/Write Do not re-download from OTP 0 Re-download
0 Read/Write '1' = 8-bit relative humidity, 12-bit temperature resolution. '0' = 12-bit relative humidity, 14-bit humidity resolution 0 12-bit relative humidity, 14-bit humidity

(3) Temperature and humidity measurement sequence

When the temperature (humidity) measurement command is issued, the controller will wait until the measurement is completed. The measurement takes about 11/55/210ms respectively with 8/12/14 bit resolution. To indicate that the measurement is completed, SHT11 will make the data line low. At this time, the controller must restart SCK and then transmit two bytes of measurement data and 1 byte of CRC checksum. The controller must confirm each byte by making DATA low. All quantities are counted from the right, with the MSB listed first. Communication stops after confirming the CRC data bit. If the CRC-8 checksum is not used, the controller will stop communication by keeping ack high after the measurement data LSB. SHT11 will automatically return to sleep mode after the measurement and communication are completed. It should be noted that in order to keep the temperature rise of SHT11 below 0.1℃, the operating frequency at this time cannot be greater than 15% of the calibration value (for example, at 12 bit accuracy, a maximum of 3 measurements per second). The timing corresponding to the temperature and humidity measurement commands is shown in Figure 4.



3.3 Register Configuration

Some advanced functions of the SHT11 sensor are implemented through the status register. The types and descriptions of each register bit are listed in Table 2. The following is a description of the functions of the relevant register bits:

(1) Heating

When the heating switch in the chip is turned on, the sensor temperature increases by about 5°C, which increases the power consumption to 8mA@5V. The heating purposes are as follows:

● By comparing the temperature and humidity before and after starting the heater, the function of the sensor can be correctly distinguished;

●In an environment with high relative humidity, the sensor can be heated to avoid condensation.

(2) Low voltage detection

When SHT11 is working, it can detect whether the VDD voltage is lower than 2.45V by itself with an accuracy of ±0.1V.

(3) Download calibration coefficients

To save energy and increase speed, OTP re-downloads calibration coefficients before each measurement, saving 8.2 ms for each measurement.

(4) Measurement resolution setting

Reducing the measurement resolution from 14 bits (temperature) and 12 bits (humidity) to 12 bits and 8 bits respectively can be applied to high-speed or low-power applications.

4 Application Notes

4.1 Operating conditions

Temperatures outside the measurement range will temporarily shift the humidity signal by +3%. The sensor will then slowly return to the calibration condition. If the chip is heated to 90°C for 24 hours in an environment with a humidity of less than 5%, the chip will quickly recover from the effects of the high relative humidity and high temperature environment. However, prolonged intensity conditions will accelerate chip aging.

4.2 Installation precautions

Since the relative humidity of the atmosphere is closely related to the temperature, the key point in measuring the atmospheric temperature is to keep the sensor at the same temperature as the atmosphere. If there are heating elements on the sensor circuit board, SHT11 should be well ventilated from the heat source. To reduce heat conduction between SHT11 and PCB, the copper wire should be as thin as possible and a narrow slit should be added in it. At the same time, the sensor should be avoided from being exposed to strong light or UV.

When the sensor is wired, if the SCK and DATA signals are parallel and close to each other, or if the signal line is longer than 10 cm, interference information will be generated. In this case, a VDD or GND should be placed between the two groups of signals

.

Figure 5 is the interface circuit between AT89C2051 microcontroller and SHT11. Since AT89C2051 does not have I2C bus interface, the general I/O port line of microcontroller is used to virtualize I2C bus, and P1.0 is used to virtualize data line DATA, and P1.1 port line is used to virtualize clock line, and a 4.7kΩ pull-up resistor is connected to the DATA terminal, and a 0.1μF decoupling capacitor is connected to the VDD and GND terminals. The following is the C51 application program matching the above hardware circuit.

#define DATA P1_1

#define SCK P1_0

#defineACK 1

#define noACK 0

#define MEASURE_TEMP 0x03 //Measure temperature command

#definition MEASURE_HUMI 0x05 //Humidity measurement command

//Read temperature and humidity data

char s-measure(unsigned char *pp- value, un-sign ed char *p_checksum, unsigned char mode)

{

unsigned char error=0;

unsigned int i;

s_transmission(); //Transmission starts

switch(mode){

case

TEMP: error + = s_write_byte(measure_temp);

break;

case

HUMI:error+=s_write_byte(measure_humi);break;

default:break;

}

for(i=0;i<65535;i++) if(DATA==0) break;

if (DATA) reeor+=1;

*(p_value)=s_read_byte(ACK);

*(p_value+1)=s_read_byte(ACK);

*p_checksum=s_read_byte(noACK);

return error;

}

// Temperature and humidity value scale conversion and temperature compensation

void calc_sth15(float *p_humidity, float *p_tem pera-true)

{

const float c1=-4.0;

const float c2=0.0405;

const float c3=-0.0000028;

const float t1=-0.01;

const float t2=0.00008;

float rh=×p_humidity;

float t=×p_temperature;

float rh_lin;

float th_ture;

float t_c;

t_c=t×0.01-40;

rh_lin=c3×rh×rh+c2×rh+c1;

trh_ture=(t_c-25)×(t1+t2×rh)+rh_lin;

×p_temperature=t-c;

×p_humidity=rh_ture;

}

//Calculate dew point from relative temperature and humidity

char calc_dewpoint(float h, float t)

{float logex,dew_point;

logex=0.66077+7.5×t/(237.3+t)+[log10(h)-2];

dew_point=(logex-0.66077)×237.3/(0.66077+7.5-logex);

return dew_point;

}

Due to space limitations , the above program does not include the functions for starting transmission, writing byte data, and reading byte data.

The SHT11 digital temperature and humidity sensor integrates the temperature sensor, humidity sensor, signal conditioning, analog/digital converter, calibration parameters and I2C bus interface into the sensor. Therefore, it not only improves the performance of the sensor, but also reduces the cost and size. It is also very convenient to interface with the microcontroller. It can be seen that this sensor is an ideal choice for temperature and humidity testing of embedded systems.

Reference address:Application of digital temperature and humidity sensor SHT11 in 51 single chip microcomputer system

Previous article:I2C bus data communication between MAX517 and 51 microcontroller
Next article:Comparison of Different Initializations between C8051F and 80C51 Series MCUs

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号