Design of temperature and humidity measurement system based on SHT11 sensor

Publisher:HeavenlyWhisperLatest update time:2014-08-14 Source: eefocusKeywords:SHT11 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The intelligent temperature and humidity measurement system based on SHT11 temperature and humidity sensor and single-chip microcomputer technology is studied. The system uses SHT11 temperature and humidity sensor to collect temperature and humidity data in real time; at the same time, AT 89s52 single-chip microcomputer is used for data storage and calculation; and a temperature and humidity value detection system integrating multiple application functions is designed by expanding peripheral circuits. The system has the advantages of high measurement accuracy, strong reliability, small size, low cost, and easy operation.

With the application of new technologies to the field of temperature and humidity measurement, highly integrated, intelligent, high-precision and high-reliability integrated temperature and humidity detection sensors have begun to be used. As a new generation of high-performance intelligent sensors, SHT11 has broad application prospects. This design introduces the working principle of SHT11 temperature and humidity sensor, and discusses how to use single-chip microcomputer to process temperature and humidity data and combine peripheral circuits to complete temperature and humidity monitoring and control functions.

1 Sensor working principle

The structure of SHT11 intelligent temperature and humidity sensor is shown in Figure 1. The sensor consists of a hybrid sensor module for detecting relative humidity and temperature and a calibrated digital output. The two-wire serial interface and internal voltage automatic adjustment make it convenient and fast system integration.

 


Figure 1 Sensor internal structure

 

The advantages of the SHT11 series sensors are: no external analog electronic circuit is required, and they can be directly accessed by the microcontroller; changes in temperature, power supply, capacitance deviation, and residual current do not affect the accuracy, and even if they are soaked, they will not fail or have errors. At the same time, they have long-term stability, no need for recalibration, fast response speed, low energy consumption, and are suitable for battery power supply.

2 Hardware Design

The design system block diagram is shown in Figure 2. The SHT11 sensor is used to collect temperature and humidity data, and a keyboard composed of non-self-locking button switches is used to send an artificial control signal to the control part, and then the DS1302 clock chip is used to generate real-time time data. The control part uses the AT89s52 microcontroller to receive, process and output various types of data. The output part uses an alarm circuit to alarm, and displays the result information such as temperature, humidity and time through a liquid crystal display module.



Figure 2 System Block Diagram


2.1 Sensor Hardware Interface Circuit Design

SHT11 is connected to the microcontroller through a two-wire serial interface circuit, and the specific circuit is shown in Figure 3. Among them, the serial clock input line SCK is used for communication synchronization between the microcontroller controller and SHT11. The serial data line DATA is used for the output of internal data and the input of external data. DATA changes state after the falling edge of the SCK clock and is only valid after the rising edge of the SCK clock. Therefore, the microcontroller can read data when SCK is high, and when it sends data to SHT11, it changes state after the falling edge of the SCK clock, while ensuring that the level state on the DATA line is stable in the SCK high level segment.



Figure 3 Connection between SHT11 and MCU


In the design, a 10 kΩ pull-up resistor is added to the data line DATA. In addition, a 100 nF capacitor is connected between VDD and GND for decoupling filtering.

2.2 Design of peripheral circuits of single-chip microcomputer system

The AT89s52 used in the system is a low-power, high-performance CMOS 8-bit single-chip microcomputer with 8kB of Flash program memory, 256 Byte of RAM, 40 pins, 32 I/O ports, 3 16-bit programmable timers/counters, 5 interrupt sources, 2 priorities, 1 full-duplex serial communication port, and is compatible with the standard MCS-51 instruction system and 80C51 pin structure. The minimum system of the single-chip microcomputer in the application usually includes related peripheral circuits such as power switch, reset circuit, crystal oscillator circuit, etc. The circuit of the single-chip microcomputer system in the design is shown in Figure 4.



Figure 4 MCU system circuit diagram


2.3 Display Circuit Design

The system uses an OCMJ4×8C liquid crystal display module with an ST7920 Chinese character liquid crystal control driver. The liquid crystal provides an 8-bit microprocessor interface, with display RAM and font generator. Only a minimum microprocessor system is needed to conveniently operate the module. The display module has a built-in 2 MB Chinese font ROM (CGROM) that provides a total of 8,192 Chinese fonts (16×16 dot matrix), and a 16 kB half-width font ROM (HCGROM) that provides a total of 128 symbol fonts (16×8 dot matrix), which can be mixed with the text screen for display.

The P0 port of the microcontroller is used as a parallel data transmission interface, and 8 1 kΩ resistors are connected to the P0 port to increase the load capacity so that it can drive the microcontroller normally. The circuit is shown in Figure 5.



Figure 5 LCD display interface circuit


2.4 Other functional circuit designs

As shown in Figure 6, the system uses a simple keyboard composed of non-self-locking push-button switches to send artificial function selection and setting control signals to the single-chip microcomputer, and uses a DS1302 clock chip powered by a 3 V button battery to generate real-time time data. At the same time, a simple alarm generation circuit composed of a triode amplifier circuit and a buzzer is used to alarm, and the alarm circuit can be isolated by pulling out the jumper P_SP. The entire system is directly powered by a 5 V power supply.



Figure 6 Keyboard, clock and alarm circuit design
 


3 Software Design

Programming mainly involves the writing of reading and writing programs and algorithm programs such as temperature and humidity data measurement and collection, time data collection, LCD display interface, keyboard scan setting, and temperature and humidity limit data comparison of the SHT11 sensor. [page]

3.1 Temperature and humidity measurement program design The

working sequence of the SHT11 sensor is shown in Figure 7. When the sensor is working, the data transmission is first initialized to start the SHT11 measurement sequence, that is, when the first SCK clock is high, DA TA flips to a low level, and when the second SCK clock is high, DATA flips to a high level. The SHT11 measurement command contains 3 address bits and 5 command bits. After the microcontroller issues a set of 8-bit measurement commands, DATA is set to a low level at the falling edge of the 8th SCK clock. Then send the 9th SCK clock as a command confirmation, and DA2TA returns to a high level after its falling edge. At the same time, the microcontroller can temporarily stop sending the clock sequence to enter the idle mode and prepare to read the measurement data. After the conversion is completed, SHT11 sets DATA to a low level, and the microcontroller continues to send a clock sequence to read 2 8-bit measurement data and 1 8-bit CRC parity check. All data starts from the MSB, and the right value is valid. Among them, after each byte transmission, a clock high electronic ACK is required, and DATA is set to a low level to confirm that the reading is successful. After the measurement and transmission are completed, SHT11 automatically enters sleep mode.

3.2 Keyboard Setting Algorithm Program Design

The keyboard uses K1, K2, K3, K4, 4 non-self-locking switch designs. When the switch is pressed, it will give a high level to the corresponding I/O port of the microcontroller. The keyboard mainly realizes the three functions of switching the display interface, setting the upper and lower limits of temperature and humidity alarms, and setting the time. The functions of these 4 switches are: K1 is the interface switching key; K2 is the logic "+", page up, and the cursor moves up; K3 is the logic "-", page down, and the cursor moves down; K4 is the selection key.



Figure 7 SHT11 sensor working timing diagram


3.3 LCD display program design

The programming method of the LCD display module is mainly determined by the control/driver used by the module. The design uses the ST7920 Chinese character LCD control/driver, which has an 8-bit parallel microcontroller interface, is programmed through a single-chip microcomputer, and uses the function of displaying letters, digital symbols and Chinese fonts. In addition, for the programming of the LCD screen, generally only data needs to be written into it. The display program design process is shown in Figure 9.

 


Figure 8 SHT11 measurement operation flow chart

Figure 9 LCD module operation procedure flow chart


3.4 Alarm Program Design

The temperature and humidity over-limit alarm function is realized through the alarm function. When the temperature and humidity are higher than the set alarm upper limit or lower than the set alarm lower limit, the P2.1 pin of the single-chip microcomputer will output a high level, and the buzzer will be driven to alarm through the transistor amplifier circuit.

In the alarm function, the algorithm compares the displayed limit of temperature and humidity with the set limit of humidity to determine whether the current humidity is over-limit. The comparison of temperature and humidity is similar, except that the algorithm still needs to consider the positive and negative values ​​of the comprehensive temperature.

3.5 DS1302 clock program design

The DS1302 clock chip plays the role of timing, time display and setting in the system. The read and write operation timing of DS1302 is shown in Figure 10. At the next SCLK clock rising edge after the control instruction word is input, the data is written into DS1302, and the data input starts from the low bit, that is, bit 0. Similarly, the data of DS1302 is read out at the falling edge of the next SCLK pulse following the 8-bit control instruction word.



Figure 10 DS1032 read and write timing diagram


3.6 Main function program design

The main function program integrates the above-mentioned functional unit sub-function programs into one function and runs it in a loop. The flow is shown in Figure 11.



Figure 11 Main function program flow chart

 


4 Conclusion

As a new generation of high-performance intelligent sensor, SHT11 has a high application prospect. The intelligent electronic temperature and humidity measurement system designed in this paper has been verified by experiments to accurately measure temperature and relative humidity, and display the measurement results in real time. In addition, the device also has the functions of time display, historical temperature and humidity data query, temperature and humidity upper and lower limit alarm, and related display switching and setting. The device has the advantages of small size, high measurement accuracy, fast measurement speed, wide range, easy operation, low cost and strong function. It is suitable for various applications such as home, travel, greenhouse agriculture, food storage, archive storage, etc., and has great practical application and economic utilization value.

Keywords:SHT11 Reference address:Design of temperature and humidity measurement system based on SHT11 sensor

Previous article:Anti-interference design of pedometer based on MMA8452Q sensor
Next article:A design method for testing phase and level differences of stereo signals

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号