ROOM SECURITY SYSTEM DESIGN USING ESP32 CAM WITH FUZZY ALGORITHM

At this time, security becomes an important thing that must be fulfilled. Especially a room that has valuables. Currently, the average room security only uses conventional methods, which are very easy to break. Therefore, An Intelligent security system is needed to maintain security in a room. An Intelligent security system is a system that can detect everything automatically and can be monitored remotely using the internet or better known as IoT (Internet of Things). This system uses a microcontroller as the primary part of running the system and is supported by several modules such as the PIR infrared motion sensor module, door window magnetic sensor module, camera module, and buzzer alarm module. The door & window magnetic sensor module serves as the first security, which, when the door/window is open, will give a warning via the buzzer alarm module. While the PIR infrared motion sensor module functions as second security which if motion is detected in a room, it will trigger the camera module to take pictures in the room. The results of this system will be sent directly to Android via the Telegram application using a bot. This Telegram bot will send data in text and images from the system to Android directly.


INTRODUCTION
Today's technological developments encourage the creation of a more sophisticated and complex system. One of them is a security system that is useful for preventing crime. Many theft cases are due to a very vulnerable security system. Therefore the security system becomes crucial. The definition of a security system, in general, is to secure an object where the object contains essential things to be secured, such as a house, room, building, or other things. Security systems can be placed in a room to help maintain the security that people cannot reach or surveillance cameras [1]. Suppose the system can be monitored and controlled by an intelligent security system. This system will increase the security in the environment and detect any crime that appears early. Many people install surveillance cameras at home to monitor the house when it is empty. However, the homeowner has no direct notification when the surveillance camera system detects an unwanted person. Another drawback is that the camera still records video even though no activity is detected.
Research related to the development of home security systems has previously been carried out by [2][3][4][5][6][7]. In this work, researchers explain security and privacy issues in smart homes. The application of motion detection [8][9][10][11][12][13] attempts to overcome the shortcomings of surveillance cameras. Security alarm system for home security is an exciting innovation to be developed. The Internet of Things-based alarm system makes it easy for room owners to inform events that occur at home [8,[14][15][16][17]. Integrating a home security system with a smartphone [18][19] is an outstanding home security system feature. The next challenge is to build a low-cost home security system.
ESP 32 cam is a small camera module with Wi-Fi connectivity and GPIO access. The ESP 32 cam has a low price and good features. The development of the ESP 32 Cam as a surveillance camera was carried out in [1]. The research shows that the cheap camera module can perform the surveillance function well. The development of the ESP 32 Cam as a security alarm has been developed in [20][21]. However, the ESP 32 Cam still has a weakness in the contrast configuration of the ESP 32 Cam. Improper contrast configuration will cause the resulting image to be dark, especially when poor lighting conditions. When the resulting image is not clear, the notification does not provide clear information about what happened. In this research, the writer will solve this problem. This study will build a room security system by fixing the contrast configuration problem on the ESP 32 Cam and connecting notifications to the telegram [22].

PROPOSED METHODS
This study uses the ADDIE development research method. This method consists of analysis of requirement, system design, system development, implementation, and evaluation. The designed hardware system is depicted in Figure 1. The main component used is the PIR Sensor. PIR sensor is used to detect the movement of living things. This sensor is useful for triggering the ov2640 camera module in capturing images. Furthermore, a Door Sensor helps know the condition of the door being open or closed. This door sensor, when open, will sound like a buzzer in a dangerous condition. The last component is the Light Sensor, which detects light conditions in dark, dim, or bright conditions. This sensor will affect the Infrared LED's condition and the camera module's contrast using fuzzy algorithm.

Figure 1. Hardware System
Fuzzy algorithm is used to adjust the contrast on the camera. The fuzzy method used is the Mamdani method. This method consists of 3 steps, namely fuzzification, inference, and defuzzification. Fuzzification changes a value from a firm form to a fuzzy set. After that, the inference is made. Fuzzy inference/basic rules are used to determine light conditions and contrast in a room. The next stage is defuzzification. The calculation is carried out to produce the output value. This value will be used to adjust the contrast on the camera module. Input and Output diagram used in this method shown in Figure 2.  The system workflow of this work can be seen in Figure 3. The flowchart describes the overall workflow of the system. The system starts by connecting the device to the internet network. The system sends a welcome notification to the user's telegram if connected. Then the system is in inactive mode. In this mode, the system can perform commands via telegram. The system will respond to the command. The "/start" command is used to turn the system into active mode. Command "/status" to send status messages to the telegram application. The message contains the status of the door, the status of the light, and the current image. If there is a "/help" message, the system will send information about the system and how to use it. In addition, if there is a message "/restart," the system will restart the ESP32-CAM. Finally, "/stop" is used to turn the system off. Inactive mode, the system can send telegram commands, and all sensors work.

RESULT AND DISCUSSION
The result of this research is a security system device that has many security support features and is integrated with Telegram via the internet. Advantages such as lower prices, no storage required so data can be continuously stored, and the applications used are open source. Testing of this system was carried out in a room size 3x3 m. This tool is placed above the door with a height of about 2 m. The position of this tool is directed, facing slightly downwards so that it can reach the entire room. All components are in the system box except the door sensor located at the top end of the door. Testing is done by testing the bot and each sensor. Tests are carried out directly by applying various conditions, such as sending bot commands, testing door, pear, and light sensors, to testing fuzzy logic for the application of contrast control.
The first test is the telegram bot test. This test ensures that the telegram bot can send messages to users. When the system is first turned on, the system automatically sends a welcome message. In addition to receiving notifications/messages from bots, users can also send some commands to telegram bots to control the system. The bot response measurement results for each message are summarized in table 1. The measurement results show that the average bot response is 5.48 seconds. The second test is the door sensor test. This door sensor helps detect the door is open or closed. When the door is opened, the buzzer/alarm will sound, and the telegram bot will send a message to the user. Meanwhile, the buzzer will stop sounding when the condition is closed, and the telegram bot will send a message like the picture above. Telegram messages will be sent only once. The results of measuring the telegram bot's response to the door sensor input are summarized in table 2. The measurement results show that the average bot response is 5 seconds. The third test is the PIR sensor test. This sensor is used to detect movement in a room. If the motion is detected, the camera module will capture images directly. After capturing the image, the system will send the image directly via the telegram bot to the user. The system will continue to capture and send images as long as motion is detected in the room. The results of measuring the telegram bot's response to the PIR sensor are summarized in table 3. The last test is a light sensor and fuzzy algorithm test. The light sensor will inform the ESP32-CAM that the light is in dark, dim, or bright conditions. When the light conditions are dark and medium, the system will turn on the infrared LED. The infrared LED will light up continuously until the light conditions change to bright. Fuzzy algorithm is used to determine the contrast in the camera module. Each light sensor value will be processed to become a contrast value. Test results are summarized in Table 4. The shooting performance of the camera module after the fuzzy algorithm is applied shown in Figure 4. Figure 4 shows that the camera can take pictures in dark, dim, and bright conditions.

CONCLUSION
Based on the results of the analysis and testing that has been done, it can be concluded that creating an IoT-based room security system with automatic monitoring methods has been successfully carried out. The system also successfully connected to the internet. The system can detect security breaches automatically and send notifications directly to the telegram application. The system can run fuzzy algorithm that is useful for adjusting the contrast on the camera so that the camera's contrast can be determined automatically to cover the weakness of the features of the camera module.