Diving safety alarm based on the techniques of machine learning

Many countries actively promote the beneﬁts of sports; in particular, water sports are popular among the younger generation. However, despite the mature development of equipment in diving, it requires relevant training to avoid decompression sickness. Sometimes when divers encounter emergencies and they may fail to alert the coach or other companions for rescues. Currently, some divers wear emergency equipment when conducting the exercise; yet, the cost is relatively high, and the operation is complicated that people tend to forget the process when facing emergencies. This article aims to develop a wearable device that has a safety alarm function based on the technique of machine learning. The features of the suggested device are as follows: (1) cost-effective detectors for monitoring divers’ conditions; (2) a combination of an Automatic Identiﬁcation System (AIS) with a Global Positioning System (GPS) to send a safety alarm with the location of the diver; (3) utilize Bluetooth communication to detect if a diver left the safety range set by the coach; (4) the machine learning technique judges the health status of the diver; (5) the wearable device connects with swim goggles to deliver danger alarms, which enables divers to notice dangerous situations from the lights on the goggles. The approach suggested in this article primarily utilizes wearable devices to ensure divers’ safety. The key feature of this device can prevent divers from sweeping away by currents or swimming into risky areas; meanwhile, the device can detect the risk of decompression sickness. The research executed an experiment to verify the design, and the results have proven the feasibility of the study. Additionally, with the cost-effective detectors installed on the device, the presented equipment has the potential to make it universal and increase the safety of divers.


INTRODUCTION
With the popularity of recreations and water sports, many people conduct relevant activities in vacations and holidays for relaxing, such as mountain climbing and diving; yet, these activities may be risky at times, which require extra safety equipment or distress alarms for protection. So far, such kind of equipment and devices in the market are usually expensive, and usually involve multiple functions that are difficult for users to operate. Because wearable devices should be simple, userfriendly, and cost-effective, this study offers an approach to construct a safety device with affordable pricing, aiming for the usage in water sports such as diving and snorkeling. Currently, the types of underwater activities consider the equipment, the depth ranges, and exercise forms; for example, the purpose of recreational diving is for underwater sightseeing and relaxing. In water, the body not only needs to bear the atmospheric pressure but also carries the hydrostatic pressure: the deeper in the water, the larger pressure the body takes. Under high pressure, the gas solubility in bodies will be higher, and the amount of gas in the diver's blood will be higher than it usually is. Therefore, when the diver ascends too quickly, the body could not release the gas fast enough, the gas forms bubbles in the body and causes tissue and nerve damage with possible symptoms such as skin tingling, numbness, or more seriously, affecting the blood circulation and causing hypoxia. The primary reason for decompression sickness is that people move from a high-pressure to a low-pressure environment without proper decompression steps, and the nitrogen dissolved in the blood and tissues by high pressure forms bubbles as pressure decreases; the bubbles move in different places in the body like embolism, causing various symptoms.
Currently, many streams of research have focused on the safety of divers, for instance, Ref. [1] replaces the diving smartwatch with an intelligent helmet, which shows relevant data, including depths, time, and decompression data. In doing diving, constantly monitoring these data is essential to keep safe. The proposed device is a lightweight, waterproof, and graphic head-mounted display (HMD) for 300 m underwater, and the display connects with a wrist diving computer. Ref. [2] primarily connects divers' watches with the sensors in their diving suits, increasing the safety factors for divers and building a monitor system to help manage divers' safety. In [3], the study creates swim goggles for users to avoid horizontal or azimuth shifts underwater. For solving these issues, the research introduces an equivalent model to describe the movement features of squinting eyesight underwater. Nonetheless, the equipment suggested in the above literature requires higher production cost, which makes it more challenging to be a universal device; moreover, although the devices notify users the risks, people need a coach or other companions for rescue, the transmission of emergency data packets between devices has become a vital issue.
The article develops a wearable device with the function of safety alarm based on the techniques of machine learning, employing an Automatic Identification System (AIS) for longrange communication and Bluetooth transmission between the device and the swim goggles because the low energy transmission of Bluetooth technology can reduce power consumption effectively. The major features of our study are as follows: (1) The carbon dioxide sensor module and G-sensor could detect whether the diver is encountering a dangerous situation; when an emergency occurs, people tend to suffer from shortness of breath and have larger arms or legs movements; hence, the machine learning technique can detect if the diver is in danger.
(2) The design combines AIS with a Global Positioning System (GPS) support to send a safety alarm with the location of the diver. (3) The device utilizes Bluetooth communication to detect if a diver left the safety range set by the coach. (4) The equipment will judge whether the diver is in danger or whether the diver has made safety stops as the rules of diving. (5) The wearable device connects with swim goggles to deliver danger alarms for the diver to notice dangerous situations from the lights on the goggles. Using an internet of things (IoT) development board, the system can conduct machine learning and achieve timely analysis without delivering data back to the server that causes transmission delay. The combination of AIS also assists in sending signals to nearby fishing vessels. The experiment shows that the device of our research is feasible and can improve the safety of divers.

LITERATURE REVIEW
Ref. [4] points out a technique of automatic sound-resource recognition system (SER) that has diverse useful applications in our daily lives; nevertheless, the challenge of using the technology in real-world scenarios is to distinguish the difference between sounds and noises. Our research proposes a novel feature extraction and sorting method to resolve the problem of SER by inputting the extracted features into a classifier for sorting. Ref. [5] mentions a real-world situation of the noise in underwater environments, replacing the dummy variables to pitch angles to avoid the conditions of singular values. Furthermore, [6] explores the underlying architectures of decompression models and algorithms in the safety equipment, monitoring the lung conditions of divers to define the optimal status of divers. Ref. [7] creates a breath sensor for divers to avoid the risk of nozzle blockage. As a result, the study develops a new sensor to install inside the diving mask to boost the safety level; the experiment has confirmed the fundamental functions and effectiveness of the new sensor. The atmospheric diving suit designed in [8] combines a sonar breath detector, which can judge if the diver is facing an emergency. Furthermore, the advance of underwater robots discussed in [9] is another critical innovation for marine biology, which is beneficial for researchers to conduct deep-sea exploration. Ref.
[10] employs high-pressure tests to train divers and confirm suitable underwater depths in different situations.
On the other hand, [11] utilizes a constrained self-tuning controller on underwater robots to trace specific targets and uses auto-regressive moving average with exogenous excitation to calculate optimal routes. Ref. [12] employs an autonomous diving agent to follow or set a route for implementing diving tasks, where the autonomous diving agent can adjust the speed of tracing. In [13], the study evaluates the technologies of submarines to control underwater robots, which can assign tasks and set the return route for executing deep-sea exploration. Ref. [14] primarily uses underwater robots to explore the ecosystems of lakes, while [15] controls the robot extension hydraulically. Ref. [16] suggests a borne trans-media aerial underwater vehicle by using a non-linear-coupled input system, as well as implementing elevation angle detections. Finally, [17] suggests adaptive neuro-fuzzy sliding mode control that can enrich the movement control of underwater robots, and using elevation angles to detect sea creatures.
In [18], support vector machines are mainly used for spectral correction to improve the recognition rate of image recognition. In [19], the combination of industrial IoT and AI is mainly proposed. Because a lot of industrial data has not been used strategically, and the inter-operability between incompatible technologies, systems, and data types is poor, it cannot be effective. To obtain value from it, AI computing can obtain the best decision from the data and improve the efficiency of industrial machine manufacturing. In [20], AI is mainly used to identify various radar images, and each radar image is partially marked according to the wind speed recorded by the meteorological observation station. Four deep learning models are designed to solve the thunderstorm and wind detection problem, which helps to detect the radar chart to quickly detect the weather problem. Ref. [21] mainly uses machine learning to identify and detect defects in solder joints in automatic production lines, and extreme learning machines are used to identify defective welds from qualified welds. Experimental results show that the proposed defect detection method is more based on neural network and can meet the needs of actual production lines. The Internet of Vehicles (IoV) in [22] realizes the detection, classification, and prediction of traffic incidents. The method can identify relevant updates of vehicle training, and prevent uploading of irrelevant updates to reduce network footprint, thereby realizing effective communication. It is mentioned in [23] that botnets are one of the most significant threats to internet security. Machine learning itself may be the weakest link in a botnet detection system. A hybrid learning system is proposed, which combines vertical and horizontal correlation models based on statistical p-values. The significant differences between the vertical and horizontal correlation models increase the difficulty of concept drift attacks.
In [24], the IoT is mainly used to transform smart medical care. The internal management department of the hospital is mainly responsible for the disinfection of surgical equipment to ensure adequate disinfection of medical equipment and avoid infection. Equipment access management. Ref. [25] uses the task allocation mechanism to execute the submitted tasks. Due to the complex relationship between devices, task allocation in the IoT is very complicated. In order to solve this problem, here, we propose a hybrid algorithm that combines the initial completion time of the algorithm and the task allocation of the Triplet algorithm in the distributed IoT to minimize the manufacturing time and time between objects. Communication costs. Ref. [26] is designing and implementing smart hats, which are wearable devices that mainly apply IoT and artificial intelligence technologies, aiming to help children explore knowledge in a relaxed and active way. The Smart Hat is designed to recognize objects in the external environment and provide output in an audio format that uses IoT and AI technology. The learning smart hat is designed to help children in the main learning task of identifying objects without being supervised by a third party (parents, teachers, other people etc.) in real life. In [27], vehicular ad hoc network (VANET) is a highly efficient wireless network, which can maintain and improve the security of vehicle-mounted networks, network traffic monitoring, and certain commercial applications. On the contrary, due to a variety of reasons, such as powerful routing in IoT-enabled VANET, and changes in vehicle density, network size, and fading channels due to high-speed movement and natural chaos in the subway environment, these functions are very lacking. The main focus of VANET is cluster routing, where the appearance of a smaller number of vehicles brings greater challenges to sending and receiving data packets from source to destination. In [28], it plays an important role in industrial internet of things (IIoT) and has been widely used in data collection and area monitoring in various industrial fields. However, due to the openness of wireless channels and the resource-constrained functions of sensor nodes, how to ensure that the sensitive data collected by sensors can only be accessed by effective group members has become a key challenge in the IIoT environment. Recently, secure and efficient group communication for IIoT systems has attracted more and more attention from the academic community and the industry. Membership authentication ensures that all users are legitimate group members, and the group key agreement allows a group of users to negotiate a session key so that encryption primitives can be used to protect group-oriented communications thereafter. We propose a new method using symmetric bivariate polynomials to solve the above problems. This method can simultaneously achieve member authentication and group key establishment. This article designs a wearable device with a safety alarm based on the techniques of machine learning, which utilizes a G-sensor and a carbon dioxide sensor to detect divers' breath conditions and movements. Additionally, the system combines Bluetooth technology to transmit data and judge diving areas; mixing the technology of AIS and Bluetooth to confirm divers' locations and to ensure ocean currents do not take them away.

System model
This research builds a wearable device with a function of safety alarm based on the techniques of machine learning, and AIS and Bluetooth communication are the primary protocols of the device with a G-sensor detector. The device only has one single button; when encountering emergencies, the user can press it and send rescue signals through AIS; the data packet in the AIS signal includes GPS information, which helps rescuers find the location. Meanwhile, the wearable device connects with the swim goggles that detect the level of carbon dioxide and send the data back to the device. Further, the IoT development board will employ machine-learning technology to judge if the moving speed is dangerous when the diver is ascending. We utilize cost-effective sensors in the design and communicate through a Bluetooth module that is beneficial for lower power consumption. Figure 1 shows the system diagram of the device.

Beacon communications
A Bluetooth communication module is in charge of transmitting messages; the low power consumption advantage of Bluetooth transmission is excellent for extending the device life. Moreover, with the Beacon communication method for delivering data and the adjustable Bluetooth ranges, the research sets diving coaches as the message transmitter while the divers are the receivers. When a diver failed to receive the signals sent by the coach, the AIS will send an alarm for the coach to start searching for the person. Nearby vessels will also scan through the AIS for finding the location of the missing person. The Beacon mechanism is beneficial for lowering the power consumption of the device; furthermore, GPS delivers vertical positioning while the Bluetooth executes plane positioning to construct a threedimensional positioning network. Thus, the coach could control divers' locations precisely and ensure their safety.

Diving positioning
The proposed wearable device employs a Beacon model to judge if the divers are near the coach, as divers are required to stay within 30 m near the coach for ensuring their safety. However, the high uncertainty of ocean currents may take divers away from the required distance, which needs that the coach pay attention to the surrounding conditions. In situations when being taken away by ocean currents may endanger divers' lives, they should wear the device that has Bluetooth and AIS communication functions for receiving the signals sent by the coach regularly. When the receiver missed the Bluetooth signal, the system will activate AIS communication and send an alarm; the algorithm is as below: In the formula, B i,t represents the signal sent by the Bluetooth device from the coach. When a diver missed the signal, the coach will receive an AIS alarm, which enables other divers and rescuers to initiate the searching immediately.

Message encryption and AIS emergency signals
To avoid malicious data diddling in Bluetooth transmission, which may lead to missing messages, the AIS continuously sending emergency signals, and waste rescue resources and increase distrust toward the system, we have designed an encryption system to protect the messages from both sides. The formulae are as below: 1. First, both sides will match devices and establish a common session key via their matching numbers, where SK B i,u ↔B i,t represents the common session key, and PR B i,u means the matching number of the diver while PR B i,u is the number of the coach. 2. Secondly, the signal sent by the coach will be encrypted through SK B i,u ↔B i,t and divers will decrypt the message by There is a button on the device; when encountering dangerous situations, users can press the button to send signals; consequently, people nearby or the coach will receive the signal and start the rescue process. This is shown the Algorithm 2:

4.3
The algorithms of machine learning to detect dangerous situations where D i means the descent distance, and we can calculate the safety stop time from the below formula: SD i represents the stop time in the formula. When a diver makes a safety stop, the swim goggles will blink a yellow light to remind the diver to stay until the time finishes. Later, using variances to define the safety stay, if the value is lower than the threshold, the diver should stay longer. The calculation is as below: In the formula, LY means to activate the yellow signal light. Next, use the below calculation for the system to use machine learning, judging the three-dimensional situations and the carbon dioxide levels. If the value is within the safety range, nothing will trigger the alarm. If the value is out of the safety range, the FIGURE 3 Hardware equipment system will send an emergency signal. Moreover, the decision tree of machine learning can be exploited for checking the carbon dioxide level. Our research uses Gini Impurity to partition the data, which is as below formula: In the dichotomy of the decision tree, when it goes to True, the wearable device of the diver will activate the AIS communication to send an emergency alarm.

PERFORMANCE ANALYSIS
The hardware equipment used in this article is shown in Figure 3. Here we mainly use the IoT development version for  Intelligent descending detection by the G-sensor machine learning algorithms. The experiment hardware utilizes Arduino for developing the software, a G-sensor, and a carbon dioxide sensor for the equipment sensors, and a power bank for power electricity, as shown in Figure 4. The study conducts diving tests at a beach, inviting professional divers to implement the experiment, which is demonstrated in Figure 5. The divers are required to carry an about-to-run-out oxygen cylinder to do the carbon dioxide test; in Figure 5, the system will detect the carbon dioxide condition constantly and alert the diver when the carbon dioxide level is abnormally high. There were 700 pieces of data for training and 300 pieces of data for experiments, and Figure 5 reveals the results. The study judges the ascending and descending speeds by the G-sensor, Figure 6 shows the ascending speed data; the decompression sickness happens when the ascending speed is too fast. Therefore, when ascending, the system will automatically detect the condition and send an alarm for warning if necessary. Meanwhile, Figure 7 exhibits the descending speed; if the speed goes too fast, the system will also alert the user. From the above experimental results, with the execution by professionals, we successfully attained relevant data for machine learning training and tests. As a result, the suggested approach can improve diver safety.

CONCLUSIONS
The study develops a wearable device with a safety alarm based on the techniques of machine learning, aiming to improve diver safety because the population of divers and relevant activities is growing. It requires more information technology equipment and detection devices to ensure the safety of underwater activities. This article combines a carbon dioxide sensor and a G-sensor to detect divers' conditions; further, the system will execute machine learning to judge the condition and alert users when necessary. From the experimental results, the suggested approach is feasible; the system can successfully check if the level of carbon dioxide is safe for the user and if the ascending and descending speeds are dangerous for divers. The data proved that the developed device is capable of ensuring users' safety in diving. The wearable device suggested in our study protects divers' safety through affordable sensors and an IoT development board. The device employs AIS communication to locate divers and transmit signals. Because AIS uses highfrequency waves, which can transmit diver locations broadly, and the G-sensor and carbon dioxide sensor can detect divers' safety. The experimental results have proved that the system is feasible and can indeed secure divers' safety.