Design and Implementation of STM32 Based Smart Home System

Smart Home (also known as Smart Home) is a safe, efficient, comfortable, convenient and environmentally friendly living environment that combines architecture, network communication, information appliances and equipment automation with a residential platform. It integrates systems, structures, services and management. Utilize integrated wiring technology, network communication technology, smart home system design security technology, automatic control technology, audio and video technology to integrate home life related facilities, and build efficient management system for residential facilities and family schedules. Compared with ordinary home systems, smart home not only meets the basic requirements of people's living environment, but also provides comfortable, safe and pleasant family living space. It can also provide a full range of information services, and combine external resources to make intelligent responses. However, such systems are often expensive, have a single control, and are susceptible to interference. Therefore, while designing and implementing intelligent control, it is an inevitable trend to develop a smart home system that is low in cost, practical and can popularize ordinary people's homes.

This article refers to the address: http://

This equipment allows users to easily grasp all aspects of the home from a thousand miles away. It is convenient to remotely control all kinds of household appliances, improve the safety, convenience and comfort of the home and realize the environment. Protect and save energy, making it easier for people to enjoy their home life.

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 receiving and sending of mobile phone modules, and perform corresponding operations according to priority. Task. The sub-module part includes: access control/security, human-machine interface, CAN-BUS communication network, wireless communication network, video monitoring module, voice recognition, window motor drive controller, multi-channel sensor interface, switching power supply circuit, etc.

Design and Implementation of STM32 Based Smart Home System

The system host connects to the Internet through a router running OpenWRT. When the network port is set up and accessed through the Internet, the system provides a user-friendly interface. Users only need to input the domain name to log in to the server running at home to remotely control the devices in the home.

2 smart home system hardware platform

The smart home system is mainly composed of a main control chip and a function peripheral. The main control chip STM32F103RBT6 is a processor with ARM 32 Cortex-M3 as the core. The maximum operating frequency is up to 72 MHz. The built-in high-capacity high-speed memory can easily accommodate the space required for smart home systems. It has FSMC flexible static memory controller. It is used to drive the LCD screen to greatly improve the refresh rate. At the same time, it has a controller supporting CAN 2.0B embedded in it, which can form a CAN network without external expansion of the dedicated chip.

The 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 chip, such as flash memory, RAM, decoding, power amplifier chip, etc., and can directly realize speech recognition/voice. / Interactive function of speech recognition. The main control chip transmits the appropriate data to the corresponding register of the chip through the four-wire SPI digital interface, and after setting the identification keyword, the recognition time length, the microphone gain, etc., the speech recognition function starts running. When the system generates a condition that requires a voice response, the MCU can send the data encoded in mp3 to the chip, configure the volume and other parameters, and then run the voice synthesis function, and the on-chip power amplifier pushes the speaker to sound.

The nRF24L01 is a new monolithic, highly integrated RF transceiver that operates between the 2.4 to 2.5 GHz ISM bands. Functional modules such as a frequency synthesizer, power amplifier, crystal oscillator, and modulator are integrated with the enhanced ShockBurst technology, where the output power and communication channels are configurable through the program. Its various low-power modes and 40-bit ultra-long device address ensure its communication security and high transmission rate, which is suitable for application in this system.

CAN bus communication has the advantages of high communication speed, high reliability, easy connection and high cost performance, and it is popularized for high-speed networks and various networks as lower costs. Since the communication of the smart home system is in the complex electromagnetic interference of the home power supply line, the system adopts a CAN twisted pair converter to form a home appliance communication network, which is sufficiently reliable to be applied in a harsh environment 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, it is necessary to design a set of user interface with good user experience, including detailed settings of smart appliances on the computer side, and basic control of home appliances that can reflect the convenience of mobile phones. Demand for Android client applications. 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 local data processing program.

Design and Implementation of STM32 Based Smart Home System

The local data processing program is further 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 the buttons pressed by the user to the upper computer software, and the commands input.

According to the data, the collected data is processed and processed, and the result is obtained, then 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 bearer of the smart home security monitoring function. After the software timer of the host computer generates an overflow interrupt for a certain time interval, it is connected to the router through TCP, and the account and password are verified correctly, then the surveillance camera can be obtained. The image information of the frame JPEG format is processed, and these JPEG image information can be synthesized and displayed on the upper computer interface 24 frames per second. Due to the Persistence of Vision of the human eye, these continuous images can be regarded as It is a smooth video effect.

The NetStream part mainly solves the problem of communication between the upper computer and the lower computer. The security of smart home systems is an important issue, and it is especially important to establish a stable and secure connection. The system uses a TCP/IP protocol encrypted by SSL. SSL, also known as the "Secure Sockets Layer" protocol, is a protocol for establishing 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 network each home appliance. The lower-level home appliance network of the system includes a CAN bus network, a 2.4G radio frequency wireless network, and a line-of-sight infrared wireless network. At the same time, these three kinds of communication networks are applied. At the same time, the smart home network has the advantages of good reliability, convenient connection and strong versatility, which makes up for the limitations of the single communication method. If the network is properly arranged, it will be effectively reduced. System cost.

One of the most important functions of the software of the lower computer is to receive the encrypted data sent by the upper computer and then process it. After the data is decrypted, it is a string with a function description and corresponding parameters. In order to facilitate the writing of the program, it is necessary to convert the parameter part of the string from a continuous and unknown length number into an integer variable and store it in the memory. as follows:

Design and Implementation of STM32 Based Smart Home System

This function calls the atai function in the standard library function stdlib.h provided by IAR Embedded. The description of the atai function is /*convert string to int*/, which forces the string to be directly converted into shaped data. The communication protocol between the host computer and the lower computer of this system is designed specifically by us. The string header has a command byte whose length is unpredictable. Therefore, it is necessary to judge the parameters in the data packet before calling the atoi function. It starts with the first few digits of the string and gets the correct pointer to the location of the string argument.

Figure 3 is a flow chart of the main control chip of the smart home lower computer. The main control chip runs the μC/OS lightweight embedded real-time operating system, which uses a deprivable real-time multi-tasking kernel, meaning that the processor is in any Time is running

The task with the highest priority, which is convenient to realize the scheduling of various tasks of the whole lower computer, and also ensures the real-time performance of the system. After the main control chip starts μC/OS, it establishes four tasks: voice recognition task, serial port receiving task, liquid crystal display task, and intrusion detection task. In speech recognition, first query whether the recognition completion bit of the LD3320 status register is set, then respond, perform the corresponding action, voice broadcast the execution result, and send a semaphore indicating that the status of the electrical appliance in the house has changed, and the display needs to be updated; The task of receiving the task is to receive the data sent by the host computer accurately, decrypt the decoding, and perform corresponding operations on the electric appliance according to the instruction; the LCD display task will always detect whether there is an updated display signal amount, if there is a semaphore The whole screen refresh is performed, and the corresponding semaphore is automatically cleared; after the security system is started, real-time monitoring is run, and the security index in the home is judged according to the state of the intensive sensor network, and the intelligent software determines when the alarm signal should be issued.

Design and Implementation of STM32 Based Smart Home System

5 PC control software, PC and Android mobile phone design

After the server (a router running the openwrt system) is running, the USB camera is automatically mounted. After the IP and password information is set in the PC settings window on the PC, the host computer connects to the server via TCP to obtain video/picture information. , displayed on the GUI interface of the host computer. The other controls in the interface also use TCP to connect to the server to send or retrieve information. After receiving the request, the server forwards the tcpserver information to the serial port through the ser2net process to communicate with the lower computer. The mobile phone host computer is designed to be relatively simple, as shown in Figure 4, the large button is convenient to control various appliances in the home.

6 Conclusion

In this paper, a smart home system based on STM32F1 series is designed. The overall architecture of the system is introduced in detail and several important hardware devices and server software implementation methods are given.

Realized indoor real-time power, indoor temperature, weather monitoring, and internal and external network remote control home appliances, remote video surveillance functions and security facilities, voice recognition correct rate of 88%, the network server part uses a router instead of a PC Solution, the overall standby power consumption of the system is ≤ 5 W. The design buttons of the mobile phone control terminal are clear and easy to operate, and can conveniently control the working state of some home appliances. Finally, the function of smart home needs is realized.

  • STM32 microcontroller Chinese official website
  • STM32 microcontroller official development tools
  • STM32 microcontroller reference design

The camera street light is used to use the infrared network high definition intelligent ball's various features so that it can be widely used in the need of large-scale hd quality control of the site.

Functional properties

â‘ Smart Function:Smart Tracing,Smart Inspecting,Smart Road Monitor

â‘¡System Function:Smart Video,Smart Photo Enhancement

â‘¢Movement Function

â‘£Network Function

Camera Lights

Camera Lights

Camera Lights,Camera Lights Action,Camera Lights For Sale,Lights Camera Color

Jiangsu chengxu Electric Group Co., Ltd , https://www.satislighting.com