Design and Prototyping of Sensor-based Anti-Theft Security System using Microcontroller

—To address the safety of the home or other facility, a microcontroller-based solar-powered anti-theft automated security system is developed with arrays of sensors to detect possible intrusion incidents. The designed system produces three kinds of alarms (Buzzer, bi-color LED, and SMS) with a security breach notification through an LCD, based on the data from its interfaced sensors (Motion Sensor, Fire Sensor, and Glass-break Sensor). The microcontroller used to control all aspects of the system is Atmega8. A Light Depended Resistor (LDR) and a Potentiometer (POT) are used to build the Motion Sensor; Temperature Detector LM35 is used as the Fire Sensor; and a sensitive metal strip is used to build a custom Glass-break Sensor. SIM900 (GSM) is used to design an SMS generating system as one of the alarming methods. The designed system is found to be consumed very low power with a 5V supply since when it is ON, the bi-color LED (0.1watt) requires only 0.98µA and 23.5mA of current, and 4.88mW and 117.5mW of power during its state change; and the Buzzer consumes only 0.49mW of power when it is ON. The system is designed with the consideration of incorporating a double-grid power management system, and a dedicated Sun-tracking solar power system is designed to increase its overall efficiency and sustainability. The whole system is designed and verified using ‘Proteus 7.7 Professional’ and the core part of the system is physically constructed and tested. The programming of the Atmega8 is done using ‘Code Vision AVR version 2.5 Professional’.


INTRODUCTION
A security system involves the detection of intrusion, trespassing, or unauthorized entry into a home or any protected area and getting alarmed of such unauthorized access to protect assets and people from being damaged or harmed. Since the emerging of modern technology, commercial, industrial, and military properties have been extensively using some sort of security system for safeguarding against theft, property damage, or personal harm [1], [2]. In recent years, the importance and demand for home security systems have been noticeably rising as well, especially in urban areas. Since nowadays, people are increasingly keeping them out of home for works and other purposes, houses are becoming victims of burglary by means of illegal entry by force, such as breaking a glass-window or slashing a glass-door or by entering through an unlocked door or an open window. Studies have pointed out that burglaries and intrusion-related crimes occur extremely less in places where a home security system is installed [3].
Not very long ago, home security systems or monitoring cannot be accomplished without human maneuver. Even today, security guards and trained-up dogs are common practice to tackle the issue, since it is evident that the crime is not going away from our society completely. Besides, people are remaining outside more than ever today, leaving their homes vulnerable if proper measures are not taken. While human security guards and trained-up dogs are reliable to a certain degree, but maintaining them is always costly and they can be fooled and corrupted. To address these issues, and to keep up with the rapidly evolving technology, the home security system needs to be automated with minimum human intervention to keep it safe, no matter if the home is occupied or empty.
The concept of automated home security systems has been around since the 1970s. But with the progress and expansion of technology, both our expectations and the idea of home security systems have been shifted [4], [5]. Home security systems involve some critical parameters like gas leakage system, fire/smoke alarming system, theft, and intruders monitoring system, etc. Many sophisticated techniques and systems are now available to serve the purpose. The latest programmable devices, controllers, sensors, video cameras, and loud buzzers are used to address the issue. Recently, very comprehensive and error-free systems are available, which are both accurate and cost-effective [6]- [8]. Many alarm monitoring services of today's home security system now allow users to access their system via the Internet. Users can check the system status remotely, and even view real-time video feed if CCTV cameras are installed. Today's systems even allow users to change their security passwords, lockout the security passwords, and arm or disarm the security system via the Internet [3], [9]. However, the trend of low cost and low power Microcontroller based home security system automation is not yet faded, rather still emerging. Hence, the work in this paper is focused on the very area.
Any system or device that is required to measure, store, control, calculate, or display information is an appropriate candidate for using a microcontroller in it [10]. A microcontroller is a small electronic device that can be considered as a single-chip and special-purpose computing machine dedicated to repetitively accomplishing a specific task. Similar to a general-purpose computer, a microcontroller comprises CPU core, memory units (RAM, ROM, Flash), and I/O ports [11]. Since the device is very small, and it is designed to control objects, processes, or events; hence the name microcontroller. Another term used for it is embedded controller since the microcontroller and its supporting circuitry are often constructed into, or embedded in, the devices they are programmed to control [10]. The uses and engineering application area of the microcontroller is enormous, including automatically controlled products like vehicles, engine control systems, power tools, toys, and office machinery which are commonly used i.e. photo-copier, printer, and fax machines [10]. During the 1990s, microcontrollers having EEPROM (such as flash memory) became available which made projects like the one described in this paper feasible and efficient, since these kinds of microcontrollers could be erased and reprogrammed using only electrical signals [10].
The paper is organized in the following manner. Section 2 describes the components and peripheral devices required for the work along with the floor-planning of the system. Section 3 represents the design of the electronic circuits/hardware of the system. Section 4 describes the programming of the microcontroller. Section 5 represents the results of the work. Section 6 concludes the paper, and section 7 describes the future scopes of the work.

II. MATERIALS & METHODS
The designed automated security system mainly involves a microcontroller (Atmega8) as the brain, three sensors (Motion sensor, Fire/Temperature sensor, Glass-breaking sensor) for detecting anomalies at the home or application area, and three output methods (LED, Buzzer, SMS) for providing the necessary alarms. As per the focus of this paper, a brief explanation of Atmega8 and three sensors are provided below, followed by a detailed list of components, a system flow chart, and a block diagram.

A. Atmega8
ATmega from Atmel AVR is a family of 8-bit microprocessors and microcontrollers. From a vast range of features depending on the model, the following ones are mostly present in all of their products: 4-256 kB Flash memory, 28 to 100 pins in SMD or DIP package, a watchdog timer, and up to 20 MHz clock speed. Besides, the Atmega family offers on-chip Flash, SRAM, and internal EEPROM [12].
The one used in this work is Atmega8 in a DIP package, which is an 8-bit Atmel microcontroller with 8kB in-system programmable Flash, designed in advanced RISC architecture. Its operating voltage is 4.5V -5.5V, and it has 512Bytes EEPROM and 1kB Internal SRAM [13]. Figure 1 shows the pin-out diagram of an Atmega8 in the DIP package.

B. Motion Sensor (LDR)
Light Dependent Resistors (LDRs) ( Figure 2) are a type of nonlinear resistor that can change its value based on the change in incident light intensity. LDRs are also known as Photo Resistor, Photo Conductor, Photo Conductive Cell, or just Photo Cell. They are made out of semiconductors, especially from the compounds of CdSe, CdS, InSb, or PbS [14]. In the absence of light, the resistance of an LRD is very high, sometimes up to 1MΩ. But when the sensor is exposed to light, its resistance decreases radically, even down to a few Ohms [15]. LDR is used in this work because they are cheap to get and simple to handle. The only limitation is that they take a few seconds to get back to their original position once the light is absent again [16].

C. Fire/Temperature Sensor (LM35)
The LM35 ( Figure 3) is selected as the temperature sensor for this work, which is a precision temperature sensing IC with an output voltage linearly proportional to the temperature. A big advantage of these sensors is that they are calibrated directly in Celsius (Centigrade), and promise 0.5°C ensured accuracy (at 25°C). The operating voltage of LM35 sensors is 4V to 30V, and they cover a full −55°C to 150°C temperature range [18].

D. Glass-break Sensor
Glass-break sensors can be built in two different ways based on the detection method, as per some research and commercial devices. One way to build is based on vibration and another based on acoustic sound. For the first way, the detector usually has a shock sensor mounted on the glass to get sufficient transmission of the vibration and detect it ( Figure 4). For the second way, the crystal of a piezoelectric sensor is tuned to the resonance frequency of 40 and 12 kHz to detect the breaking sound. This sensor also has to be mounted on the glass [19]. In this paper, the proposed method involves placing a tiny metal strip (current conductor) around the outer periphery of a glass window or door, so that when the glass breaks the strip breaks as well which changes the current flow in the controller to take an action.

E. Components and Peripheral Devices
To ensure sustainability, the power management of the designed security system is considered to be solar-based. Not only that, a Sun-tracking system is designed and developed for higher efficiency of solar intake. So, the entire work presented in this paper can be divided into two broader parts: (i) Design and verification of the security system, which involves two separate circuits; one for motion sensing and glass-breaking detection, another for fire/temperature detection. And, (ii) Design and verification of the Sun-tracking solar system. All the parts and components required to design and develop the whole system are listed in Table 1.

F. System Flow Chart
The heart of this work is the automated security system, and to better represent its workflow step-by-step, a logic flowchart is provided in Figure 5. The core concept is to monitor the sensor (Motion, Fire, Glass-break) inputs for Real-Time Voltage (RTV) change and compare them with the predefined SET Voltage (SV); and then changing the status of the output modules (LED, Buzzer, SMS) accordingly.

G. Block Diagram of the System
A block diagram is often called a high-level flowchart, which is very effective in having a high-level view and understanding of a system quickly. So, to provide an overall easy visualization of the whole system presented in this paper including all its peripheral devices a block diagram is provided in Figure 6. It is to be noted that the power management of the whole system is considered to be double-grid with a Suntracking Solar System and Grid Control Unit. The design and verification of the Sun-tracking Solar System are presented in the following sections. 61 motion sensing and glass-breaking detection, another for fire/temperature detection. And, (ii) Design of the Sun-tracking solar system. The design of all the circuits is done by Schematic Capture of Proteus 7.7 Professional and presented in the following sub-sections, where the power supply is taken to be 5V dc throughout the system. Figure 7 represents the circuit for motion sensing [21] and glass-breaking detection, where an LED (red) is connected with the power terminal of +5V dc. A Light Depending Resistor (LDR) and a voltage dividing series resistor are connected to the rectifier's output (+5V), where the divided voltage is interpreted as a metal strip that encloses the outer periphery of a glass window or door which is interfaced with the microcontroller (ATmega8) through ADC (4). The voltage across the Potentiometer (POT) is considered as the SV, which is interfaced with the Atmega8 through ADC (3); and the voltage across R2 is considered as the RTV, which is interfaced with the Atmega8 through ADC (4). This RTV varies according to the change in light intensity on the LDR, or the connection of the metal strip (glass-breaking sensor).  As an output device for alarm indicating, a pair of Red and Yellow LEDs (represents a bi-color LED) with series resistor R6 and R7 is interfaced with the Atmega8 through two NPN transistors as their driver. As per the design, when RTV>SV, LED is OFF and vice versa. A buzzer is also connected as an output device for alarming, through a series NPN transistor as its driver. When the metal strip is disconnected due to glass breaking, the RTV<SV, which disconnects R2 from the Atmega8, and an SMS is sent to a preprogrammed mobile number as an alert, which is shown in Figure 8. A temperature sensor circuit using LM35 is also shown in Figure 8 to detect fire, and the incident will be alerted through SMS as well. Figure 9 represents the circuit for automatic Sun-tracking system, where six LDRs are used to track the position of the Sun based on the solar intensity on them at a given time, and a stepper motor to rotate the solar panel according to the inputs from LDRs' changing voltage level [22]. The positions of the LDRs corresponding to the rotation angle of the motor to track the solar position are listed in Table 2. When light intensity on an LDR increase, its resistance decreases, and the voltage across it falls; which in turn raises the voltage drop across its series resistor. This change is read by the ADC port of the Atmega8 to decide where the solar position is. Then the motor receives an instruction to rotate in clockwise (CW) or counterclockwise (CCW) direction based on the highest ADC value.  Microcontrollers are programmable devices, and their functions depend on the programming codes written by the system designer. Atmel AVR uses 'Language C' to write codes for their microcontrollers. To execute the functions of the designed system presented in this paper, the necessary programming codes for the Atmega8 are written using Code Vision AVR version 2.5 Professional. Some fundamental codes required to run the system are taken care of by the Code Vision platform itself [23], [24]. The written codes for the Atmega8 to execute the designed system are provided in Table 3, which follows the logic flowchart in Figure 5.

A. Operational Results from Simulation
To verify and investigate the operation and behavior of the system presented in this paper, the designed circuits are carefully simulated in Proteus 7.7 Professional. The results are verified according to the written functional program codes and their logical working principles, which satisfy the expected outcomes. The screenshots of the simulations that represent the operational analysis are provided below in Figures 10 to 12, which reflect the process of steps 1, 3, and 5 of the flowchart in Figure 5. Steps 2 and 4 are tested and verified as well.   As long as the value of SV is greater than or equal to the value of RTV, the above operations keep continuing repeatedly; except before blinking of the Red and Yellow LEDs, the buzzer sounds for once. By changing the value of the POT's resistance, the SV can be manipulated. This means a threshold can be set to change the sensitivity of the system.

B. Transient Responses from Simulation
Besides operational analysis, a system also needs to be verified for its transient response to make sure the input-output signal responses are as per the design. The transient responses of the circuits including the Sun-tracking system are checked and verified in Proteus by plotting the input and output signals, and the obtained results are shown in Figures 13 to 16.   According to the operational and transient response, the simulation results can be summarized as follows:  Initially, when the incident light on the LDR is at maximum intensity, the bi-color LED is OFF.  If the incident light is interrupted, the voltage across R2 decreases and eventually falls below SV, which turns ON the Buzzer; and the bi-color LED is also turned ON in the manner of changing color with 1 (one) second of delay. This indicates that an unwanted intrusion happened.  If the metal strip is torn up, R2 gets disconnected from the ATmega8, which in turn sends an SMS to a preset GSMbased mobile number. This indicates that the incident of Glass-breaking happened by an intruder or by any other means.
 If the temperature inside the home or building is greater than the ambient temperature, then also an SMS is generated and sent. This means an incident of fire occurred by intention or accident.  Sun-tracking on both CW and CCW is achieved to increase the efficiency and sustainability of the power management system, which can improve the grid performance by 40% [25]. Table 4 represents the results of various changes in current, voltage, power, etc. measured with respect to the change in LDR voltage or light intensity by keeping the SET voltage at 2.5V and the supply voltage at 5V.     Table  4, which compare different electrical parameters as the system goes through different steps.

D. Prototype & Results
The operations related to step 1 through step 5 of the flowchart in Figure 5 are practically verified by constructing the designed circuit on a PCB board, which is shown in Figures 19  and 20. The physical implementation of the whole system is a work-in-progress.

E. Discussion
The work done in this paper including its applicability is summarized in Figure 21. Since one of the outputs or alarm methods of the security system is sending an SMS, it can be said that the system is already applicable remotely by monitoring the security status of homes or any other facilities through SMS notification, besides its local control unit. But to make it a full-fledged remotely controllable and distantly monitoring security system, a wireless system with a signal transmitter and receiver can be designed and implemented that is compatible with the security system. Figure 22 represents the revised block diagram of the proposed extension of the current work. The remote control unit can also be powered by solar energy with the Sun-tracking system designed in this work.

VI. CONCLUSION
A microcontroller-based Sun-tracking solar-powered antitheft automated security system is designed with three kinds of incident detection sensors (motion, fire, glass-break) and three kinds of alarm methods (Buzzer, bi-color LED, SMS). The core part of the security system is also constructed and tested. The designed system is verified to be functional and useful in security protection, which features automatic control of the LED (color-changing in blinking manner), alarming (when LED is ON) with Buzzer and SMS, and displaying the information according to the different scenarios of security measures. The system operates on 5V dc supply, requiring less than 1mA of current and 5mW of power during standby conditions. When the system is ON, during the bi-color LED's blinking sequences (Yellow-Off-Red) it consumes less than 25mA of current and 120mW of power. And, the buzzer takes less than 0.5mW of power while ON, which makes it a very low power system and suitable for working reliably with solar energy for a longer duration when grid connection is not available. To make the system even more efficient and sustainable a Sun-tracking solar system is also designed. Alert SMS generation system for Fire and Glass-break detection is also verified and confirmed to be reliable with the designed security system. This anti-theft system can be applied in homes or any kind of facility where security is a concern, and the control unit can be placed locally or remotely for monitoring.

VII. FUTURE SCOPES
Engineering is a continuous process of experimenting, problem solving, and innovation for different kinds of applications. Every engineering projects have some sort of scopes to improve or extend them, and the work presented in this paper is not an exception. Besides the existing possible applications of the designed system, the future scopes, according to the revised block diagram in Figure 22, may involve: (i) designing the Grid Control Unit to complete the power management system between Solar and Grid, (ii) designing a wireless Transmitter and Receiver compatible with the system to make it true remote-area applicable, and (iii) physical implementation of the whole system including the Sun-tracking system.