Shenzhen ZTRON Microelectronics Co., Ltd
Telephone
0755-8299 4126

MCU

Temperature and humidity recorder microcontroller


Design of Temperature and Humidity Recorder Based on SCM


Temperature and humidity have always been the two most basic and important parameters in the field of environmental monitoring, and there are various devices for measuring, monitoring and recording these two parameters. This paper designs a temperature and humidity recorder based on AVR microcontroller. The recorder uses an infrared remote controller to set and control the parameters of the recorder, and can measure the ambient temperature and humidity in real time, and store and display locally. The measured historical data can also be transmitted to the host computer through the serial port of the single chip microcomputer. machine for monitoring.


1. System composition and basic principle of temperature and humidity recorder


The recorder realizes the following functions: collect, record and display temperature and humidity data; use the remote control to set the initial time of the system; self-select the time interval of temperature and humidity data collection; transmit the historical data recorded locally to the PC terminal of the host computer ; Use the remote control to control and display the current real-time temperature and humidity data or view historical data on multiple screens. The temperature and humidity recorder designed in this paper uses a single-chip microcomputer as the control core, and is composed of a temperature and humidity acquisition module, a clock module, a display module, an infrared sending and receiving module, a serial communication module, and a power module. Its structure diagram is shown in Figure 1. The temperature and humidity acquisition module collects the temperature and humidity data of the environment, converts them into digital quantities, and provides them to the single-chip microcomputer for processing. The clock module provides accurate and detailed time information such as year, month, day, hour, minute and second for the entire recorder, and can automatically enable the backup power supply to supply power to this module when the system is powered off. The display module displays local real-time temperature and humidity data, historical record data, etc. The infrared receiving module cooperates with the infrared remote control to set and modify the parameters of the recorder, and to change the displayed content of the display during the operation of the recorder. The serial communication module is responsible for transmitting the historical data recorded on the recorder to the upper PC. The power module supplies power to the entire recorder.


2. Hardware design of temperature and humidity recording system


The system hardware mainly adopts high-performance AVR microcontroller ATmega16, digital temperature and humidity sensor SHT10, clock chip PCF8563, dot matrix LCD display module 12864 and infrared receiver VS1838 and other devices.


2.1 Introduction of MCU ATmega16


High reliability, powerful functions, high speed, low power consumption, and low price have always been important indicators for measuring single-chip microcomputers, and they are also necessary conditions for single-chip microcomputers to occupy the market and survive. In this system, 8-bit microcontroller ATmega16 with high performance and low power consumption is used.


ATmega16 has complete functions and rich peripheral interfaces, with 2 8-bit, 1 16-bit timer/counter, 8-way 10-bit AD converter, 4-channel PWM, 2 programmable serial USARTs, and a total of 32 programmable I /O interface. On-chip has 16KB of in-system programmable Flash, 1KB of on-chip SRAM, and 512 bytes of EEPROM. There are up to 6 sleep modes such as idle, ADC noise suppression, power saving, power down, and standby. Because ATmega16 uses Haval structure, fully static work, word as instruction length unit, and simplifies instruction set, most of its instructions are completed within one clock cycle, so its data throughput rate is very high, and its performance is as high as 16MIPS when working at 16MHz, so that it can Slow down the contradiction between power consumption and processing speed of the system. ATmega16 has a total of 131 instructions and 32 8-bit general-purpose registers, all registers are directly connected to the ALU, so that one instruction can access two registers at the same time in one clock cycle, which greatly improves code efficiency and can perform data transmission and temperature collection.


2.2 Temperature and humidity acquisition module


The measurement of temperature and humidity uses the integrated digital temperature and humidity sensor SHT10. SHT10 integrates temperature and humidity sensing, signal conversion, AD converter and other functions into one chip, provides two-wire digital serial interface SCK and DATA, supports CRC transmission verification, programmable adjustment of measurement accuracy, and provides temperature compensation with temperature After the measurement value, the measurement and communication are completed, it will automatically switch to the low power consumption mode, and the sensor head can be completely immersed in water during measurement. The temperature of this recorder is designed with 14b resolution, and the range is:


-400C~990C, measurement accuracy: ±0.50C, resolution 0.01 0C; humidity uses 12b resolution, range: 0~99%RH, measurement accuracy: ±4.5%RH, resolution 0.03%RH. When designing the circuit, connect SCK and DATA pins of SHT10 to PC7 and PC6 pins of ATmega16 respectively, ATmega16 provides clock signal to SHT10, and DATA pin is used for data exchange between the two.


2.3 Clock module


When recording temperature and humidity data, accurate time information is required, which is provided by the clock module. The clock module takes Philips' programmable clock/calendar chip PCF8563 as the core, supplemented by corresponding peripheral circuits. PCF8563 has 16 8-bit registers, built-in 32.768KHz oscillator, frequency divider, timer, alarm, power-down check, I2C bus interface and other components for providing source clock for real-time clock RTC. Among the 16 registers, 2 are used for control registers and status registers, 7 are used for clock (second, minute, hour, day, week, month, year) counters, and 4 are used for alarm registers (defining minutes, hours, days, alarm condition of the week), and the remaining three are CLKOUT frequency register, timer control register and countdown timing register. These registers are read and written by the microcontroller through the two-wire I2C bus (clock SCL, data SDA). Because PCF8563 adopts I2C bus line, its peripheral circuit design is simple. PCF8563 has a total of 8 pins. In this design, OSCI and OSCO are connected to a 32.768KHz crystal oscillator. The SCL pin is connected to the PC0 port of the single-chip microcomputer to provide a clock signal for the I2C bus, and the SDA pin is connected to the PC1 port of the single-chip microcomputer to realize reading and writing of time and date. In addition to connecting the system power supply, the power supply pin Vdd is also connected to a 3.3V button battery as a backup power supply. When the system is powered down, the backup power supply of 3.3V is used as the power supply of PCF8563.


2.4 Infrared receiving module


When the temperature and humidity recorder is used, there will be some special occasions, such as the height of the recorder, the recorder is placed in a confined space, etc., making the recorder inconvenient to control, and short-distance non-contact control is required. The system uses infrared communication technology for short-distance communication. Infrared communication technology has the characteristics of large information capacity, simple structure, good directionality, low power consumption, low price, and strong confidentiality. The system uses the integrated infrared receiving head VS1838 and the integrated infrared remote control to transmit the recorder's time setting, display format and other control information. When different buttons on the remote control are pressed, different serial binary remote control codes are generated. After the code is secondarily modulated by the 38KHz carrier signal, it is sent out in the form of infrared signals through the infrared emitting diode. The VS1838 receiver integrates infrared receiving diodes, signal amplifiers, limiters, frequency-selective bandpass filters, integrating circuits, and comparators. The infrared receiving diode transmits the received signal to the amplifier for amplification, the signal is limited to a suitable voltage range through the limiter, and only the 30~60KHz signal is retained after passing through the band-pass filter. After demodulation and integration circuit, the signal is transmitted to the comparator to output high and low levels, converted into binary code sent by the transmitter, and sent to the PC2 pin of the single-chip microcomputer through the pin DQ for use by the single-chip microcomputer.


2.5 Display module


The display module displays the current time, temperature and humidity locally, displays the initial setting time when the system is initialized, the time interval of temperature and humidity recording, and displays the recorded historical data and other information. Due to the large amount of displayed data, this system uses a dot-matrix graphic liquid crystal display module LCD12864. The display resolution of LCD12864 is 128*64, and it can display Chinese characters in 8*4 lines and 16*16 dot matrix. 12864 hardware circuit structure and software programming are much simpler and cheaper than the same type of graphics dot-matrix liquid crystal module, and have been widely used. The system uses an 8-bit parallel 12864 display module, which has 20 pins in total with the external interface. The module is simple to connect with the external circuit. During the design, 8 parallel tri-state data lines DB0~DB7 of 12864 are connected to the PB0~PB7 ports of the single-chip microcomputer for data transmission with the single-chip microcomputer. The contrast (brightness) adjustment pin V0 of 12864 is connected to an adjustable resistor, and the brightness is changed by adjusting the resistor value. 12864's parallel instruction/data display selection pin RS, read-write control pin R/W, and parallel enable pin E are respectively connected to PD7~PD4 of the single-chip microcomputer, and the control signal is given by the single-chip microcomputer. Because the parallel interface is used, the parallel/serial interface selection pin PSB is connected to high level. The reset terminal RESET, the positive terminal of the backlight source and the PSB terminal are jointly connected to the power supply terminal VCC. The LCD drive voltage output terminal Vout is connected to the power supply terminal VCC through a 10K current limiting resistor.


2.6 Communication Module


The communication module completes the communication between the single-chip microcomputer and the PC. The recorder can store up to 50 recent temperature and humidity data continuously. In some usage occasions, it is necessary to permanently retain the data for a longer period of time. Using the communication module, the data in the recorder can be sent to the PC for permanent storage. Serial communication is adopted between the single-chip microcomputer and the PC. Since the serial port level of the PC machine is inconsistent with the electrical specification of the serial port of the single-chip microcomputer, the MAX232 chip is used for level conversion. Use the PD0 port (RXD) of the ATmega16 microcontroller to connect to the 9-pin R2OUT of the MAX232, and connect the PD1 port (TXD) to the 10-pin T2INT of the MAX232. Pins 7 and 8 of MAX232 are connected to the full-duplex serial port of the PC. With the development of the Internet of Things technology, the device can also be used as a terminal node of the Internet of Things. When designing the system, the PA port is reserved for the Zigbee network.


2.7 Power module


The power module supplies power to the entire recorder. The recorder uses AC 220V mains as the power supply, and the chip power supply on the recorder requires DC 5V. Therefore, the power module needs to complete the conversion from AC220V to DC5V. The principle is that the 220V AC is rectified by a full-bridge rectifier circuit, filtered and stabilized, and then sent to a 7805 three-terminal voltage regulator to obtain a stable DC voltage of 5V.


3. Software design of temperature and humidity recorder


After the system hardware architecture is completed, the functions realized by the system software are mainly the initialization settings after power-on, and the real-time collection, recording, display and transmission of temperature and humidity data. After the microcontroller is powered on or reset, the system is initialized, and the initial settings of the IO port, internal register, and serial communication baud rate of the microcontroller are completed, and then the infrared receiver is scanned to see if there is a remote control signal sent by the remote controller. If yes, analyze whether the signal is the setting signal of the recorder or the data transmission signal, the setting signal is transferred to the setting of the recorder time, recording interval, and display mode, and the transmission signal controls the historical data recorded in the recorder to be transmitted to the PC. If no remote control signal is sent to the single-chip microcomputer, check whether the recording interval time is up, if the temperature and humidity data is collected, recorded and displayed, otherwise check again whether there is a remote control signal sent. The software design adopts the C language programming language, and adopts the modular design method. According to the flow chart, the program is divided into initialization module, infrared remote control signal acquisition module, infrared remote control signal processing module, temperature and humidity data acquisition module, acquisition data conversion into storage data, display code conversion module, PCF8563 setting, time information reading, Display code conversion module, temperature and humidity data recording module and record historical data transmission and other modules.


Summarize


This paper studies and designs a temperature and humidity recorder based on AVR single-chip microcomputer. The recorder has the characteristics of high data acquisition accuracy, small size, convenient portability, low cost, low power consumption, simple structure, and simple and convenient control. This recorder also has certain deficiencies. Because the storage of historical data uses the EEPROM area inside the single-chip microcomputer, and the capacity of the EEPROM area of the single-chip microcomputer is limited, the recorder can only store 500 pieces of historical data at most. If it is set to record a piece of data every 15 minutes, the recorder can only store 3 days of historical data. The expansion of large-capacity memory chips by single-chip microcomputers can increase the recorded historical data.


The above is the design technology of temperature and humidity recorder based on AVR microcontroller introduced by Shenzhen Zuchuang Microelectronics Co., Ltd. for you. We have rich experience in customized development of smart electronic products, can evaluate the development cycle and IC price as soon as possible, and can also calculate the PCBA quotation. We are the agent of Sonix MCU and Yingguang MCU agent, selling and developing MCU and voice IC solutions of Sonix and Yingguang. We act as an agent and develop ICs and solutions of Jieli, Ankai, Quanzhi, realtek and other series, and also develop BLE Bluetooth IC, dual-mode Bluetooth module, wifi module, and Internet of Things module. We have hardware design and software development capabilities. Covering circuit design, PCB design, single-chip microcomputer development, software custom development, APP custom development, WeChat official account development, voice recognition technology, Bluetooth development, wifi technology, etc. It can also undertake the research and development of smart electronic products, the design of household appliances, the development of beauty equipment, the development of Internet of Things applications, the design of smart home solutions, the development of TWS earphones, the development of Bluetooth earphone speakers, the development of children's toys, and the development of electronic education products.

  • TOP