- Home >> News >> Blog articles >> Appliances & Tools
WiFi smart air purifier development
Frequent human social activities have put enormous pressure on the environment, the air quality has declined rapidly, and the haze weather has become more and more serious. Air pollution has seriously endangered human health. Among them, PM2.5 particles in the air are mainly harmful to the human body. Particle molecules can not only enter the respiratory tract, but also penetrate human cell walls, which leads to an increased risk of respiratory and cardiovascular diseases. Air purifiers targeting PM2.5 have become standard equipment for families in northern my country.
With the rapid development of the mobile Internet, "Internet +" has become a fashion in the design of household electronic products. The use of mobile terminals for device control greatly facilitates and improves the human-computer interaction function. This paper adopts STM32F103 and PM2.5 concentration sensor, temperature and humidity sensor and WIFI module, etc., and designs functions such as real-time display, alarm and automatic start and stop control of air purification motor with PM2.5 concentration, temperature and humidity and other environmental parameters, and has The air purifier that realizes the communication of the mobile phone APP and related operations through WiFi meets the growing health needs of the people.
1. The overall design of the air purifier system
The air purifier is mainly composed of motor, fan, air filter and other auxiliary purification devices, such as negative ion generator, high voltage circuit and so on. Among them, the quality of the air filter directly affects the effect of the air purifier. This paper mainly designs the electronic control system of the air purifier. In the system design, STM32F103C8T6 is used as the main control chip. The concentration of PM2.5 in the air is detected by the Sharp GP2Y1014AU dust sensor. At the same time, the temperature and humidity data in the air and the air quality detection data These three main input data are transmitted to the CPU, and after being processed by the single-chip microcomputer, the parameters are displayed using the OLED display module, and the ESP8266WiFi module is used for communication at the same time, and the collected data is transmitted to the mobile phone APP. The overall design block diagram of this system is shown in Figure 1, and the basic power supply part is ignored for the sake of simplicity.
2. Sensor selection and circuit design of air purifier
2.1 PM2.5 sensor interface circuit design
PM2.5 is detected by GP2Y1014AU dust sensor module. Its working principle is to detect the content of dust in the air through the reflection of infrared light-emitting diodes, and judge the concentration of PM2.5 by the height of the output pulse. Its output is a voltage analog quantity proportional to the dust concentration in the air, and its sensitivity is 0.5 V/0.1 mg/m3. The pins 1 and 2 of the sensor module are the power supply and ground of the working power supply. Pin 3 is the infrared light-emitting diode inside the sensor. By turning it on as an analog input to collect data, it is connected to the IO port of the microcontroller. Then pin 4 is ground GND. Pin 5 is used as a sensor output port for AD conversion with the microcontroller. Pin 6 is connected to the power supply.
2.2 Temperature and humidity sensor interface circuit design
The DHT11 temperature and humidity sensor module is a single-bus serial interface, the humidity measurement range is 0%~100%, and the measurement error is ±5%; the temperature measurement range is 0~50°C, and its error is ±2%. The operating voltage of the sensor module is 3.3~5 V, and the output form is digital output.
2.3 Motor interface driver
The MCU controls the voltage output of the L298N driver through the duty cycle of the PWM, making it continuously adjustable from 0 to 12 V. L298N contains 4 logic drive circuits inside. Among them, the L298N chip can support two input and output channels. ENA and ENB are the enable channel terminals. They are connected to the PWM output of the STM32 through ENA to enable the L298N driver. Since only one motor is controlled, only IN1 and IN2 are needed. As the input interface, OUT1 and OUT2 are connected to the motor as the output end, so that the single-chip microcomputer can drive the rotation of the motor to the L298N, and realize simple cleaning switch operation.
2.4 WiFi module interface design
The ESP8266 WiFi module uses a serial port to communicate with the MCU, and has a built-in TCP/IP protocol stack, which can realize the conversion between the serial port and WiFi. Through the ESP8266 module, the traditional serial device is only configured through a simple serial port, that is, it only needs to transmit its own internal data through the network (WiFi). It can support three working modes, that is, STA, AP, and STA+AP combined mode. The STA mode is connected to the Internet through a router, and the mobile phone or computer can remotely control the device through the Internet. In AP mode, the ATK_ESP8266 module is used as the hotspot to realize the direct communication between the mobile phone or the computer and the ESP8266, so as to meet the needs of LAN wireless control. STA+AP is an enhanced version of the two modes, that is, it can realize seamless switching through Internet control, which is convenient for users to operate. The module has 6 interface pins, among which the VCC pin is mainly connected to the power supply, GND is connected to the ground, the TXD pin of the module is used as the serial port sending pin, connected to the RXD pin of the MCU, and the RXD pin of the module is used as the serial port The receiving pin is connected to the TXD of the MCU, RESET is the reset pin, and the low level is effective, and IO_0 is used for firmware programming. In the default state, the low level is the programming mode, and the high level is the running mode.
3. Air purifier software design
3.1 System software design
The system software uses KEIL5 software for single-chip C language programming. The software mainly includes the initialization of the single-chip system (clock initialization, GPIO initialization, etc.), the initialization of the required sensors, the initialization of the WiFi communication module, the initialization of the OLED, the working code and related data. Sending, transmitting, receiving codes, etc., through a series of work, the data is finally transmitted to the mobile phone APP through the LCD screen and the WiFi module. The first is the system initialization of the STM32 microcontroller:
1) The system clock needs to be enabled. This is because the STM32 MCU has a clock switch for each functional peripheral. When it needs to work, the switch is turned on, and when it is not needed, the switch is turned off, so as to reduce energy consumption. Therefore, after the power supply is powered on, enabling its clock is the first step. 2) Enable the GPIO input and output ports, that is, enable the ENABLE initialization operation of the IO ports that need to be used. 3) There is also serial port initialization, which is to set a consistent baud rate, otherwise problems may occur when the system is running. Then initialize the sensor and the LCD screen, such as DHT11 temperature and humidity sensor module, GP2Y1014AU dust sensor, etc. Each sensor module works in an orderly manner, and the MCU obtains data such as temperature, humidity, voltage-dust ratio through the serial port, and displays them The parameters are displayed on the screen. At the same time, the microcontroller will process the data accordingly. If the concentration exceeds a certain value or range, an alarm will be issued and the air will be purged. At this time, the WiFi module needs to be initialized before the data can be transmitted to the mobile phone through the WiFi module.
3.2 Display subroutine design
This design uses the display screen to display parameters such as temperature, humidity, and PM2.5-related concentrations. Before obtaining these data, the first step that must be done is to calibrate the screen, and judge whether the screen is calibrated. If it has been calibrated, then Start to acquire the corresponding data; if the corresponding calibration has not been performed, perform initialization, and continue to execute the operation after the calibration is completed.
3.3 APP software
The APP software uses the android studio development platform. Android studio is an Android integrated development tool launched by Google, based on IntelliJ IDEA. It provides integrated development tools for development and debugging. The terminal APP designed this time is mainly to realize the operation of PM2.5 concentration, temperature, humidity and other parameters. This time, the main purpose is to use the WiFi module as a hotspot, and then connect the mobile phone APP to it, so as to realize the simple communication data connection between the MCU and the APP through WiFi. The APP side is mainly a network debugging assistant. Through the configuration of the WiFi module, set the WiFi name, password, and TCP service port number. The mobile terminal needs to connect to WiFi first, then enter the network debugging assistant, activate the port number and establish a good connection. The WiFi name set this time is "ESP8266", the password is "012345678", the IP and port numbers are "192.168.4.1" and "5000" respectively.
Summarize
The smart air purifier designed in this paper has realized the real-time measurement of PM2.5 concentration after testing, and can realize the setting of over-limit alarm parameters through APP and buttons. When it exceeds 600 ug/m3, an alarm signal will be generated to prompt the purification switch Operation; the temperature and humidity detection accuracy reaches 20~50℃, and the humidity is 20%~98%; at the same time, it realizes related operations such as switch control and parameter display of the device through the APP through WiFi. The air quality is monitored through the mobile terminal, which greatly facilitates the user. The user can switch the air purifier through the key on the mobile terminal to perform corresponding switch operations.
The above is the development example of the air purifier circuit board introduced by Shenzhen Zuchuang Microelectronics Co., Ltd. for you. If you have air purifier control board solution development needs, you can trust us. We represent a variety of single-chip microcomputers, voice chips, dual-mode Bluetooth ICs, and wifi chips. Brands include Songhan MCU, Yingguang MCU, Jerry Bluetooth, Ankai Bluetooth, Allwinner, and Realtek. Our technical services include: PCB design, MCU development, Bluetooth solution, software and hardware custom development, APP development, small program development, WeChat official account development, etc. It can also undertake the design of intelligent electronic products, the development of living appliances, the research and development of beauty equipment, the application of Internet of things platform, the smart home control system, the development of TWS earphones, Bluetooth earphone speakers, the development of children's educational toys, the design of electronic education products, etc.
Proposal recommendation
- TOP