Design of a prototype for sending fire notifications in homes using fuzzy logic and internet of things

ABSTRACT


INTRODUCTION
Currently, any home or space is prone to suffer a fire, which can bring various damages such as human or material losses, the causes may be due to different factors such as a short circuit, explosions, facing this problem, a platform supported by the internet of things (IoT) provides a solution accessible to people, which works in such a way that the notifications generated are as accurate as possible to avoid such accidents [1].With the development of an IoT oriented device, a quick response to an incident is sought because we will get a notification to the user regardless of their location, sometimes fire responses are not performed properly because the alarms are at the scene, making the response difficult when the user is absent [2].Therefore, having a smart home environment improves the safety of homes and makes a person's life more secure [3].
There are studies related to home security that propose to monitor the data obtained by sensors [4]- [6].The data of temperature and humidity can be displayed on a web site and then stored in my structured query language (MySQL) [4], [6].On the other hand, [5] proposes to monitor the data obtained by means of a mobile phone application and at the same time turn on lights or enable people's entrances from Int J Elec & Comp Eng ISSN: 2088-8708  Design of a prototype for sending fire notifications in homes using fuzzy logic … (Johan Huaman-Castañeda) 249 the same application.What they propose in [4], [5] is to use a device that helps to obtain the results of the sensors and make a quick response to something unusual that arises.Likewise [7], [8] comments that to detect thin smoke by means of images is difficult to differentiate from other objects (waving flags, climbing vehicles in mountains, and moving lights) since they share similar characteristics and conventional methods such as chrominance, texture, transparency and frequency, are difficult to identify in chaotic conditions, if it is scarce, it is much more difficult to detect by the methods mentioned, for which, other differences must be taken into account.Smoke has differences in it is movement, but there are also confusions with other objects such as the movement characteristics of flags.Although the dynamic characteristics of smoke are different from many others, it is difficult to identify and extract this movement information by hand.That is why there is not much research to detect smoke by dynamic features.Deep learning is an exceptionally useful tool to extract these features, so [7] proposes a deep neural network to detect smoke.
Advances in the sensitivity and availability of gas detection sensors and other parameters have been significant in recent years due to the use of technology and research into their functionalities, which in time have been decisive in the timely detection of potential fires in houses, buildings, and other environments [9].Since 2011, IoT has been used to complement sensors and systems previously developed in previous years [9].Where sensors are used to detect heat (fuse-element, bimetals, fiber optics, thermocouple, thermistor, infrared cameras (IR)), gas sensors (MG-811, MQ-2, MQ135), fire sensors (Photodiodes, HTS-220, LM-35, closed circuit television (CCTV), near infrared (NIR), smoke sensors (ICSD, MQ-6, DHT11, DHT22) [9].It is important to mention that the development of intelligent environments coupled with IoT is a remarkably interesting advance since the system can be fed back and improve its efficiency significantly equal or greater than 95% as mentioned in [3] which makes the system increasingly robust and new functionalities can be added.
Various applications have used fuzzy logic to address problems such as energy management systems [10], manipulator of flexible joints [11], [12], estimation of soil moisture content [13] or navigation by mobile robots [14].We have identified research on the use of fuzzy logic for the recognition of fire signal patterns (humidity, temperature and presence of smoke) [15]- [19].As well as the development of an algorithm with fuzzy logic using images for the detection of forest fires to avoid false alarms [16], [20].On the other hand, improving the data obtained with sensors and by means of a set of rules using fuzzy logic to detect the presence of fire [17].The studies mentioned in [15]- [18] argue that better results are obtained by applying fuzzy logic in projects related to IoT with 95% assertiveness, since with this we avoid false alarms and better results are obtained by defining a set of rules that will help to determine if a fire is occurring [21].In addition, as a first step to standardize the use of fuzzy algorithms, fire detection data should be considered to eliminate interferences caused by index characteristics and order of magnitude [22].The mentioned detail is essential for the normal development of the other processes otherwise the processing and conclusion of the logic is erroneous [22], [23].
On the other hand, Wang et al. [7] mentions the use of fuzzy logic for the detection of potential fires considering parameters such as rates of change of temperature, humidity, CO, CO2, O2 and flame (estimated fire intensity prediction).The use of this method helps to improve fire detection with a high accuracy rate 95% with respect to conventional and analog forms that are below 90% [1].In addition, there is research on the use of artificial intelligence in motion devices to visualize through sensors and camera some unusual activity within a house or establishment to alarm the user remotely [24].The open system for fire detection is used in forested areas to reduce wildlife losses using system training, improving the efficiency of the system by using cameras connected to a server to identify potential fire situations.In addition, fuzzy logic determines the degree of assertiveness to classify it as a possible fire and trigger the actuators installed in the area [25].Advances in the sensitivity and availability of gas detection sensors and other parameters have been significant in recent years due to the use of technology and research into their functionalities, which in time have been decisive in the timely detection of potential fires in houses, buildings, and other environments [22].Since 2011, IoT has been used to complement sensors and systems previously developed in previous years [22].Where sensors are used to detect heat (fuse-element, bimetals, fiber optics, thermocouple, thermistor, infrared cameras (IR)), gas sensors (MG-811, MQ-2, MQ135), fire sensors (Photodiodes, HTS-220, LM-35, closed circuit television (CCTV), near infrared (NIR), smoke sensors (ICSD, MQ-6, DHT11, DHT22) [22].It is important to mention that the development of intelligent environments coupled with IoT is a remarkably interesting advance since the system can be fed back and improve its efficiency significantly equal or greater than 95% as mentioned in [23] which makes the system increasingly robust and new functionalities can be added.
Finally, to improve the reliability of the alarms sent to the user and the percentage of assertiveness [7], [26].The use of IoT is of vital importance in fire detection systems since it is the first link between the incident and the user making possible alarms reach their destination and action can be taken based on it as mentioned in [1]- [3].Therefore, after a thorough analysis of the previously reviewed articles, a pioneering proposal emerges.Although so far, fire detection has relied exclusively on sensors or images captured by cameras, our innovative perspective lies in the integration of both technologies simultaneously.In this sense, we propose the creation of a prototype that combines the capability of sensors with the support of cameras, using fuzzy logic to synchronize these two approaches.This system will send notifications via email transfer protocol (SMTP) to the user.Our primary goal is to evaluate whether this protocol proves to be more efficient than hypertext transfer protocol (HTTP) when employing a Wi-Fi and 3G network.Measuring notification sending times will be essential for this analysis [27]- [30].

METHOD
The objective of the designed prototype is to determine the probability of a fire to verify if the SMTP protocol is faster than the HTTP protocol, taking as a reference the results of the source [2] where response times are obtained using the HTTP protocol.Additionally, a comparison of the response time using different Internet technologies will be made to avoid fires and to have a prompt response when the incident occurs.Results will be obtained from three parameters (presence of gas, humidity levels, temperature), which as a whole or individually are indicators of possible fires or a developing incident.In addition, a camera is used to send evidence through images of the detection of the sensors from the conclusion of the implemented fuzzy logic.The chronology of the implementation of the prototype starts with the acquisition of the necessary components according to the need for functional testing and programming development.

Hardware
The hardware of the system was developed with fundamental blocks where each one fulfils crucial functions for the operation.On the one hand, the inputs are linked to a fuzzy logic block with the intention of generating valid and necessary alarms for the user.It has a block of sensors that have the function of collecting data from the enclosure to be monitored, the DHT-22 sensor has very important features as it has high sensitivity and performance which gives high reliability to monitor temperature and humidity levels, likewise with the MQ-2 sensor that has the function to monitor and detect levels of smoke and gas which are important indicators when a fire develops, The video camera helps to verify the alarms emitted by the DHT-22 and MQ-2 sensors.All the above mentioned arrives as input data to the ESP32-camera (CAM) microcontroller block, which has the configuration to process the data properly and make the best decision according to the fuzzy logic.The last block is in charge of sending an alert message through the Internet to the user, by means of e-mail, in case of an incident in the area where the prototype is located.

ESP32-CAM
The microcontroller can be widely used in various IoT applications such as smart home systems, industrial wireless control, wireless monitoring, and wireless positioning signals.The most influential features in solving the problem are: 32-bit low power dual-core central processing unit (CPU), connectivity to Wi-Fi, Bluetooth, video camera and microSD port up to 4 Gigabytes.It has both analogue and digital pins, with a supply voltage of 5 volts and support for an input voltage of 3.3 volts.

DC power supply
The power supply used is 5 volts direct current for the microcontroller and the gas sensor.In the case of the temperature sensor a voltage of 3.3 volts is used.It is important that the devices are properly powered so that there are no reading and/or operation problems for consistent performance.

Sensors
The DHT-22 and MQ-2 sensors have a key role in the project since they are the main link between the system and the environment to be monitored, therefore their functionality in extreme situations is of utmost importance.The DHT22 sensor has especially important and particular characteristics that help it to be installed in any environment.It is a digital sensor that allows receiving temperature and humidity data.The MQ-2 sensor is responsible for detecting the presence or level of gas or smoke in the environment.It has an analogue output to detect several types of gases and a digital output that indicates whether gas is present.

Software
With respect to the software used for programming the ESP32-CAM microcontroller, the Arduino Development Environment version 1.8.11 was used.In addition to programming the microcontroller, the software was used to measure the prototype message sending times.The tests were performed with the Arduino serial monitor.

Development
For the development of the prototype, we start with the correct power supply of the input components that will have the ESP32-CAM microcontroller and the microcontroller itself.The latter requires a power supply of 5 volts to operate the camera that has integrated and between its input pins only support a voltage of 3.3 volts.With respect to the sensors, the DHT22 is powered with a voltage of 3.3 volts and delivers a maximum voltage of 3.3v at its output.With the MQ-2 gas sensor it requires a 5-volt power supply for its operation, therefore, to deliver the voltage that the microcontroller supports as maximum (3.3 volts) a voltage divider was added at the output of the sensor to obtain the desired voltage.Figure 1 shows sensors connected to the ESP32-CAM.
To start with the programming, we will be using the digital outputs of both sensors, since when the ESP32-CAM microcontroller is using the Wi-Fi, it disables the analogue inputs of all available pins.We will be using the Wi-Fi module to be able to send notifications via email in case of an incident.Once the above is defined, the algorithm will be defined as shown in Figure 2.

Fuzzy logic
In order to obtain better results with the input sensors, fuzzy logic is used, with the objective of avoiding false alarms and improving decision making.In this project, temperature and humidity inputs are being considered for the fuzzy logic algorithm.Regarding the gas sensor input, it will be used as a reinforcement to the results obtained.For Temperature, the values shown in Table 1 and the membership function in Figure 3 are defined.While for Humidity [1], the values shown in Table 2 and the membership function in Figure 4 are defined  In order to obtain as an answer whether a fire is occurring or not, we will work with probabilities, where a value greater than 50 is indicative that a fire is occurring in the enclosure.The output values for a possible fire are defined in Table 3.Then, the membership function is shown in Figure 5. Finally, the Table 4 defines the temperature vs. humidity values.
In summary, the microcontroller will receive data from the DHT-22 and MQ-2 sensors, the data that will pass through the fuzzy logic will be the temperature and humidity data, obtained by the DHT22 sensor.If the probability of fire is greater than or equal to 50, we would be talking about a possible fire in the enclosure.With respect to the MQ-2 gas sensor, the data obtained will be used to support the probability obtained previously.

Sending notifications
Once it is defined if a fire is occurring, the microcontroller sends an e-mail via the STMP protocol (port 587) to the user so that a quick response to the incident can be taken.The e-mail sent has the temperature and humidity recorded in the room, as well as if there is any gas leakage.Figure 6 shows the flowchart of the proposed prototype.

Tests
To determine if the SMTP protocol has a faster response time than the HTTP protocol, tests were performed with a connection to a Wi-Fi network and to a 3G network to determine the delay time of the message sent.The tests were performed by sending e-mails with an image of 1,600×1,200 size (UXGA image type) and the data obtained by the DHT22 and MQ-2 sensors.Additionally, tests were performed in a mock-up simulating a home environment where fires occur very frequently.7 shows an example of the e-mail that the user will receive.Thus, ten tests of the proposed prototype connected to a Wi-Fi network were performed and the data shown in Table 5 were obtained.Also, ten tests of the proposed prototype connected to a 3G network were performed and the data shown in Table 6 were obtained.

RESULTS AND DISCUSSION
The test results aligned with our expectations.The system's response times fell within the expected range, as observed in evaluations of other sensor-only systems.When comparing it to our new system, some advantages emerged, which we will elaborate on shortly.

Results 1
For this part, the data were obtained by performing tests evaluating response times with a Wi-Fi network, where the results shown in Figure 8 were obtained.It can be inferred from the Figure 8

Results 2
With respect to this part, the data were obtained by performing tests evaluating response times with a 3G network, where the results shown in Figure 9 were obtained.It can be inferred from the Figure 9 that the average sending time with the SMTP protocol is 2856.9milliseconds at an average speed of 34.94 Kb/s.A maximum time of 4.021 milliseconds sending a packet of size 136.8Kilobytes and a minimum time of 2.052 milliseconds sending a packet of size 75.049Kilobytes.Figure 9. Response times with a 3G network

Results to compare
Regarding [2], they performs tests with the HTTP protocol connected to a Wi-Fi network and sending notifications to WhatsApp and a web page for monitoring.The results are shown in Table 7 and it can be inferred that the average send time with the HTTP protocol is 190.67 milliseconds at an average speed of 5.25 Kb/s.A maximum time of 251.09 milliseconds and a minimum time of 126.504 milliseconds.These results are obtained because [2] only sends the notification by text, without indicating the temperature obtained in the enclosure, with this we can infer that using the HTTP protocol the message will arrive much faster compared to the SMTP protocol.The most novel is to send data and image using the SMTP protocol where you can have several receivers (mail) and the message that is determined to be sent, must go through a fuzzy logic evaluation, and then attach an image and send to the receiver.

CONCLUSION
Tests showed that the notification sending time for SMTP protocol is longer compared to HTTP protocol, due to query source uses WhatsApp as a means of notification and only sends text without any parameters.In this research an email is being sent with the parameters of temperature, humidity, and gas presence, in addition to sending an image of the enclosure.Therefore, the time to send the notification using the SMTP protocol is not decreased.
The notification sending time using a 3G network is 3 times longer compared to a Wi-Fi network.Additionally, many of the tests performed with a 3G network were not completed due to lost connection.For this prototype it is recommended to use a Wi-Fi network to avoid higher latencies or inconveniences due to bandwidth.
The use of fuzzy logic within the programming of the ESP32 microcontroller facilitates the system to identify the minimum and necessary parameters to catalogue them as potential fire notifications and send evidence with an image via e-mail.By means of this logic it was possible to validate the result of the

Int
Design of a prototype for sending fire notifications in homes using fuzzy logic … (Johan Huaman-Castañeda) 251

Figure 5 .
Figure 5. Range of the first output


Figure 7  shows an example of the e-mail that the user will receive.Thus, ten tests of the proposed prototype connected to a Wi-Fi network were performed and the data shown in Table5were obtained.Also, ten tests of the proposed prototype connected to a 3G network were performed and the data shown in Table6were obtained.

Figure 7 .
Figure 7. Mail sent to the user & Comp Eng, Vol.14, No. 1, February 2024: 248-257 256 algorithm by sending an image to the end user.The result consists of an e-mail with details of temperature, humidity, presence of gas and adding the mentioned image.

Table 5 .
Tests with a Wi-Fi network

Table 6 .
Test with a 3G network that the average sending time with the SMTP protocol is 1050.1 milliseconds at an average speed of 87.33 Kb/s.A maximum time of 1,382 milliseconds sending a packet of size 130.4 Kilobytes and a minimum time of 878 milliseconds sending a packet of size 123.234Kilobytes.
Design of a prototype for sending fire notifications in homes using fuzzy logic … (Johan Huaman-Castañeda) 255