# IoT-Based System for Improving Vehicular Safety by Continuous Traffic Violation Monitoring
This approach utilizes different algorithms for estimating speed [11], counting passengers [12], or detecting seatb belts [13; 14]. Examples of these algorithms are derived from neural networks and deep learning [15; 16]. However, these techniques have shortcomings, which can be summarized as low accuracy, because the entire road network is not covered by these systems, and they are sensitive to weather and obstacles [17]. Moreover, image processing algorithms usually require long computation times, which causes delays in estimation and makes a real-time response more difficult [18]. Therefore, systems that can monitor violations on the entire road network accurately and enable a real-time response are needed. This research proposes a traffic violation monitoring system consisting of an edge computing layer, a fog computing layer, and a cloud computing layer. The novelty of the system is the combination of the three layers for the first time in traffic violation monitoring, and the combination of the monitoring of speed, passenger counts, and seatbelt fastening. The edge layer consists of a microcontroller connected to a GPS sensor, infrared sensors, and limit switch sensors. The edge layer aggregates data collected from sensors and forwards the data to the fog layer. The fog layer contains algorithms for speed estimation, passenger counting, and seatbelt detection. The fog layer inputs the GPS data to the Haversine algorithm, which estimates the speed. The system compares the speed of a vehicle with the permitted value on a certain road. Moreover, the system counts the number of passengers using infrared sensors and compares it with the permitted value. Further, the system determines the status of seatblets using limit switches. A warning message will be displayed by the controller if the speed or number of passengers exceeds the permitted value and a seatbelt is unfastened. The fog layer will send the violation information to the cloud if the driver does not reduce their speed, put a seatbelt on, or reduce the number of passengers within a period of time or after a number of warnings. In addition, the fog layer aggregates data collected from the edge layer and sends the data to the cloud periodically to allow for a second phase of violation checking. The cloud side is responsible for communicating with the fog nodes, storing data, processing data, searching for violating vehicles, and updating vehicles with the permitted speed based on the location. The cloud also communicates with traffic stations to notify them if any vehicle violates the law. The system was evaluated using real-life data by evaluating its components on vehicles to estimate speed, passenger counts, and seatbelt status. To determine the effect of adding the fog layer to the violation monitoring system, the proposed system was compared to the system proposed in [12]. The proposed system with the fog layer outperforms the system with the edge layer alone, because the accuracy of speed, passenger count, and seatbelt estimation is higher. We conclude that adding a fog layer improves the system's functionalities because the computational load is distributed on both layers. While the edge layer prepares and aggregates the data, the fog layer operates the algorithms and also prepares the data for the cloud layer. Therefore, the contributions of this research are as follows. * An IoT-based system for the continuous monitoring of traffic violations, including over-speeding, passenger overloading, and seatbelt unfastening, is presented. This contribution includes both the architecture, consisting of edge computing, fog computing, and cloud computing, and the algorithms used for the monitoring. This system benefits the safety of autonomous vehicles. * Empirical proof shows that adding a fog layer between the edge and cloud layers improves the estimation accuracy, because the fog layer provides the system with more computational resources for operating the estimation algorithms.