Lei Yuting and Li Shuhui: Intelligent vortex purifier[Copy link]
AbstractWith the development of society and industry, people pay more and more attention to health issues. Air purifiers can not only purify the surrounding environment but also be used as decorations in homes and dormitories. They are beautiful and modern in appearance, simple but not simple. Therefore, this product is gradually accepted by people. With the change of people's concepts, air purifiers will have a good development prospect. This design adopts the minimum system of STC89C52 single-chip microcomputer, Bluetooth module, GP2Y1014AU dust sensor, ADC0832 analog-to-digital converter module, DHT11 temperature and humidity sensor module, LCD1602 liquid crystal module, power module, buzzer alarm module, LED module and key module. The single-chip microcomputer collects the dust concentration of the GP2Y1010AU dust sensor through the ADC0832 conversion chip in real time. At the same time, the temperature at that time is sensed through the DHT11 temperature and humidity sensor, and then the quality and temperature of the air are displayed on the LCD screen after the single-chip microcomputer data conversion processing. When the temperature and humidity in the measured air are greater than or less than the set temperature and humidity, the buzzer alarms. Different indicator lights indicate different temperatures. The fan is turned on and off by the power transformer. At the same time, the transformer, alarm and indicator light are remotely controlled via Bluetooth, and the modules on the circuit board are turned on and off by the battery. Keywords: GP2Y1014AU0F dust sensor, DHT11 temperature and humidity sensor, Bluetooth remote control, air quality ABSTRACT With the development of society and industry. People pay more and more attention to health problems. Air evolutional devices can not only purify the surrounding environment but also be ornaments in the home and bedroom. Therefore, this kind of product is gradually accepted by people. With the transformation of people's ideas, the air purifier will be good. Prospects for development. This design US ES the smallest system controlled by STC89C52, Bluetooth module, GP2Y1014AU dust sensor, ADC0832 analog to digital converter module, DHT11 temperature and humidity sensor module, LCD1602 module, power module, buzzer alarm module, LED module and key module module. The single chip microcomputer collects the dust concentration of the GP2Y1010AU dust sensor in real time through the ADC0832 conversion chip. At the same time, the temperature of the time is induced by the DHT11 temperature and humidity sensor, then the quality and temperature in the air are displayed on the LCD screen after the data conversion of the single chip microcomputer. When the temperature and humidity in the measured air is greater than or less than the setting of the air, the temperature and humidity are greater than or less than the setting. When the temperature and humidity, the buzzer alarm. Different lights show different temperatures. The switch of the fan is controlled by the transformer. indicator light are controlled by the Bluetooth, and the switch of each module on the circuit board is controlled by the power supply. Key words: GP2Y1014AU0F dust sensor, DHT11 temperature and humidity sensor, Bluetooth remote control and air quality. Contents summary I ABSTRACT II 1. Introduction 4 1.1 Background of the topic 4 2. Overall scheme design 5 3. System scheme selection and comparison, design and demonstration 3 3.1 Main controller module selection 3 3.2 Button selection 4 3.3 Selection of display module 4 3.4 Selection of power supply 5 4. Introduction to chip data 4.1 Introduction to GP2Y1010AU0F sensor 5 4.2 Introduction to ADC0832 analog-to-digital converter 12 5. Hardware implementation and unit circuit design 21 5.1 Main control module 21 5.2 Display module circuit 22 5.3 Design of alarm module 23 5.4 Design of power supply 24 6. Circuit debugging and analysis 25 6.1 Circuit debugging 25 6.2 Implementation of each function References 29 Overall circuit schematic 30 1. Introduction 1.1 Background of the topic In modern life, due to economic development, air pollution is becoming more and more serious. More and more people are flocking to big cities. The improvement of living standards has brought about a decline in the quality of life. Air is a substance that everyone must breathe every day. However, since air pollution seriously threatens human health, more and more people are eager to breathe clean and pollution-free air in big cities. The big environment cannot be changed, and people can only use technological products to improve the small environment. Therefore, products such as air humidifiers, air humidifiers, air purifiers, etc. have emerged in the market. The air purifier designed this time is positioned as a "home" industry in terms of region. In terms of the positioning of the crowd, it is mainly to design an air purifier suitable for the aesthetics of young people. In short, the theme is "love life, enjoy life, and pay attention to health". 2. Overall design This design adopts the minimum system of STC89C52 microcontroller, Bluetooth module, GP2Y1014AU dust sensor, ADC0832 analog-to-digital converter module, DHT11 temperature and humidity sensor module, LCD1602 liquid crystal module, power module, buzzer alarm module, LED module and button module. The single-chip microcomputer collects the dust concentration of the GP2Y1010AU dust sensor through the ADC0832 conversion chip in real time. At the same time, the temperature at that time is sensed through the DHT11 temperature and humidity sensor, and then the quality and temperature of the air are displayed on the LCD screen after the single-chip microcomputer data conversion processing. When the temperature and humidity in the measured air are greater than or less than the set temperature and humidity, the buzzer alarms. Different indicator lights indicate different temperatures. The switch of the fan is controlled by the transformer. At the same time, the switch of the transformer, the switch of the alarm and the switch of the indicator light are remotely controlled through Bluetooth, and the switch of each module on the circuit board is controlled by the power supply.
3. Comparison and selection of system solutions, design and demonstration The system is mainly composed of the dust detection module GP2Y1014AU, the button setting module, the DHT11 temperature and humidity sensor module, the alarm module and the LCD display module state display circuit. The following introduces the solution to realize the function of this system. 3.1 Main controller module selection Option 1: STC12C5A60S2 is a new generation of 8051 microcontroller with high speed/low power consumption/super strong anti-interference. The instruction code is fully compatible with the traditional 8051, but the speed is 8-12 times faster. It integrates MAX810 dedicated reset circuit, 2-way PWM, 8-way high-speed 10-bit A/D conversion (250K/S), for motor control and strong interference occasions. However, this system does not require complex AD conversion, and the data processing speed requirement is not very high. And from the perspective of use and economy, we gave up this plan. Option 2: Use STC89C52 microcontroller as the core of the entire system, and use it for program data processing to achieve its established performance indicators. Fully analyzing our system, the key is to realize the display data display of temperature and humidity sensors and PM2.5 sensors, and at this point, the microcontroller shows its advantages-simple control, convenient and fast. In this way, the microcontroller can give full play to its advantages such as rich resources, powerful control functions, bit addressable operation functions, and low price. The STC89C52 microcontroller has powerful bit operation instructions, and the I/O ports can be bit-addressed. The program space is up to 8K, which is more than enough for this design. What's more valuable is that the STC89C52 microcontroller is very cheap. 3.2 Selection of buttons The buttons of this system are used to switch and adjust the alarm setting value. Button 1 is used to adjust the self-increment function of the alarm value, button 2 is used to control the buzzer, and button 3 is used for the self-decrement of the alarm value. Solution 1: Use a matrix keyboard. This type of keyboard uses a matrix row and column scanning method. The advantage is that when there are more buttons, the number of I/O ports occupied by the microcontroller can be reduced. The disadvantage is that the circuit is complicated and the programming difficulty will be increased. Solution 2: Use an independent button circuit. Each button occupies an I/O interface line separately. The working status of each I/O port does not affect each other. This type of keyboard uses a port direct scanning method. The disadvantage is that when there are more buttons, a large number of I/O ports of the microcontroller are occupied. The advantage is that the circuit design is simple and programming is relatively easy. Considering that this system requires fewer buttons, it is more convenient and easier to control with independent buttons, so the second solution is adopted. 3.3 Selection of display module Solution 1: Use digital tube for display. Digital tubes have been widely used due to their fast display speed, simple use, and concise and clear display effect. However, due to the need to display temperature, humidity and PM value. Digital tubes cannot display such rich content, so we gave up this solution. Solution 2: Use LCD liquid crystal for display. LCD has been widely used due to its clear display, rich and clear display content, large amount of displayed information, easy use, and fast display. 1. Use LCD12864 for display. LCD12864 is a graphic dot matrix liquid crystal display, which is mainly divided into two types, with font library and without font library. LCD without font library needs to provide font library font template by itself. At this time, various font display styles can be set according to personal preferences, and the design is more flexible. LCD with font library provides font library font template, but can only display GB2312 Songti. Each has its advantages and disadvantages, and can be flexibly selected according to different application scenarios. The schematic diagram of its liquid crystal module is shown below. Advantages: low power consumption, small size, light weight, ultra-thin, etc. Disadvantages: LCD12864 has a large amount of information, so the program and circuit are relatively complex and the price is relatively high.
2. LCD1602 is used for liquid crystal display. Its principle is to use the physical characteristics of liquid crystal to control its display area through voltage. There is display when there is electricity, so that graphics can be displayed. The lcd1602 liquid crystal display module can only use D4-D7 as four-bit data to transmit twice. In this way, the I/O port resources of the MCU can be saved. The lcd1602 can display 2 lines of 16 characters, with 8 data buses D0-D7, and three control ports of RS, R/W, and EN. The working voltage is 5V, and it has character contrast adjustment and backlight. As shown in Figure 1:
Advantages: character liquid crystal, it is convenient to display letters and numbers, simple to control, and low cost. Disadvantages: The font size of the display is limited, graphics cannot be displayed, etc., and it cannot display curves. Since this system does not need to use more complex patterns such as text, graphics and curves, it only needs simple alphanumeric display. Therefore, LCD1602 liquid crystal display is used. 3.4 Selection of Bluetooth module Option 1: HC-06 is a master-slave integrated Bluetooth serial port module. The master and slave can be switched by command. The instructions are less than HC-05 and it is easy to use. Advantages: The output part is enhanced, the tube capacity is larger, and it can also be connected to a higher voltage external drive. Option 2: HC-05 is a master-slave integrated Bluetooth serial port module. The master and slave can be switched by command, and the instructions are rich and complete. Advantages: There are many instructions, simple, easy to use, and relatively easy for AT settings. Comprehensively considering the AT settings and command sending of this system, option 2 is selected. 3.5 Power supply selection
Option 1: Use 5V and 12V batteries to power the system. The battery has a strong current driving capability and stable voltage output performance. However, the battery is too large and the power is too small. When used for a long time, the voltage is not stable. Option 2: Make a 12V, 9V and 5V transformer power supply board to supply power. The voltage is stable. There is no need to worry about voltage instability due to reduced power, nor do you need to worry about changes in resistance due to long-term use. In the final application, both options are adopted due to the actual power supply voltage. 4. Introduction to chip information 4.1 Introduction to GP2Y1014AU0F sensor GP2Y1014AU0F is a dust sensor using an optical sensing system. The device consists of an infrared light emitting diode (IRED) and a photoelectric tube arranged diagonally. It detects the reflected light of dust in the air. In particular, it can effectively detect very fine particles such as cigarette smoke. In addition, it can distinguish between smoke and dust in the house through pulse analog output. 4.2 ADC0832 Analog-to-digital Converter Introduction ADC0832 is an 8-bit resolution, dual-channel A/D conversion chip produced by National Semiconductor Corporation. It is popular among microcontroller enthusiasts and enterprises due to its small size, strong compatibility and high cost performance. It has a high penetration rate. Learning and using ADC0832 can help us understand the principle of A/D converter and help improve our microcontroller technology level. ADC0832 has the following features: · 8-bit resolution · Dual-channel A/D conversion · Input and output levels are compatible with TTL/CMOS · Input voltage is between 0-5V when powered by 5V · Operating frequency is 250KHZ, conversion time is 32μS · General power consumption is only 15mW · 8P, 14P—DIP (dual in-line package), PICC multiple packages · Commercial-grade chip temperature range is 0°C ~ +70°C, industrial-grade chip temperature range is -40°C ~ +85°C Chip top view:
Figure 1 Chip interface description: · CS_ Chip select enable, low-level chip enable. · CH0 Analog input channel 0, or used as IN+/-. · CH1 Analog input channel 1, or used as IN+/-. · GND Chip reference 0 potential (ground). · DI Data signal input, select channel control. · DO data signal output, converted data output. · CLK chip clock input. · Vcc/REF power input and reference voltage input (multiplexed). Interface circuit between ADC0832 and microcontroller:
ADC0832 is an 8-bit resolution A/D conversion chip, with a maximum resolution of 256 levels, which can meet general analog conversion requirements. The multiplexing of its internal power input and reference voltage makes the analog voltage input of the chip between 0 and 5V. The chip conversion time is only 32μS, and the dual data output can be used as data verification to reduce data errors. The conversion speed is fast and the stability is strong. The independent chip enable input makes it more convenient to connect multiple devices and control the processor. Through the DI data input terminal, the channel function selection can be easily realized. The control principle of the microcontroller to ADC0832: Under normal circumstances, the interface between ADC0832 and the microcontroller should be 4 data lines, namely CS, CLK, DO, and DI. However, since the DO and DI terminals are not effective at the same time during communication and the interface with the microcontroller is bidirectional, DO and DI can be used in parallel on a data line when designing the circuit. When ADC0832 is not working, its CS input terminal should be high level, the chip is disabled at this time, and the levels of CLK and DO/DI can be arbitrary. When A/D conversion is to be performed, the CS enable terminal must be set to low level and maintained at low level until the conversion is completely completed. At this time, the chip starts to convert, and the processor inputs clock pulses to the chip clock input terminal CLK, and the DO/DI terminal uses the data signal of the channel function selection input by the DI terminal. Before the sinking of the first clock pulse, the DI terminal must be high level, indicating the start signal. Before the sinking of the second and third pulses, the DI terminal should input 2-bit data to select the channel function. When the 2-bit data is "1" or "0", only single-channel conversion is performed on CH0. When the 2-bit data is "1" or "1", only single-channel conversion is performed on CH1. When the 2-bit data is "0", "0", CH0 is used as the positive input terminal IN+, and CH1 is used as the negative input terminal IN- for input. When the 2-bit data is "0", "1", CH0 is used as the negative input terminal IN-, and CH1 is used as the positive input terminal IN+ for input. After the sinking of the third pulse, the input level of the DI terminal loses its input function, and then the DO/DI terminal begins to use the data output DO to read the converted data. From the sinking of the fourth pulse, the DO terminal outputs the highest bit of the converted data DATA7, and then the DO terminal outputs the next bit of data at each subsequent pulse sinking. Until the 11th pulse, the lowest bit of data DATA0 is issued, and the output of one byte of data is completed. It is also from this bit that the next opposite byte of data is output, that is, DATD0 is output from the sinking of the 11th byte. Then 8 bits of data are output, and the data output is completed at the 19th pulse, which also marks the end of an A/D conversion. Finally, set CS to a high level to disable the chip, and directly process the converted data. ADC0832 timing diagram:
Figure 3 When used as a single-channel analog signal input, the input voltage of ADC0832 is 0~5V and the voltage accuracy is 19.53mV at 8-bit resolution. If used as an input from IN+ and IN-, the voltage value can be set within a larger range to increase the conversion width. But it is worth noting that when inputting IN+ and IN-, if the voltage of IN- is greater than the voltage of IN+, the converted data result is always 00H. 5. Hardware implementation and unit circuit design 5.1 Main control module The minimum system of the microcontroller includes a microcontroller, a reset circuit, and a clock circuit. The operating voltage range of the STC89C52 microcontroller is: 4V-5.5V, so the microcontroller is usually given an external 5V DC power supply. The connection method is that the 40-pin VCC in the microcontroller is connected to the positive pole 5V, and the 20-pin VSS is connected to the power ground. The reset circuit is to determine the working starting state of the microcontroller and complete the startup process of the microcontroller. When the microcontroller is powered on, a reset signal is generated to complete the startup of the microcontroller and determine the initial working state of the microcontroller. When the microcontroller system is running and the program is disturbed by the external environment and runs away, press the reset button and the internal program will automatically start from the beginning. Generally, there are automatic reset at power-on and manual reset by external buttons. After the clock circuit of the microcontroller works, the reset operation can be completed when the RESET terminal continuously gives a high level for 2 machine cycles. This design uses an external manual button reset circuit, and a pull-up resistor needs to be connected to increase the value of the output high level. The clock circuit is like the heart of the microcontroller, which controls the working rhythm of the microcontroller. The clock circuit is an oscillator circuit, which provides a sine wave signal to the microcontroller as a reference to determine the execution speed of the microcontroller. XTAL1 and XTAL2 are the input and output of the reverse amplifier, respectively, and the reverse amplifier can be configured as an on-chip oscillator. If an external clock source driver is used, XTAL2 should not be connected. Because a machine cycle contains 6 state cycles, and each state cycle is 2 oscillation cycles, so a machine cycle has a total of 12 oscillation cycles. If the oscillation frequency of the external quartz crystal oscillator is 12MHZ, one oscillation cycle is 1/12us. 5.2 Display module circuit The display module uses LCD1602 liquid crystal display, which can clearly display characters and numbers on the liquid crystal, which makes people feel comfortable. The command operation pins of the liquid crystal are RS, RW, and EN connected to the P3^5, P3^6, and P3^7 pins of the microcontroller. , Data pins D0~D7 are respectively connected to the P1 port of the microcontroller. The specific circuit diagram is shown in Figure 5:
6. Circuit debugging and analysis 6.1 Circuit debugging First burn the LCD display program to see if the display is normal. If it is abnormal, check the soldering conditions of the pins of the LCD1602 liquid crystal to see if there are any cold soldering, short soldering, or wrong soldering. After the display is normal, add the dust detection program, temperature and humidity detection program, Bluetooth module, LCD1602 liquid crystal display, ADC conversion module, etc. to the program and debug them one by one. 6.2 Implementation of each function This system belongs to the detection and display module. The data detected by PM2.5 is sent to the display screen after AD conversion, and the data detected by temperature and humidity is directly displayed on the display screen. The principle of the purification function is that the outside air enters the filter, passes through two layers of filters, one layer of activated carbon filter, and one layer of HEPA filter, and finally passes through the centrifugal vortex fan to pass the purified air out.
References [1] Guo Tianxiang "51 Single-Chip Microcomputer C Language Tutorial" Tsinghua University Press [2] Tan Haoqiang "C Programming" Electronic Industry Press Part of the program is as follows: #include5 The detected data is sent to the display screen after AD conversion, and the temperature and humidity detected data are directly displayed on the display screen. The principle of the purification function is that the outside air enters the filter, passes through two layers of filters, one layer of activated carbon filter, and one layer of HEPA filter, and finally passes the purified air out through the centrifugal vortex fan.
References [1] Guo Tianxiang "51 Single Chip Microcomputer C Language Tutorial" Tsinghua University Press [2] Tan Haoqiang "C Programming" Electronic Industry Press Part of the program is as follows: #include5 The detected data is sent to the display screen after AD conversion, and the temperature and humidity detected data are directly displayed on the display screen. The principle of the purification function is that the outside air enters the filter, passes through two layers of filters, one layer of activated carbon filter, and one layer of HEPA filter, and finally passes the purified air out through the centrifugal vortex fan.
References [1] Guo Tianxiang "51 Single Chip Microcomputer C Language Tutorial" Tsinghua University Press [2] Tan Haoqiang "C Programming" Electronic Industry Press Part of the program is as follows: #include5 The detected data is sent to the display screen after AD conversion, and the temperature and humidity detected data are directly displayed on the display screen. The principle of the purification function is that the outside air enters the filter, passes through two layers of filters, one layer of activated carbon filter, and one layer of HEPA filter, and finally passes the purified air out through the centrifugal vortex fan.
References [1] Guo Tianxiang "51 Single Chip Microcomputer C Language Tutorial" Tsinghua University Press [2] Tan Haoqiang "C Programming" Electronic Industry Press Part of the program is as follows: #include5 The detected data is sent to the display screen after AD conversion, and the temperature and humidity detected data are directly displayed on the display screen. The principle of the purification function is that the outside air enters the filter, passes through two layers of filters, one layer of activated carbon filter, and one layer of HEPA filter, and finally passes the purified air out through the centrifugal vortex fan.
References [1] Guo Tianxiang "51 Single Chip Microcomputer C Language Tutorial" Tsinghua University Press [2] Tan Haoqiang "C Programming" Electronic Industry Press Part of the program is as follows: #include5 The detected data is sent to the display screen after AD conversion, and the temperature and humidity detected data are directly displayed on the display screen. The principle of the purification function is that the outside air enters the filter, passes through two layers of filters, one layer of activated carbon filter, and one layer of HEPA filter, and finally passes the purified air out through the centrifugal vortex fan.
References [1] Guo Tianxiang "51 Single Chip Microcomputer C Language Tutorial" Tsinghua University Press [2] Tan Haoqiang "C Programming" Electronic Industry Press Part of the program is as follows: #include5 The detected data is sent to the display screen after AD conversion, and the temperature and humidity detected data are directly displayed on the display screen. The principle of the purification function is that the outside air enters the filter, passes through two layers of filters, one layer of activated carbon filter, and one layer of HEPA filter, and finally passes the purified air out through the centrifugal vortex fan.
References [1] Guo Tianxiang "51 Single Chip Microcomputer C Language Tutorial" Tsinghua University Press [2] Tan Haoqiang "C Programming" Electronic Industry Press Part of the program is as follows: #include5 The detected data is sent to the display screen after AD conversion, and the temperature and humidity detected data are directly displayed on the display screen. The principle of the purification function is that the outside air enters the filter, passes through two layers of filters, one layer of activated carbon filter, and one layer of HEPA filter, and finally passes the purified air out through the centrifugal vortex fan.
References [1] Guo Tianxiang "51 Single Chip Microcomputer C Language Tutorial" Tsinghua University Press [2] Tan Haoqiang "C Programming" Electronic Industry Press Part of the program is as follows: #include5 The detected data is sent to the display screen after AD conversion, and the temperature and humidity detected data are directly displayed on the display screen. The principle of the purification function is that the outside air enters the filter, passes through two layers of filters, one layer of activated carbon filter, and one layer of HEPA filter, and finally passes the purified air out through the centrifugal vortex fan.
References [1] Guo Tianxiang "51 Single Chip Microcomputer C Language Tutorial" Tsinghua University Press [2] Tan Haoqiang "C Programming" Electronic Industry Press Part of the program is as follows: #include5 The detected data is sent to the display screen after AD conversion, and the temperature and humidity detected data are directly displayed on the display screen. The principle of the purification function is that the outside air enters the filter, passes through two layers of filters, one layer of activated carbon filter, and one layer of HEPA filter, and finally passes the purified air out through the centrifugal vortex fan.
References [1] Guo Tianxiang "51 Single Chip Microcomputer C Language Tutorial" Tsinghua University Press [2] Tan Haoqiang "C Programming" Electronic Industry Press Part of the program is as follows: #include5 The detected data is sent to the display screen after AD conversion, and the temperature and humidity detected data are directly displayed on the display screen. The principle of the purification function is that the outside air enters the filter, passes through two layers of filters, one layer of activated carbon filter, and one layer of HEPA filter, and finally passes the purified air out through the centrifugal vortex fan.
References [1] Guo Tianxiang "51 Single Chip Microcomputer C Language Tutorial" Tsinghua University Press [2] Tan Haoqiang "C Programming" Electronic Industry Press Part of the program is as follows: #include5 The detected data is sent to the display screen after AD conversion, and the temperature and humidity detected data are directly displayed on the display screen. The principle of the purification function is that the outside air enters the filter, passes through two layers of filters, one layer of activated carbon filter, and one layer of HEPA filter, and finally passes the purified air out through the centrifugal vortex fan.
References [1] Guo Tianxiang "51 Single Chip Microcomputer C Language Tutorial" Tsinghua University Press [2] Tan Haoqiang "C Programming" Electronic Industry Press Part of the program is as follows: #include5 The detected data is sent to the display screen after AD conversion, and the temperature and humidity detected data are directly displayed on the display screen. The principle of the purification function is that the outside air enters the filter, passes through two layers of filters, one layer of activated carbon filter, and one layer of HEPA filter, and finally passes the purified air out through the centrifugal vortex fan.
References [1] Guo Tianxiang "51 Single Chip Microcomputer C Language Tutorial" Tsinghua University Press [2] Tan Haoqiang "C Programming" Electronic Industry Press Part of the program is as follows: #include3 Alarm module design [attach] 373311 [/attach] 5.4 Power supply design [attach] 373312 [/attach] 6. Circuit debugging and analysis 6.1 Circuit debugging First burn the LCD display program to see if the display is normal. If not, check the soldering of each pin of the LCD1602 liquid crystal to see if there is any cold soldering, short soldering, or wrong soldering. After the display is normal, add dust detection program, temperature and humidity detection program, Bluetooth module, LCD1602 liquid crystal display screen, ADC conversion module, etc. to the program for debugging. 6.2 Implementation of each function This system belongs to the detection and display module. The data detected by PM2.5 is converted to the display screen through AD, and the data detected by temperature and humidity are directly displayed on the display screen. The principle of the purification function is that the outside air enters the filter, passes through two layers of filters, one layer of activated carbon filter, and one layer of HEPA filter, and finally passes the purified air out through the centrifugal vortex fan.
References [1] Guo Tianxiang, "51 Single Chip Microcomputer C Language Tutorial", Tsinghua University Press [2] Tan Haoqiang, "C Programming", Electronic Industry Press Part of the program is as follows: #include3 Alarm module design [attach] 373311 [/attach] 5.4 Power supply design [attach] 373312 [/attach] 6. Circuit debugging and analysis 6.1 Circuit debugging First burn the LCD display program to see if the display is normal. If not, check the soldering of each pin of the LCD1602 liquid crystal to see if there is any cold soldering, short soldering, or wrong soldering. After the display is normal, add dust detection program, temperature and humidity detection program, Bluetooth module, LCD1602 liquid crystal display screen, ADC conversion module, etc. to the program for debugging. 6.2 Implementation of each function This system belongs to the detection and display module. The data detected by PM2.5 is converted to the display screen through AD, and the data detected by temperature and humidity are directly displayed on the display screen. The principle of the purification function is that the outside air enters the filter, passes through two layers of filters, one layer of activated carbon filter, and one layer of HEPA filter, and finally passes the purified air out through the centrifugal vortex fan.
References [1] Guo Tianxiang, "51 Single Chip Microcomputer C Language Tutorial", Tsinghua University Press [2] Tan Haoqiang, "C Programming", Electronic Industry Press Part of the program is as follows: #include
#include "LCD1602.h" //Add LCD1602 header file #include "dht11.h" //Add DHT11 header file #include "adc0832.h" #include "intrins.h" #include "delay.h" #include "1602xs.h" #include
//uchar Rx_buf[4],Rxnum=0; uchar receiveData = '*'; //'1' '#' '%' /*************************************************************************** * Function name: UsartInit() * Function: Set serial port * Input: None * Output: None *********************************************************************************/ void UsartInit() { SCON=0X50; //Set to working mode 1 TMOD=0X20; //Set counter working mode 2 PCON=0X80; //Double the baud rate TH1=0XF3; //Set the initial value of the counter, note that the baud rate is 4800 TL1=0XF3; ES=1; //Open the receive interrupt EA=1; //Open the total interrupt TR1=1; //Open the counter} /*UART sends one byte void Usart_send_byte(char dat) { SBUF = dat; while (TI == 0); TI = 0; }*/ /* UART sends string void Usart_send_string(unsigned char *buf) { while (*buf != '\0') { Usart_send_byte(*buf++); } } */ /******************************************************************************* * Function name: main * Function function: Main function * Input: None * Output: None *********************************************************************************/ void main() { LCDXS(); UsartInit(); // Serial port initialization// uchar Tx_Buf[15]; while(1) { LCDXS(); if(receiveData == '1') { BUZZER = 1; } else if(receiveData == '0') { BUZZER = 0; } else if(receiveData == 'L') { relay = 0; } else if(receiveData == 'O') { relay = 1; } else if(receiveData == 'V' ) { LED1=0; } else if(receiveData == 'E') { LED2=0; } else if(receiveData == 'Y') { LED3=0; } else if(receiveData == 'U') { LED1=1; LED2=1; LED3=1; } /* Tx_Buf[0]='T'; //Frame headerTx_Buf[1]=T1_data/10%10+0x30; //Send the temperature and humidity data to the sending array and send it to the Bluetooth module for the mobile phone APP to displayTx_Buf[2]=T1_data%10+0x30; Tx_Buf[3]=R1_data/10%10+0x30; Tx_Buf[4]=R1_data%10+0x30; Tx_Buf[5]=PMVAL/1000+0x30; //Send the pm value data to the sending array and send it to the Bluetooth module for the mobile phone APP to display Tx_Buf[6]=PMVAL/100%10+0x30; Tx_Buf[7]=PMVAL/10%10+0x30; Tx_Buf[8]=PMVAL%10+0x30; Tx_Buf[9]=0;//Terminator Tx_Buf[10]=0;//Terminator Tx_Buf[11]=0;//Terminator Usart_send_string(Tx_Buf); //Serial port sends temperature and humidity data out*/ } } /******************************************************************************* * Function name: Usart() interrupt 4 * Function: Serial communication interrupt function * Input: None * Output: None ******************************************************************************/ void Usart() interrupt 4 { receiveData=SBUF;//Output received data RI = 0;//Clear receive interrupt flag SBUF=receiveData;//Put received data into transmit register while(!TI); //Wait for sending data to be completed TI=0; //Clear send completion flag } /*void UsartInterrupt(void) interrupt 4 { ES=0; //Disable interrupt if(RI) //Received data { Rx_buf[Rxnum]=SBUF; //Receive data into array if(Rx_buf[Rxnum]==0x08) Rxnum=0; else Rxnum++; if(Rx_buf[0]==0x01)//LED1 light { if(Rx_buf[1]==0x01)//Turn on light LED1=0;//Turn on light else LED1=1; //Turn off light } if(Rx_buf[0]==0x02)//LED2 light { if(Rx_buf[1]==0x01)//Turn on light LED2=0;//Turn on light else LED2=1; //Turn off light } } RI=0; ES=1; //Disable interrupt } */ #include
void WriteCOMDATA(uchar LCD_DATA,uchar N) { Delay(5); E=1; RW=0; RS=N; LCD_PINDATA=LCD_DATA; E=0; } /**************************************************** ** Function name: void LCD_init(void) ** Function function: LCD1602 initialization operation ** Input: None ** Output: None ** Description: ************************************************/ void LCD_Init(void) { WriteCOMDATA(0x01,0); Delay(500); WriteCOMDATA(0x38,0); Delay(10); WriteCOMDATA(0x06,0); Delay(10); WriteCOMDATA(0x0C,0); Delay(10); } /************************************************ ** Function name: void WriteChar(uchar Row,uchar Col,uchar Num,uchar *pBuffer) ** Function: Write the specified number of characters at any position ** Input: Row: the row where the character to be written is located, which can only be 1 or 2; Col: the column where the character to be written is located, which can only be 0---15 Num: the number of characters to be written pbuffer: the first address of the character to be written ** Output: None ** Description: ************************************************/ void WriteChar(uchar Row,uchar Col,uchar Num,uchar *pBuffer) { uchar i; if(Row==1)Row=0x80+Col; else Row=0xC0+Col; WriteCOMDATA(Row,0); for(i=Num;i!=0;i--) { WriteCOMDATA(*pBuffer,1); pBuffer++; } } #include
#include "LCD1602.h" //Add LCD1602 header file #include "dht11.h" //Add DHT11 header file #include "adc0832.h" #include "intrins.h" #include "delay.h" #include "1602xs.h" #include "led.h" #include
Yes, this work has a good idea and strong practical significance. Keep up the good work and I hope there will be more excellent works
Details
Published on 2018-9-4 11:03