Zacytuj

Introduction

Smart home is an ideal lifestyle for many people for a long time, and with the support of modern information technology, it has finally become a reality [1-3]. The rapid development of the Internet has provided new ideas and directions for the smart home market, opening a new era of intelligent “Internet of things + home products”. With the continuous improvement of people′s requirements for home life, the application of smart home products is born, through the in-depth mining of diversified needs of users, the use of existing technologies of the Internet of things and home products to link and integrate, can make smart home products more intelligent, humanized and convenient, meet people′s experience and emotional needs of smart home products, improve people′s living quality [4-5]. This paper designs a system which integrates hardware and software and can measure and transmit various data. The system can obtain the information about the external environment in real time, display it on the single chip microcomputer display, and send the data to the communication equipment in real time [6-7]. The smart home control system can greatly improve the comfort and reliability of people′s home environment, so as to improve people′s living standards [8].

Related works

Smart home has become a popular trend in foreign markets [9-10]. In 1984, the first “intelligent building” in the United States opened the prelude to smart homes. In recent years, developed countries such as Europe, the United States, and Japan have constantly innovated in the research and application of smart home technology. For example, Google′s smart Home system Google Home, Apple′s HomeKit, etc., can realize intelligent control of home products, such as smart light bulbs and smart sockets. Germany Berlin Racecourse district completed the “AAL” system model room, AAL system used to improve the life of the elderly home. It includes a scalable intelligent technology platform on which a wide range of instruments can be interconnected to build a responsive environment, profiling and responding to customer situations and environmental objectives. Spain built one of the most advanced smart houses in Europe in 2005, which focuses on living in harmony with nature to meet people′s basic needs. Intelligent lighting is used in the room, which can automatically open and close the light source according to the sunshine condition, saving energy. In addition to the smart home, the roof of the smart house is also equipped with a temperature monitoring system to monitor temperature and weather conditions.

Compared with foreign markets, the smart home industry in the domestic market started late. Smart home in China about the rise of the late 1990s, and then entered a period of rapid development [10-15]. In recent years, with the wide use of single-chip microcomputer control technology, the design and application of smart home control system based on single-chip microcomputer has been effectively developed. Through the control function of embedded single chip microcomputer, the intelligent management function of residential buildings can be realized effectively. At present, home intelligence and property management, security, a variety of information services and management combined to provide high-tech intelligent means for the service and management of residential communities, in order to achieve fast and efficient value services and management, to provide a more safe and comfortable home environment. With the continuous enhancement of chip computing power and the large-scale application of 5G communication, cloud platform construction technology, video and audio AI algorithm technology, and product intelligence technology will all empower the smart home industry.

Ovrall design

This system mainly realizes data measurement, data communication and data processing. The data is measured by the DHT11 temperature and humidity sensor, the MQ3 alcohol concentration sensor and the DSM501A particle number sensor. Data communication is realized by ATK-ESP8266 serial port wireless communication module. Data processing and data reception are implemented using the Python programming language. Therefore, this system is divided into hardware design and software design.

Overall system design

The overall framework of the system is shown in Figure 1.

Figure 1.

Overall system architecture

As can be seen from the figure above, the system is composed of two parts, namely hardware and software. The hardware part is composed of STM32 MCU, sensor and TFTLCD display. The software part is a client application developed by the Python language.

Data measurement module

The hardware part of the data measurement module uses a total of three sensors. The system uses DHT11 sensor to measure temperature and humidity, DHT11 sensor output TTL high and low level, STM32 through a GPIO pin to measure; The system uses MQ3 sensor to measure alcohol concentration, MQ3 sensor outputs analog data, STM32 is measured by ADC peripheral; The system uses DSM501 to measure the number of PM2.5 particles, DSM501 to output pulse signals.

Data Transmission Module

The data transmission module transmits data through the ATK-ESP8266 module. ESP8266 module built by TCP/IP protocol stack, can send data over the wireless network. This module can set three modes, this system uses AP mode, which is equivalent to router. The module communicates with STM32 microcontroller through serial port, and communicates with computer through network.

Software module

The function of the software part mainly realizes three functions, data acceptance, data display and data preservation. Data acceptance is to accept the data sent by the ESP8266 module; Data display is to display the received data in accordance with the format on the client interface; Data saving is to save the data displayed by the client in a file.

System design and implementation
Hardware
Temperature and Humidity measurement module

The DHT11 sensor transmits DATA through the TTL level of the data pin. Use this sensor to transmit data “0” and “1”. When the sensor sends data “0”, it starts with a low level for a duration of about 12 to 14μs, followed by a high level for a duration of about 28 to 28μs. When data “1” is sent, it also starts with a low level for a period of 12 to 14μs, followed by a high level for a period of 116 to 118 μs. The DHT11 sensor distinguishes “0” from “1” by output a high level of different time lengths and verifies the sent data to ensure the accuracy of the data.

After the T/H sensor is initialized, the host sends a start signal and replies to the host before sending data. The size of the data sent is 40bit, 5 bytes. The first and second bytes are the integer and decimal parts of humidity, the third and fourth bytes are the integer and decimal parts of temperature, and the last byte is the check code, equal to the sum of the first four bytes. Through this byte, you can judge the accuracy of the sensor′s measurement data. One complete data measurement using the DHT11 sensor.

A complete temperature and humidity data measurement can be divided into four steps. The first step is to set the sensor to the input mode, and then the STM32 host sends the start signal to the sensor, and the sensor is set to the output mode after the transmission is completed. Step 2: If a sensor sends a response signal to the host, after sending the response signal, the sensor pulls the low level to prepare to send data, and pulls the low level to notify the host that it can now receive data; The third step is to send 40bit data from the sensor to the host. The last step is to calculate whether the data received by the host is correct. If it is correct, the data is saved to the memory for other modules to use. If the data is incorrect, jump to step 1 and start over.

MQ3 Alcohol concentration measurement module

The MQ3 sensor has two output ports, digital output port and analog output port. The digital output port outputs a low level when the alcohol concentration exceeds a set threshold, and the analog output port converts the alcohol concentration into an analog signal output. The system uses the analog output port to detect the alcohol concentration value, and reads the analog signal through the AD conversion function of STM32 SCM ADC module. The MQ3 sensor operates at a voltage of 5V, so the conversion of analog signals into electrical signals has a range of 0~5V.

There are five steps to measure alcohol concentration in this system. The ADC was initialized before the measurement, but not enabled. In this system, the first step is to start ADC and prepare the measurement analog data. Each ADC has multiple measurement channels, and this ADC uses channel 16 to measure alcohol concentration data. Step 2 Set the ADC acquisition channel and enable it. In the third and fourth steps, 20 sets of alcohol concentration data are measured using the ADC. The final step converts the data from the analog signal into a concentration value and saves that value.

PM2.5 particle number measurement module

PM2.5 particle counts are measured using the DSM501A dust sensor, which is based on the principle of light reflection to measure the amount of dust. The DSM501A dust sensor can measure smoke particles produced by tobacco burning, particles produced by pollen, particles in dust in houses, and more. The output mode of the DSM501 sensor is PWM pulse modulation output, using the principle of particle counter, can detect particles above 1 micron, and the built-in heater can realize self-suction air. The DSM501 sensor works at a voltage of 5V, and the sensor can work normally at a temperature of -10°C~60°C. The data measurement tends to be stable after 1 minute after the heater power is turned on. The function of the heater is: heating causes the updraft, so that the outside air flows into the module, easy to measure.

The DSM501 sensor consists of 5 pins. Among them, pin 2 and pin 4 are its output pins, the difference between them is that the No. 2 output pin can detect particles with a diameter of more than 1μm, while the No. 4 output pin can only detect particles with a diameter of more than 2.5 μm, and the No. 1 pin exists as its control foot, when the external resistance of the No. 1 pin can adjust the sensitivity of the No. 4 pin, and the No. 3 pin is connected to the 5V power supply to work. Pin 5 is grounded. The operating voltage standard of the DSM501A is 5.0V±0.5, and the maximum operating current can be 90mA.

When the LED light source irradiates on the suspended particles in the air, the light will be scattered, and the reflected light will be received at a specific Angle and converted into an electrical signal by the photoelectric sensor. The output per unit time is shown in Figure 2.

Figure 2.

Output PWM waveform of DSM501 dust sensor

From the figure above, it can be seen that the output of the DSM501 sensor is a PWM waveform. When there are no dust particles, the output is about 4.5V high level, when there are dust particles, the output is about 0.7V low level. The DSM501 sensor measures the number of particles, not the concentration, and cannot be converted to each other. The DSM501 sensor calculates the number of particles by calculating the percentage of low levels per unit time, measured in units (units per liter). The measurement process of PM2.5 particle number in this system is shown in Figure 3 below.

Figure 3.

Flow chart of PM2.5 particle number measurement

As can be seen from the figure above, the particle count is measured by two timers. A timer is used to set the unit time, usually the unit time is set to 30S, this time is recommended by the official document of the sensor, its measurement data is relatively accurate; A timer is used to capture low-level pulses. This system uses TIM2 and TIM3 two timers. When starting, start two timers, and then enter the TIM2 or TIM3 callback function when the timer interrupt is met, calculate the length of a low-level pulse in the TIM2 callback function, and add the pulse time of each measurement. After setting the unit time length in TIM3, calculate the data result once, clear the accumulated pulse length, and start the calculation again.

ATK-ESP8266 Wireless transmission module

The ATK-ESP8266 sensor is a serial wireless data transmission module. ATK-ESP8266 module uses serial port and level machine for communication, the module value TCP/IP protocol stack, can realize the conversion between serial port and WIFI, only need simple configuration can transmit data through the network. ESP8266 module supports three modes, serial port to STA mode, serial port to AP mode, serial port to STA+AP mode. The AP mode provides wireless access services, allows other wireless devices to access, and provides data access. The general wireless routing/bridge works in this mode. Aps are allowed to connect to each other. STA mode is similar to the wireless terminal, STA itself does not accept wireless access, it can be connected to the AP, the general wireless card that works in this mode. STA+AP mode is both functions can be met.

The system uses AP mode. ATK-ESP8266 module is used as router + server to send the data collected on the single chip computer. Use the computer to connect to the ATK-ESP8266 router and receive data through TCP/IP protocol. Figure 4 shows the process of using ATK-ESP8266 in the system.

Figure 4.

Flowchart of the ATK-ESP8266 wireless transmission module

The ATK-ESP8266 module starts to work and exits as shown in the figure above. According to the above flow chart, check whether the ATK-ESP8266 module is successfully connected after the start. If the connection is successful after five checks, proceed to the next step. After the ATK-ESP8266 connection is successful, configure the corresponding function mode. The first step is to turn off the output and set it to AP mode. After the setting is complete, you need to restart the module before it can be used. Then set the router SSID and password, start the connection mode after the setting is complete, and set the server port. After starting the server, you can send and receive data. When you need to exit, click the KEY0 button on the MCU to exit the wireless transmission mode.

Software part
System Analysis

In this system, the ATK-ESP8266 module is used as the data sender, and the computer is used as the data receiver. However, when in use, the ATK-ESP8266 module needs to be configured as AP mode, and the single chip needs to be connected to the AP module router.

The client application of this system is developed using Python language and runs on Windows operating system. Python language development software has some advantages, because the Python language is an object-oriented programming language, used to develop a small amount of program code, easy to modify, easy to understand, compatibility is better, you can run in Windows, Linux, Mac operating systems. There are also various useful Python libraries in the Python language community, such as: pandas data processing, regular expressions, network programming, graphical interface development, object-oriented programming, etc. In this chapter, we will introduce the main modules of the client application and the main Python libraries used.

Software Running Environment Actual system test

There are two ways to run the software, one is to run the Python script directly, the other is to generate an executable file through the PyInstall tool, and then run the executable file. The advantage of running scripts directly is that they can be run on different operating systems, but the Python interpreter and related Python libraries must be installed. The advantage of running executable files is that you do not need to install the Python interpreter, Python libraries, but can only run on Windows operating systems.

Actual system test

In addition to introducing the various functions and sensors of the system, this paper will also test the various functions of the system and analyze the measurement data of the sensor. In this chapter, DHT11 temperature and humidity measurement data, MQ3 alcohol concentration measurement data, DSM501 particle number measurement data, ATK-ESP8266 module transmission data will be analyzed, and the function of the client software will be tested.

Temperature and Humidity Data Measurement

After several measurements, the results measured by the DHT11 sensor are shown in Figure. 5.

Figure 5.

Measurement data of temperature and humidity

The figure 5 below shows the data measurement display when the system is in common mode. The framed data are the temperature and humidity of the current region. The unit of the temperature is °C, and the unit of the humidity is %RH.

After multiple measurement records, the temperature and humidity data in a period of time are shown in Table 4.1. It can be seen from the table that the temperature measured by the DHT11 sensor is maintained between 24.50°C and 25.30°C for a period of time. In the local area, the temperature read by mobile phones is around 25 degrees Celsius. Through comparative analysis of the two data, it can be concluded that the temperature measured by DHT11 sensor is more accurate and the error is relatively small. As can be seen from the table, the humidity value measured by the DHT11 sensor remained between 46 and 48% over a period of time, while the humidity value read by the mobile phone in the local area was 51% over the same period of time. By comparison, the data measured by the sensor is lower than the actual data, but in general, the error is relatively small.

TEMPERATURE AND HUMIDITY MEASUREMENT DATA PROCESSING TABLE

Time Temperature(°C) Humidity(%)
Sat May 7 23:01:42 2022 24.90 45.00
Sat May 7 23:01:44 2022 24.90 45.00
Sat May 7 23:01:46 2022 24.90 48.00
Sat May 7 23:01:48 2022 24.90 48.00
Sat May 7 23:01:50 2022 24.90 49.00

It can be seen from the above data measurement comparison that the temperature and humidity measured by this system is relatively accurate, the data measurement results are relatively small and the data is stable, and the data measured by DHT11 sensor can meet the needs of users.

Alcohol concentration measurement

After measurement, the alcohol concentration measurement results are shown in Figure 6.

Figure 6.

Measurement of alcohol concentration

The alcohol concentration was measured indoors and the measurement result was 10.40ppm. After several measurements, the alcohol concentration data is shown in Table 2 below. The alcohol concentration was maintained between 7.28 and 12.19ppm, and the measurement data was relatively stable.

ALCOHOL CONCENTRATION DATA MEASUREMENT TABLE

Time Alcohol concentration(ppm)
Sat May 7 23:01:42 2022 9.36
Sat May 7 23:01:44 2022 12.12
Sat May 7 23:01:46 2022 8.29
Sat May 7 23:01:48 2022 7.68
Sat May 7 23:01:50 2022 8.22
PM2.5 particle number measurement

Through measurement, the measurement results of PM2.5 particle number are shown in Figure 7.

Figure 7.

Measurement value of PM2.5 particle number

This measurement was made in an indoor environment. According to the above figure, the number of PM2.5 particles tested is 19.07 per liter. After repeated measurements, the measurement results of PM2.5 particle number are shown in Table 3, where the value of PM2.5 particle number is maintained between 5.80 and 21.47 per liter. The output data of the sensor is stable and the data change is small.

PM2.5 PARTICLE COUNT MEASUREMENT TABLE

Time PM2.5 concentration (per/ liter)
Sat May 7 23:01:42 2022 7.96
Sat May 7 23:01:44 2022 7.25
Sat May 7 23:01:46 2022 7.25
Sat May 7 23:01:48 2022 7.25
Sat May 7 23:01:50 2022 9.84
ATK-ESP8266 Wireless transmission test

In the wireless transmission module, the data is sent through the ATK-ESP8266, and the data is received through the computer client application. The application is developed using the Python language and receives data via TCP/IP network programming.

Test the data sending function of ESP8266 wireless module and the data receiving function of client software. The wireless transmission mode on STM32 MCU is shown in Figure 8.

Figure 8.

Wireless transmission interface

In the wireless transmission mode, the corresponding data is calculated by STM32 MCU and sent to the client software through the ESP8266 module. The format of sending data is “T: temperature; H: Humidity; AC: Alcohol concentration; PMC: Number of particles “where T stands for temperature, H for humidity, AC for alcohol concentration, and PMC for number of particles. After the client receives the data, the received data and the received time are displayed in the data information area. The data received by the client is shown in Figure 9.

Figure 9.

Wireless transmission interface

According to the figure above, after the client connects to the router simulated by STM32 and successfully logs in to the server, it begins to receive data. The received data is displayed in the Data Info area of the client interface, and the received data time is added. The IP address and Port of the server are displayed in the Configuration Information area on the client. There are four buttons in the Control area. The Login button is used to log in to the server. Click the “Log Out” button to stop the client receiving data and clear the server information in the “Configuration Information” area. Click the “Clear” button to clear the received data in the “Data Information” area; Click the “Output” button to save the data in the “Data Information” area to Excel in the format shown in Table 4 below.

STORAGE FORMAT OF MEASUREMENT INFORMATION

Time Temperature(°C) Humidness(%) Alcohol (ppm) PM2.5 (per/liter)
Sat May 7 23:01:42 2022 24.90 45.00 9.36 7.96
Sat May 7 23:01:44 2022 24.90 45.00 12.12 7.25
Sat May 7 23:01:46 2022 24.90 48.00 8.29 7.25
Sat May 7 23:01:48 2022 24.90 48.00 7.68 7.25
Sat May 7 23:01:50 2022 24.90 49.00 8.22 9.84

Through the data in the Table4, the smart home collection unit can upload the surrounding environment to the user in real time. The user achieves the real-time control function of the home environment parameters.

Conclusions

The figure in the next page shows the sample data from the water temperature and turbidity sensors. Through this period of design and development, the following work has been completed:

1) This system uses STM32 as the main control chip to develop the smart home system on the STM32MINI development board. The STM32 development board has a low-power mode with wake-up function. This system uses this function to design a switch module, which has a higher priority and can interrupt any other task being performed. On this basis, the function of automatic screen is added, and the timer control system is used to automatically disconnect the power supply of TFTLCD display after counting to the set threshold.

2) This system can measure a lot of data, these data are more in line with people′s needs. The system uses DHT11 sensor to measure temperature and humidity; Measurement of alcohol concentration using MQ3 sensor; The PM2.5 particle count was measured using the DSM501 sensor.

3) This system has two main modes, ordinary mode and wireless transmission mode. In normal mode, the measured data is displayed on the TFTLCD display. In wireless transmission mode, the measured data is sent to the computer through the built-in TCP/IP protocol through the ATK-ESP8266 module.

4) The innovation of this system lies in the use of the popular Python language to develop applications. The Python language is maliciously compatible with many platforms and can be easily ported to Windows, Linux, and Mac operating systems. Python supports both procedural and object-oriented programming. Python is open source software, so the community is relatively complete, and various problems can be discussed and discussed in the community. This time it was tested on the Windows operating system, and the test results show that it can meet all task requirements.

eISSN:
2470-8038
Język:
Angielski
Częstotliwość wydawania:
4 razy w roku
Dziedziny czasopisma:
Computer Sciences, other