Smart home (also known as smart house) is a safe, efficient, comfortable, convenient and environmentally friendly living environment that takes residence as a platform, combines architecture, network communication, information appliances, equipment automation, and integrates systems, structures, services and management. It integrates facilities related to home life by using integrated wiring technology, network communication technology, smart home system design solution security technology, automatic control technology, and audio and video technology to build an efficient management system for residential facilities and family schedule affairs. Compared with ordinary home systems, smart homes not only meet people's basic requirements for living environment, but also provide comfortable, safe and pleasant family living space. It can also actively provide all-round information services, combine external resources, and make intelligent responses. However, such systems are usually expensive, have a single control method, and are easily interfered with. Therefore, while designing and realizing intelligent control, it has become an inevitable trend to develop a smart home system that is low-cost, highly practical and can be popularized in ordinary people's homes.
This device allows users to easily grasp all aspects of the home even if they are thousands of miles away. It is very convenient to remotely control various household appliances, improve the safety, convenience and comfort of the home, achieve environmental protection and energy conservation, and make people enjoy home life more easily.
1 System overall structure
The overall structure of the system is shown in Figure 1. It is mainly composed of a microcontroller and multiple sub-modules. The microcontroller is mainly used to analyze and process user operation information, sensor information, control the reception and transmission of the mobile phone module, and perform corresponding tasks according to priority. The sub-module part includes: access control/security, human-machine interface, CAN-BUS communication network, wireless communication network, video monitoring module, voice recognition, window opening motor drive controller, multi-channel sensor interface, switching power supply circuit, etc.
Figure 1 System composition block diagram
The system host is connected to the Internet through a router running OpenWRT. After setting up the network port, when accessing through the Internet, this system provides an interface with good user experience. Users only need to enter the domain name to log in to the server running at home to remotely control the devices at home.
2 Smart Home System Hardware Platform
This smart home system is mainly composed of a main control chip and functional peripherals. The main control chip STM32F103RBT6 is a processor based on the Cortex-M3 of ARM 32. The maximum operating frequency can reach 72 MHz. It has a built-in large-capacity high-speed memory, which can easily accommodate the space required for the smart home system; it has a flexible static memory controller of FSMC, which is used to drive the LCD screen to greatly improve the refresh rate; at the same time, it has an embedded controller that supports CAN 2.0B, and can form a CAN network without an external dedicated chip.
LD3320 is a speech recognition and synthesis chip that integrates high-precision A/D and D/A interfaces. It does not require any external auxiliary chips, such as Flash memory, RAM, decoding, power amplifier chips, etc., and can directly realize the speech recognition function of speech recognition/speech/interactive functions. The main control chip transmits appropriate data to the corresponding register of the chip through the four-wire SPI digital interface. After setting the recognition keywords, recognition time length, microphone gain, etc., the voice recognition function starts to run. When the system generates conditions that require voice response, the MCU can send the data encoded in mp3 to the chip. After configuring parameters such as volume, the voice synthesis function will be run immediately, and the power amplifier built into the chip will drive the speaker to sound.
nRF24L01 is a new single-chip highly integrated RF transceiver device that operates between the 2.4 and 2.5 GHz ISM band. It has built-in frequency synthesizer, power amplifier, crystal oscillator, modulator and other functional modules, and integrates enhanced ShockBurst technology, in which the output power and communication channel can be configured through the program. Its multiple low-power modes and 40-bit ultra-long device address ensure the security of its communication and high transmission rate, making it suitable for application in this system.
CAN bus communication has the advantages of high communication rate, high reliability, easy connection and high cost performance. It is widely used because of its high-speed network and various networks with lower costs. Since the communication of the smart home system is in the complex electromagnetic interference of the home power supply line, this system uses a CAN twisted pair converter to form a home appliance communication network, which is reliable enough to be used in harsh environments with strong interference.
3 Smart Home System Software Design
One of the important purposes of smart home is to achieve a comfortable and convenient home life. Therefore, a set of upper computer operation interfaces with good user experience must be designed, including detailed settings of smart home appliances on the computer side, and Android client applications that can reflect the basic control needs of home appliances with the convenience of mobile phones. The main software design process is shown in Figure 2. The implementation of system tasks is implemented by two different threads: the NetStream program for network communication and the program for local data processing.
Figure 2 Upper computer software design process
The local data processing program is divided into the following two parts according to the task: the user operation response part and the video stream data processing part. The user operation response part is mainly responsible for collecting data such as the buttons pressed by the user on the upper computer software and the commands entered, and then calculating and processing these collected data. After obtaining the results, they are encrypted and encoded, and finally loaded onto the network stream and automatically sent to the lower computer through the network. The video stream data processing part is the carrier of the smart home security monitoring function. After the software timer of the upper computer generates an overflow interrupt at a certain time interval, it connects to the router through TCP. After the account and password are verified, the image information of each frame of the surveillance camera in JPEG format can be obtained. After processing, these JPEG image information can be synthesized into 24 frames per second and displayed on the upper computer interface. Due to the visual persistence of the human eye, these continuous images can be regarded as achieving a smooth video effect. [page]
The NetStream part mainly solves the problem of communication between the upper computer and the lower computer. The security of the smart home system is a very important issue, and it is particularly important to establish a stable and secure connection. This system uses an SSL encrypted TCP/IP protocol. SSL, also known as the "Secure Sockets Layer" protocol, is a protocol that establishes a secure channel between the client and the server, which fully guarantees the security of the system communication process.
4 Construction of smart home appliance network
In order to achieve the purpose of controlling smart home appliances, it is necessary to connect each home appliance to the network. The lower-level home appliance network of this system includes CAN bus network, 2.4G radio frequency wireless network and line-of-sight infrared wireless network. These three communication networks are applied at the same time, and they have the advantages of good reliability, convenient connection and strong versatility of smart home networks, which makes up for the limitations of a single communication method. If the network can be reasonably arranged, the system cost will be effectively reduced.
One of the most important functions of the lower-level software part is to process the encrypted data sent by the upper computer. After the data is decrypted, it is a string with function description and corresponding parameters. In order to facilitate the writing of the program, the parameter part of the string needs to be converted from continuous and unknown length numbers to integer variables and stored in the memory. The implementation code is as follows:
This function calls the atoi function in the standard library function stdlib.h provided by IAR Embedded. The atoi function function description is /*convert string to int*/, which means that the string is directly forced to be converted into an integer data. The communication protocol between the host computer and the slave computer of this system is specially designed by us. The string header contains a command byte with an unpredictable length. Therefore, before calling the atoi function, it is necessary to determine which part of the string the parameter in the data packet starts from and get the correct pointer to the string parameter position.
As shown in Figure 3, it is a flowchart of the master chip of the smart home slave computer. The master chip runs the μC/OS lightweight embedded real-time operating system, which uses a preemptive real-time multi-tasking kernel, which means that the processor runs the highest priority task at any time. In this way, it is very convenient to realize the scheduling of various tasks of the entire slave computer, and at the same time ensure the real-time performance of the system. After the master chip starts μC/OS, four tasks are established: speech recognition task, serial port receiving task, LCD display task, and intrusion detection task. In voice recognition, first check whether the recognition completion bit of the LD3320 status register is set, then respond, execute the corresponding action, voice broadcast the execution result, and send a semaphore to indicate that the status of the indoor electrical appliances has changed and the display needs to be updated; the serial port receiving task is to accurately receive the data sent by the host computer, decrypt and decode it, and perform corresponding operations on the electrical appliances according to the instructions; the LCD display task will always detect whether there is a semaphore to update the display. If there is a semaphore, the entire screen will be refreshed, and the corresponding semaphore will be automatically cleared; after the security system is started, real-time monitoring will be run to judge the safety index of the home based on the status of a densely populated sensor network, and the intelligent software will decide when an alarm signal should be issued.
Figure 3 Lower computer software design process
Figure 4 PC-side upper computer control software
5 Design of host computer control software, PC and Android mobile phone
After the server (a router running the openwrt system) is running, the USB camera is automatically mounted. After setting the IP and password information in the host computer setting window on the PC, the host computer connects to the server via TCP to obtain video/picture information and displays it on the GUI interface of the host computer. Other controls in the interface also use TCP to connect to the server to send or obtain information. After receiving the request, the server forwards the information of tcpserver to the serial port through the ser2net process to communicate with the lower computer. The design of the mobile phone host computer is relatively simple, as shown in Figure 4. The large button is convenient for controlling various electrical appliances in the home.
6 Conclusion
This paper designs a smart home system based on the STM32F1 series, introduces the overall architecture of the system in detail, and gives several important hardware devices and server software implementation methods.
It realizes the monitoring of indoor real-time power, indoor temperature, and weather, as well as remote control of home appliances through internal/external networks, remote video monitoring functions, and security facilities. The voice recognition accuracy rate reaches 88%. The network server part adopts the solution of replacing the PC with a router. The overall standby power consumption of the system is ≤5 W. The design of the mobile phone control terminal has clear and easy-to-operate buttons, which can conveniently control the working status of some home appliances. Finally, the functions required by smart home are realized.
Previous article:Design of Synchronous Control System for Printing and Dyeing Machine Based on STM32 and CAN Bus
Next article:Design of smart home system based on S3C6410
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Some useful information: RVB2601 development board program download automatic operation and OLED screen protection
- To the netizens who entered the Pingtouge RVB2601 competition (reference materials, technical support, experience sharing, work submission and selection criteria)
- Summary: RCSN experience W806 Lianshengde 9.9 yuan development board
- Hardware Design: Circuit Design of DSP TMS320C5509A
- VaST's latest modeling tool enables comprehensive software development before tapeout
- What are the methods of remote communication? Which manufacturers have used specific products?
- Regarding "Circuit Design Based on Operational Amplifiers and Analog Integrated Circuits", there is a concept of "Pole" that is not clear
- RISC-V IDE MRS usage notes (Part 3): Improving floating-point calculation efficiency
- Pan it STM32H750 3 (lan8720 Ethernet test --iperf)
- Another question about the matrix keyboard