Abstract
In order to improve the real-time prevention and control effect of community security, this paper uses environmental monitoring as the background to design a ZigBee-based wireless sensor network scheme. The ZigBee nodes in the system are set as FFD nodes and have the ability of coordinator and the nodes are not connected with other networks, and a network is formed through a multinode system. Moreover, the proposed cluster routing protocol firstly determines the orientation of the cluster and determines the cluster head in the cluster according to the orientation information of the cluster so that the clusters in the network can be evenly distributed. In addition, the system in this paper is mainly monitored through the Internet of Things and data processing through big data. Therefore, this paper mainly analyzes the data mining, data transmission, and monitoring effect of the system, combined with the simulation software. Finally, through experiments, this paper verifies that the Internet of Things real-time monitoring technology proposed in this paper has a good application effect in community security prevention and control.
1. Introduction
Nowadays, informatization has become an important feature of modern society, and as the first resource, information resources have their core competitive advantages. Information management has penetrated into all fields of social development and directly affects all aspects of economic, cultural, and social development. Moreover, the popularization and application of informatization has its increasingly prominent significance and role. The informationization of the public security system is a powerful driving force for the development and progress of public security work and team building, an inevitable requirement for improving the level of public security work, and the only way for public security organs to reform police affairs [1]. Facing the new era, new situation, and new challenges, the information construction of the public security system also has higher requirements. The national public security system has carried out informatization construction led by the establishment of a “big intelligence” system. With regard to the reform of the police operation mechanism, local public security organs have shown a trend of catching up with each other and have promoted the construction of “information policing,” and changing the traditional mode of public security combat effectiveness generation to relying on science and technology, especially high-tech technology with information technology as the core. By integrating police resources, reforming police processes, and innovating police models, we can reduce police costs, maximize police efficiency, improve the technical content and efficiency of public security work, improve the combat effectiveness of public security forces, maintain social stability, combat crime, and protect people’s lives and property [2]. The role of modern information technology in public security administration, public security prevention and control, investigation and solving, law enforcement supervision, and team management is becoming increasingly important and prominent. As an important institution to ensure public safety, public security organs undertake the important task of defending the people. As part of the tasks of public security organs, social security management plays a fundamental and important role. At present, the overall situation of social security is good, showing a stable and harmonious basic situation, but we should also clearly realize that there are still many problems in social security management, prevention and control, and many challenges are faced [3].
The Internet of Things is mainly composed of the following technologies. The first is radio frequency identification technology. Radio frequency identification (RFID) technology is a noncontact two-way communication using radio frequency signals and their spatial coupling and transmission characteristics to realize automatic identification of stationary or moving objects and an identification technology for data exchange [4]. A typical radio frequency identification system is composed of readers, electronic tags, and information processing systems. Its role is to identify objects and obtain information. The second is the wireless sensor network. Wireless sensor network is a technology that can detect changes in the surrounding environment. It is combined with related technologies to automatically sense, collect, and process various changes of data of the sensed object in its coverage area so that remote observers can use these data to judge the object’s operating status or environmental changes, and further take corresponding actions, or automatically adjust by system settings, and so on [5]. The third is embedded technology. Embedded technology is a technology that combines hardware and software to form an embedded system. In the use of Internet of Things technology, all objects must have the ability to receive, transmit, and process information, so the development of embedded technology is very important. The fourth is nano- and micro-electromechanical systems. In order for all objects to have networking and data processing capabilities, the miniaturization and precision requirements of computing chips are getting higher and higher. Nanotechnology is used to make machine components more miniaturized, or to create new structures and materials to cope with various harsh environments. The development of micro-electromechanical technology achieves the accuracy of a series of processing that receives natural sound, light, temperature, and other signals and converts them into digital signals and then transmits them to the controller to respond to a series of processes [6]. The fifth is distributed information management technology. In an environment where things are connected, each sensor node is a data source and processing point and has operations, such as database access, identification, processing, communication, and response. Therefore, it is necessary to use distributed information management technology to manipulate these nodes. In this environment, distributed database systems are often used to manage these data nodes and connect them together in the network [7].
The core role of the Internet of Things is to obtain intelligence information. Obtaining intelligence information can be divided into three stages, namely, before the event, during the event, and after the event [8]. The Internet of Things system is an information system established on the basis of the existing security system, social security video system, intelligent transportation system, GPS, and other systems. Through this system, information before the occurrence of public security incidents can be effectively collected so that public security organs and other departments can quickly and effectively make response plans to avoid public security incidents. After a public security incident occurs, the public security organs can use the Internet of Things to timely and accurately determine the time, location, and surrounding environment of the public security incident, such as the temperature, humidity, and light of the incident, to facilitate the handling of public security incidents [9]. After quelling the public security incident, the public security organs further strengthened the monitoring of the area through the Internet of Things to prevent similar public security incidents from recurring. At the same time, the public security organs timely sent the handling results and precautions of the public security incident to the residents in the area through the Internet of Things. It is convenient for residents to understand the situation and strengthen the awareness of public security prevention. As a high technology, the Internet of Things has an immeasurable impact on social security [10]. For example, using the Internet of Things technology, public security organs and guardians can easily grasp the whereabouts of children and the elderly, which can reduce cases of women and children being trafficked, and the disappearance of the elderly; the public security organs can effectively monitor the society through the Internet of Things. It can enable public security organs and national security agencies to obtain more comprehensive and valuable intelligence information and provide a basis for public security agencies and national security agencies to make timely and accurate decisions [11]; apply the Internet of Things technology to deal with mass incidents. Therefore, we can grasp the nature, cause, time, and development status of mass incidents in time and provide us with a lot of valuable information to effectively deal with mass incidents; use the Internet of Things technology to prevent and control some key personnel, such as “Falungong” Members; persons released after serving their sentence, and so on, can detect the signs of the incident in time and take precautions against it [12].
At present, although the public security organs have extensively carried out informatization and technological work and have a large number of public security police information resources, the existing various information systems are still at the application stage of business inquiry and file management and most public security information systems. It is to solve the problems of “being” and “nothing” and is a basic data information system that serves the overall situation. Although there have been revolutionary changes to the traditional manual, manual, and paperwork modes, public security information resources have not been used more rationally, unable to create a higher social value. At the same time, all aspects of public security work are multifaceted. For the grassroots public security teams that are fighting at the forefront of social and community public security prevention and control work, what is needed is more practical, more targeted, and more creative in the actual work, a more effective public security application system. The main motives for the occurrence of illegal and criminal acts that affect public security are financial and anger and social “special groups,” including key populations, key public security personnel, and social workers, are committed to illegal and criminal behaviors in the community and undermine public security in the community.
This article combines big data technology and Internet of Things technology to conduct community security prevention and control research, builds a corresponding intelligent system, and conducts experimental verification on the community security system to provide a reference for subsequent community security prevention and control.
2. The Structure of the Internet of Things System
2.1. System Software Design
The system takes environmental monitoring as the background and designs a wireless sensor network solution based on ZigBee. Figure 1 shows the effect diagram of this scheme. Within the coverage of the coordinator of the wireless sensor network, several terminal nodes and routing nodes are arranged to implement wireless communication and network management between nodes.

ZigBee is an emerging wireless transmission technology based on the IE802.15.4 standard. It has the characteristics of self-organization, low cost, low power consumption, low complexity, and low transmission rate, and it works in an unlicensed frequency band, which is easy to use and has the advantages of ultra low cost. The system uses the ZigBee protocol stack to develop a set of wireless sensor networks according to the actual monitoring requirements in the laboratory. The nodes in the network are transmitted through the ZigBee protocol between nodes and between the nodes and the coordinator.
The environmental monitoring subsystem mainly includes servers, coordinators, routing nodes, terminal nodes, and various sensor devices. The main role of the coordinator in the network is to manage the network, gather data, provide the interface to connect to the computer, and realize the establishment of the sensor network data and data transmission channel. Multiple collection nodes realize the collection of data (temperature, smoke, harmful gas, etc.) in the laboratory under the control of the coordinator and transmit the collected various data directly to the coordinator or through the router to the coordinator to coordinate. The device communicates with the server through the serial port to transfer the collected data (temperature, smoke, harmful gas, etc.).
2.1.1. Coordinator
The coordinator is a communication bridge between the control center and the terminal node. It receives and processes the instructions sent by the control center, and the coordinator communicates with the control center through the serial port. It also needs to receive various data information collected by terminal nodes and routing nodes with the ZigBee wireless communication protocol and send it to the control center. Its flowchart is shown in Figure 2.

The ZigBee node in the system must be an FFD node and have the capability of a coordinator, and the node must not be connected to other networks. At this time, this node can build a network. Since a ZigBee wireless sensor network has one and only one coordinator, when a node is already connected to other networks, it can only be a child node of this network. In the network coordination, it first initializes the microcontroller CC2530, then initializes the protocol stack, and turns on the interrupt.
In addition, the coordinator also needs to have the function of building a network. The flowchart of its self-organizing network is shown in Figure 3.

In the ad hoc network process, it first determines whether the node is an FFD node to determine the network coordinator and then performs channel scanning. After finding a suitable channel, the coordinator will select a network identifier PANID, and this network D must be unique in the channel. At this point, the initialization of the network is completed, and the next step is to wait for other nodes to join.
2.1.2. Terminal Node
The information of each terminal node of this system is different. After the sensor detects the data, the collected data will be transmitted to the terminal node. In order to realize the data transmission in the system, it is necessary to establish a network connection. The terminal node needs to send a request to establish a network connection to the coordinator, and the coordinator will determine whether to allow the node to join the network according to the specific situation and then make a corresponding response to the request and send it to the node. After the node joins the network, it will establish a connection with the coordinator and then transmit data. The specific steps are to first find the network coordinator and send an association request command, then wait for the coordinator to process, and send a data transmission command to transmit data after the connection is established. The flowchart is shown in Figure 4.

As the terminal of the wireless sensor network, it first scans and finds the coordinator or front-end routing node in the network. If the beacon is not detected during the scanning period, the node will scan again until the network coordinator or front-end routing node is found. Then, the node sends an association request command to it, and the node also sends a data request command, waiting for the front-end routing node or network coordinator to process it. If it agrees to the node’s joining request, it will assign a short address of 16 bits to the node. At this time, the node will send the collected data to the coordinator.
2.1.3. Routing Node
As the relay node in the WSN monitoring system, the routing node is suitable for large area and long distance. In a wireless sensor network, because the range of nodes is too wide, the network coordinator may be too far away from the terminal node to establish a connection and cannot communicate. At this time, the routing node can be used as a transit war to connect the coordinator and the terminal node in communication. Therefore, the system can expand the coverage of the wireless sensor network by increasing the number of routing nodes.
When setting up the routing node, the program first initializes the CC253O and protocol stack. After initialization, the system sends a signal to join the network, and the front-end routing node or network coordinator will respond to the node accordingly and will assign itself a network address when agreeing to join the network request. After the routing node joins the network, it starts to act as a transit station and has the function of forwarding data. The program flowchart is shown in Figure 5.

2.2. Design and Implementation of System Routing Algorithm
Some environmental monitoring locations in the system may not be able to provide a stable power supply. At the same time, in order to reduce the trouble caused by wiring, the nodes will work under battery power. In order to realize that the node can work uninterrupted for a long time, it is necessary to reduce the energy consumption of the sensor node. The most widely used clustering algorithm in WSN is the low-power adaptive LEACH routing algorithm, and other clustering algorithms also use this as a benchmark.
Before describing the algorithm, first make some assumptions about the wireless sensor network and sensor nodes, as follows:(1)The wireless sensor network is a static network, and all nodes in the system are static and will not move after finishing the deployment(2)The sensors are randomly and evenly distributed in the monitoring area(3)The sensing nodes are isomorphic, and all sensor nodes in the network have the same initialization energy(4)In order to know its location information, the sensing node in the system can rely on GPS, positioning algorithm, and other methods to obtain specific coordinates(5)The coverage area of each node is the same(6)The wireless channel is symmetrical
After determining the cluster head, the traditional clustering protocol randomly classifies the sensor nodes in the network, which leads to uneven network distribution and excessive energy consumption. Based on the above assumptions, the cluster routing protocol proposed in this paper first determines the location of the cluster and then establishes and determines the cluster head in the cluster according to the location information of the cluster so that the clusters in the network can be evenly distributed.
In practice, in the monitoring area A, in order to enable the network to achieve seamless coverage , the number K of the first family to be selected can be determined as follows:
Here, r is the node transmission radius.
In the network, the number of effective nodes in the cluster will gradually decrease as the energy of the nodes is exhausted. The relationship between the new seamless network coverage and the number of effective nodes S is as follows [13]:
In this paper, the formation of clusters in wireless sensor networks is realized by fuzzy C-means clustering (FCM) algorithm. After the cluster is established, the system determines the cluster heads and candidate cluster heads in the cluster. When the energy of all cluster heads in a certain cluster decreases to the threshold, the system starts the next round of clustering. Its algorithm flowchart is shown in Figure 6.

N sensor nodes in the wireless sensor network have their corresponding coordinates, and the data convergence point composes the coordinates of the N sensor nodes into a set . The N sensor nodes in the set are used as the N samples in the set. We set the center of each cluster to , and is the membership function of the jth node to the ith cluster [14].
Fuzzy C-means clustering algorithm (FCM) is a fuzzy objective function method. The objective function is defined as [15]
Here, a is the membership matrix and satisfies the following formula:
Here, the optimal range of m is [1.5, 2.5], and d is the distance from the kth sample to the ith category, which is defined as
Therefore, we can adopt a new objective function to make the necessary conditions for formula (3) to reach the minimum value:
Here, is the Lagrangian multiplier of n constraints of formula (3). The derivation of all the input parameters of the above formula is performed, and the necessary conditions for formula (3) to be minimized are as follows [16]:
After obtaining the cluster by the FCM algorithm, the cluster head needs to be determined. The node closest to the center is the cluster center point. In order to select the preselected cluster head of the ethnic group, the system first calculates the Euclidean distance between the center point of the cluster and all nodes in the cluster and then selects the shortest Euclidean distance as the preselected cluster head. After that, the system manages all preselected cluster heads in the form of a queue, taking the head node in the queue as the head of the cluster, and the cluster head is responsible for collecting and fusing data collected by all nodes in the cluster.
In the cluster, the cluster mainly processes a large amount of data, and each processing of data consumes a large amount of energy. In order to prevent the cluster head’s energy consumption from causing node failure due to excessive energy consumption, we set a threshold . When the cluster head energy decreases to , the cluster head will notify the next node in the queue to become a new cluster head, and this cluster head will become a normal node. The threshold is set according to the energy of the node. At the beginning, the values of and are equal, and the value of decreases after each clustering [17].
When the energy of all candidate cluster heads in the queue is less than threshold or the energy consumption is complete, the network convergence point will recluster the remaining nodes (excluding dead nodes and missing candidate nodes) so that the redivided clusters can obtain the original difference and can also avoid the difference between the previous candidate cluster head and the current candidate cluster head.
After the clustering is completed, the data transmission in the network adopts the principle of cluster head forwarding. The cluster head far away from the base station will select the nearest cluster head for data transmission instead of directly communicating with the base station. Each cluster head performs corresponding processing and fusion of the data transmitted from other cluster heads and then forwards it to the next cluster head node, all the way to the convergence point where the data is transmitted. By adopting the principle of cluster head forwarding, the data transmission distance of nodes is shortened, and the energy consumption of cluster head nodes is greatly reduced. In the strategy proposed in this paper, there are multiple candidate cluster head nodes in each cluster group, and they can be elected cluster heads in turn. This not only ensures the stability of the cluster, but also maintains stability for a long time after the data transmission route is established for the first time.
3. Community Public Security Prevention and Control System Based on Big Data and Internet of Things
After the system is powered on, the system first initializes and checks whether the system is powered on for the first time. If it is powered on for the first time, the system calls the system default parameters and records related information. After the address is set, the program enters the loop state, asking whether it needs to read card processing or other corresponding processing. If it encounters a situation that needs to be dealt with, the system will automatically deal with the corresponding subroutine. If there is no need to deal with the situation, the system will go to sleep. In the dormant state, if there is information to be processed, the system will be awakened quickly in a short period of time. The main program flowchart is shown in Figure 7.

When the main program detects the card reader identification bit, the system executes the card reader processing subroutine. First, the system scans the card to read the information in the card, and the data read by the reader is finally transmitted to the computer. The main program in the computer judges the received data and judges whether it is valid data. If it is valid data, the program automatically reads the card number stored in the buffer and determines whether the card is a valid card. Then, it queries the current card status and the information in the card according to the card number, compares and authenticates with various information tables stored in the database, and then uses the comparison information to execute the command to open the door or refuse to open the door. The flowchart is shown in Figure 8.

In the access control system, the system judges the information in the ID card sent by the access controller. When it is judged that the card holder’s card information is true and has authority, the computer control management center will send related control commands to the access controller. The access controller drives the access control module to send a high level to the relay to turn on the device, and the electronic door lock will automatically open at the same time. When the cardholder is judged by the system as an illegal person or does not have this authority, the system sends an alarm command to the access controller and controls the alarm module to turn on the alarm and at the same time records the alarm information. The workflow is shown in Figure 9.

The security system mainly consists of perimeter infrared anti-overstepping monitoring at all levels of nodes in the ZigBee wireless network, residential window sill monitoring, intelligent antitheft doors and windows, and community monitoring platforms. This solution has the functions of automatically sensing threats and active warnings, and it cooperates with the community’s video surveillance system and uses the rapid response of the owners, community properties, and the police to reduce accident losses. As shown in Figure 10, this security system uses multiple security lines of defense. The system builds a multilayer protection system around the entire community, building, and family to truly realize all-weather intelligent security.

Based on the advantages of ZigBee technology in wireless sensor networks, in this solution, the coordinator is the gateway node of the entire ZigBee network and is the core device of the entire system. The coordinator unites various routing nodes and terminal sensor nodes to form a mesh network. The coordinator is responsible for the establishment of the entire network, address binding, sensor data collection, and data transmission to the host computer through the serial port. In the end, the data is provided to the community monitoring center for observation, and the system promptly starts video surveillance, calls for civil air defense, and other related processing. The overall layout of the security system is shown in Figure 11.

After constructing the above system, the performance of the system is verified. The system in this paper is mainly monitored through the Internet of Things and data processing through big data. Therefore, this paper mainly combines simulation software to analyze the data mining, data transmission, and monitoring effects of the system, and the results are shown in Table 1 and Figure 12.

From the above research, we can see that the community security prevention and control system based on big data Internet of Things technology constructed in this paper has good practical effects and has a certain effect on the security management and stability maintenance of modern communities.
4. Conclusion
This article builds and implements a community public security information analysis system to maximize data collection and dynamic control of the crowd. Moreover, this paper uses information elements, such as economic income, activity trajectory, and peer information to classify the personnel who meet specific conditions, dynamic management, high-risk early warning, and group judgment. In addition, this paper guides the police force to be targeted, intervene in advance, and act proactively, which is of substantial significance for reversing the situation where the police force passively follows the case. This article combines the Internet of Things technology and big data technology to construct a community security prevention and control system, monitors through the Internet of Things, and conducts data processing through big data. The security system mainly consists of perimeter infrared anti-overstepping monitoring at all levels of nodes in the ZigBee wireless network, residential window sill monitoring, intelligent antitheft doors and windows, and community monitoring platforms. After constructing the system, this paper designs experiments to verify the performance of the system. From the experimental analysis, we can see that the community security prevention and control system based on big data and Internet of Things technology constructed in this paper has good practical effects.
Data Availability
The labeled dataset used to support the findings of this study is available from the corresponding author upon request.
Conflicts of Interest
The authors declare that they have no conflicts of interest regarding the publication of this paper.
Acknowledgments
This study was sponsored by Railway Police College, China.