Design and implement a smart system to detect intruders and firing using IoT

Received Apr 6, 2020 Revised May 15, 2020 Accepted May 28, 2020 The security system is essential for occupants' convenience and protection from intruders and fire. Theft and fire are the most important requirement for the security system. The advancement of wireless sensor networks using IoTs increased the features in a security system and play an important role in daily life. In this paper, the proposed system is divided into two units. The first one about security which use to take snapshots by a camera whenever there is fire or intruders in the security zone and mail it to the owner every three seconds by using Arduino configured with MATLAB program. MATLAB program plays the main role to coordinate between sensors and to turn on/off the cameras. The second unit is about controlling the appliances and also the main door by using AVR microcontroller configured by CVAVR software that connected with Bluetooth sensor and controlled by a smartphone by using the implementation software built-up in the smartphone. To arrival of the control unit, the user should send code from the software implementation to the framework that use to turn on/off the devices or open/close the door. This proposed system is designed and implemented in details in this paper.


INTRODUCTION
Nowadays the risk of fire and intruder has been increased. In general, the security system is defined as a network of devices that contain a trigger and alarm. The features of the security system have been increased with the advancement in the internet field. The concept of the internet of things (IoT) is introduced where the appliances can communicate with humans [1][2][3].
Nowadays the Internet of Things is a fastly growing technology [4,5]. Explain that IoT is consist of a physical device, software, network, sensors, wired or unwired technology, etc. This is essentially due to the instilling of sensors on them. These sensors are connected by wired and wireless networks using Internet Protocol that link-up the Internet [6,7]. Internet as aforesaid has become a part of the daily habit that most of the people in different countries who have the incoming to it. These people have become contingent on having an Internet connection in their daily lives to be able to really carry on with their life for some cause. Because of the increasing risk of burglary and robbery and the busy lifestyle the technology of safety and security system has been increased [8]. In [9] the author designs a smart system to detect intruders using short message service, this system consists of a sensor circuit, controller, and receiver. When an intruder passes through the PIR, SMS is sent to the mobile phone numbers.
In [10] Arduino configured with the gas module, motion sensor, laser sensor to detect intruders and unwanted occurrences that controlled by Bluetooth when the owner indoor and GSM when the owner outdoor. [11] The author suggests two methods to apply the security system for the home. The first one uses a Webcam. A mail is delivered to the owner whenever there is a motion in front of the camera. The second one sends SMS. Also, the control of home appliances by code are very important so in [12,13] the author explain how to control home appliances using AVR microcontroller by the Bluetooth of smartphone. In this paper, if an intruder or the fire occurred a snapshot is taken by the camera which connects with the server and controlled by Matlab program which use SMTP protocol to send e-mail include a photo of the fire for the first time or to the intruders which give an idea to the occupant about the case of the place at that time. Also, for more safety, the door will be controlled automatically by sending a code from the smartphone to the Bluetooth sensor which configured by AVR microcontroller and connected to a DC motor to open or close the door and also to turn on/off the appliances.

RESEARCH METHOD 2.1. Arduino
Arduino is an open exporter stand that used to build an electronics circuits project. This platform consists of a physical programmable circuit board as shown in Figure 1 and software, or (IDE) that works on your computer and used to write down and transfer code to the physical board. This podium has become a popular with world and used widely in electronics circuits because it does not need an independent piece of hardware (called a programmer), like most previous programmable circuit boards. To programming the Arduino board, you can plainly use USB-USB cable to upload the code. The programming language that used with Arduino software is a simplified version of C++, making it easier to learn and programming [14].

AVR Microcotroller
The AVR microcontroller has a CPU and ROM, RAM, I/O ports, and timer all embedded together on a single chip as shown in Figure 2. So, the designer cannot annex any external I/O pins, memory, or timer to it. The AVR with these facilities makes it perfect for many of applications which the cost and space are critical. ATmega 8 is used in this project which provides 23 I/O lines, 512 bytes of EEPROM, 8 Kbytes of System Programmable Flash, 1 KB of SRAM, and USART [15].

CVAVR
Code Vision AVRis a software that is used to write the code for programming the AVR microcontroller on Windows. To inject the code to the AVR microcontrooler SinaProg program is used. The CVAVR is a very good Code Wizard that generates codes automatically [15].

MATLAB
MATLAB is a 4 th generation programming language and it used for numerical analysis. It includes matrix calculations, running algorithms, data visualization, and creating user interfaces. MATLAB environment as shown in Figure 3 allows developers to interface it with other programs in different languages. MATLAB is used in many fields by engineers and scientists such as signal and image processing, control systems for industry, communications, robotics, smart grid design [16].

Smoke detector
Analogy Smoke Sensor or MQ2 module is sensitive to smoke and it has a protection resistor with an adjustable resistor on board. It could be used for fire or smoke detection, also, it used in gas leakage detecting equipment in family and industry. The resistance of the sensor changes as the concentricity of the target smoke changes [17].

PIR sensor
PIR is a motion sensor and it used to detect whether a human has moved in the security zone or through the sensor range. The PIR sensor as shown in Figure 4 is small, simple to use, low-power, cheap, and doesn't wear out. Because of that why the PIR sensor found in the used systems in homes or businesses [18]. PIR used for many projects that need to detect intruders or when a person has left the security zone. PIR sensors are low cost and low power, pretty rugged and have a wide lens range [19].

Webcam
A webcam is a video camera used to flow its image in real-time by means of a personal computer to the internet. When there are intruders or fire throw the security zone the camera takes a snapshot and sends it to throw the network via systems such as the internet, and email as an attachment to the owner. A webcam is generally built into computer hardware or connected by a USB cable [20].

E-mail or email
Electronic mail is the exchanging of digital messages by telecommunication between people using digital devices such as mobile phones, computers, and tablets. Electronic mail first uses in the 1960s and by the mid-1970s had taken the form now recognized as email [21]. Email systems required both the sender and the recipient online to receive the snapshot at the same time.

LCD
Liquid Crystal Display screen is an electronic display module as shown in Figure 5 and used in various devices and circuits.16x2 LCD means it can display 16 characters per line and there are 2 lines. Each character is displayed in a 5x7 pixel matrix. The command register stores the command directive given to the LCD which predefined tasks like preface it, setting the cursor position, controlling a display, clearing its screen, etc. [22].

Relay
A relay is an electrical switch use dc input for receiving a signal and the output is AC to operate appliances and other devices, so, in this project, the relay will receive the signal from microcontroller which connects to the C-port and (NO) port will be connected to the AC device [23].

Bluetooth module
To remote control the AVR microcontroller over a short distance, the Bluetooth sensor is used to receive data from the smartphone. HC-06 module is used and the connection pins are TX to TXD to send data to the microcontroller and RX to RXD to receive data from the microcontroller, VCC with VCC for power, and GND to GND for ground. For generality, use states the HC-06 is sufficient, as typically I want to have a wireless UART joining to my devices from my smartphone [24,25].

BTInterface
BT The software that is used to control the appliances is BTInterface and it is easy to install on the smartphone from the android store, so, by using this software it will be possible to control all devices that connected with the proposed system and used an ID for each device, so, to turn on/off any controlled device just send the ID number from this application show in Figure 6.

RESULTS AND DISCUSSION
In this section the proposed system performance will evaluate, in the ability to turn on/off appliances, open and close the door, receive a snapshot of fire or intruder in the email. Figure 7 shows the proposed system.

Configure the AVR microcontroller with the outdoor
The security system is designing for the outdoor by using AVR microcontroller configured with a Bluetooth sensor as shown in Figure 8 and connected with a DC motor to open and close the door. By sending a code from the smartphone to the sensor the microcontroller will match the code, if the code is correct the outdoor will open and a welcome message will display in the LCD, else the outdoor will not be opened. Open and close the outdoor using a code sent by a smartphone through the Bluetooth will allow the occupant to easily controlling the door and also it will be secure.

Configure the AVR microcontroller
The steps to configure the AVR microcontroller CVAVR software will be used and following this steps: 1) To receive a signal from the smartphone application USART is used. 2) To display each case LCD will be configured.
3) Configure each Port that depends on the number received from the smartphone.
The microcontroller pins connecting as shown in Figure 9 and details below: 1) Connect Bluetooth module (HC-06) Rx to Tx of the AVR microcontroller and Tx of the Bluetooth sensor to Rx of the AVR microcontroller, also, complete VCC-VCC and GND-GND.

Configure the Arduino with MATLAB
First, start MATLAB and install Arduino packages by clicking the Add-Ons drop-down menu and click Get Hardware Support Packages. The package will start download. To establish a connection between MATLAB and Arduino boards, the following command can be used with MATLAB after the Arduino package installed. ard=arduino ('port no.') The PIN (2 & 8) used as an input which received the signal from the PIR and MQ-2 sensors respectively. The pin no. (13) used to send the signal to the camera and to turn on the light when the sensors detect intruders or fire readDigitalPin(ard,2) readDigitalPin(ard, 8) writeDigitalPin(ard,13,1) writeDigitalPin(ard, 13,0) In this project, the camera will be connected directly with the server and configured with the Matlab program as shown in Figure 10. So, if there are any intruders to the security zone the sensor sends a signal to the Arduino which configured with Matlab program to take a snapshot for the introduces and send it by email to the occupant. The SMTP protocol code is written in the Matlab program to send a snapshot of the fire or intruders to the occupant's email every 10 seconds. From the received images it is possible to build a database about all the steps of fire and to know how it happens, by a trigger of an electricity or by intruders, and also to take emergency steps by the owner. To display the cases in each time, the following code is written as if(a==1) writeDigitalPin(ard,13,1); disp('intro'); else writeDigitalPin(ard,13,0); disp('ok'); if(b==1) writeDigitalPin(ard,13,1); disp('fair'); else writeDigitalPin(ard,13,0); disp('ok'); end If there are no intruders and fire (OK) will display, else if there are intruders or fires then (Intruders) or (Fires) will display and an email will send to the occupant.

CONCLUSION
In this paper, the proposed system has been designed using microcontroller AVR Atmega 8 microcontrollers to control the appliances and the main door, also, a security system is done by using Arduino programmed using Matlab to detect firing and intruders. The performance of the designed system has been tested and it's work found very comfortable for the occupant to controlling office or home appliances via Bluetooth with the software application on a smartphone, also, the smartphone using for calling, games, internet, that is mean in the future the smartphone using for controlling devices, also, this design is very simple with low cost. In the other side, the security system is very important to detect the intruders and send a snapshot through the email to the occupant every 3 seconds to store a database about all the steps of the intruders and also if a fire occurs in the building it will be very easy to know the reason for the fire and also to take emergency steps to stop the firing. For the future scope, it is necessary to design a wireless sensor network and connected it with a GPS map to get an idea about the situation of all the places using IoT.