Design of Intelligent Drunk Driving Detection System Based on Internet of Things

In recent years, with the rapid development of China’s economy and the continuous improvement of people’s living standards, the number of motor vehicles and the number of drivers in the country have grown rapidly. Due to the increase in the number of vehicles and the number of motorists, the traffic accident rate is increasing, causing serious economic losses to society. According to the traffic accident statistics of the Ministry of Communications of China in 2009, more than 300,000 car accidents occurred in the year, most of which were caused by drunk driving. Therefore, this paper proposes a design scheme based on the Internet of Things-based vehicle alcohol detection system. The system uses STM8S003F3 single-chip microcomputer as the main control chip of the system, combined with alcohol sensor MQ-3 circuit, LCD1602 liquid crystal display circuit, buzzer alarm circuit and button circuit to form a complete alcohol detection module hardware system. The main functions of the system are as follows: the alcohol sensor in the car detects the driver’s alcohol concentration value, and displays the value on the LCD screen. The buzzer alarm is exceeded and the information is sent to the traffic police department and the family’s mobile phone through the GPRS module. The system can effectively make up for the shortcomings of traffic police detection, which has certain research significance.


Introduction
With the rapid development of China's economy and the rapid improvement of people's living standards, China has gradually entered the "automobile society" [Qin, Ma, Yan et al. (2013); Zhao, Fan, Fu et al. (2016)]. Drinking and driving behaviors have caused more and more accidents, and the impact on society has become more and more. The more ferocious "road killer". According to incomplete statistics, there are about 500,000 people killed in car accidents every year in the world. The factors that cause traffic accidents are human factors and natural factors, most of which are caused by humans. Among the driver's own factors, drunk driving accounts for the vast majority [Guo and Li (2013)]. According to statistics from countries around the world, accidents caused by drunk driving account for about 30% to 50% of traffic accidents.
According to reports from the transportation department of China, the probability of accidents caused by drunk driving is 5 to 6 times that of ordinary driving. In 2009, China's transportation department investigated more than 310,000 cases of drunk driving, and drunk driving accounted for 1/8 of drunk driving ]. This paper designs a smart drunk driving detection system based on the Internet of Things. The GPRS module uses SIM900A, which can send relevant information of drunk driving vehicles in real time. Install a four-way alcohol probe on the car to check if the driver in the car is drunk. When the alcohol concentration detected by the sensor exceeds the standard, the alarm sounds an alarm, and the vehicle is located through the GPRS module, and the information is sent to the family and the local transportation department. This can effectively combat drunk driving and facilitate centralized management of the transportation department [Cheng and Pien (2018) ;].

Hardware design
This paper designs an automatic alcohol detection system with low cost and fast response. Therefore, STM8S003F3 single-chip microcomputer is selected as the main control chip of the system, and the main data acquisition accuracy of this design requires alcohol concentration, so the display data uses LCD1602 liquid crystal. The display circuit is sufficient [Wang (2014); Li (2014); Liu and Liu (2018)]. In the measurement of alcohol sensor, the internal function of STM8S003F3 MCU is effectively utilized. Therefore, internal A/D is used for data acquisition. Considering various factors, this paper adopts STM8S003F3 MCU LCD1602 liquid crystal display circuit MCU internal A/D function scheme [Yang, Li and Zhang (2015)]. The basic function of the data collection part is to detect the alcohol content and judge whether the alcohol content exceeds the standard. The basic function of the data collection part is to detect the alcohol content and determine if the alcohol content is excessive. Once the alcohol content exceeds the threshold, the MCU sends the alcohol concentration data and alarm information to the transportation department and family through the GPRS module. on the phone ; Zhu, Fan, Ye et al. (2016)]. The gas sensor used in the data acquisition part is of a semiconductor type, and the alcohol data detected by the alcohol gas sensor is amplified, subjected to A/D conversion, and finally sent to the central control module for processing. The overall block diagram is shown in Fig. 1.

Sensor module design
The resistance value of the MQ-3 alcohol sensor differs in the values exhibited by gases of different types and concentrations [Shi (2018); Chen, Liu, Ma et al. (2018)]. Therefore, when designing its hardware circuit, the voltage value is changed by changing the resistance value, and the alcohol concentration is calculated by reading the voltage value  ;Fan, Zhu, Zhao et al. (2017); ]. The concentration of the alcohol is linear with the output voltage of the sensor. The magnitude of the alcohol concentration is linear with the output voltage value of the sensor. Therefore, the signal output pin of the sensor is connected to the STM8S003F3 microcontroller. The A/D acquisition pin is then used by the software to acquire the A/D value of the sensor so that the specific alcohol concentration value can be known. Because the sensitive body resistance of MQ-3 is only 120 KΩ, the load resistor uses a sliding varistor of 0 to 300 Ω, and R2 is a larger sampling resistor, at least 10 KΩ. The circuit is very sensitive and can basically reach 4.7 V when there is alcohol. The working principle is shown in Fig. 2.

Alarm module design
Since the IO pin driving current of STM8S003F3 MCU is only about 10 mA, it cannot directly drive the buzzer to make a loud enough sound. Therefore, it is necessary to amplify the IO current of the MCU through the triode and input it into the buzzer to send the buzzer. A loud enough sound. A triode is a device used to amplify current, with three poles, collector C, base B, and emitter E. The triode is divided into two types: NPN and PNP. In this design, the 8550 triode belongs to the PNP type low-power triode. When a voltage is applied between the emitter set and the collector, the current therein varies with the voltage between the emitter set and the collector. The current of the ordinary IO port of the STM8S003F3 MCU is amplified by increasing the voltage, and then connected to the buzzer to control. The specific circuit diagram is shown in Fig. 3. The hardware is shown in Fig. 4.

.1 Alcohol module programming
The system collects alcohol concentration data by injecting different alcohol concentration gases into the MQ-3 sensor, and obtains the alcohol concentration by reading the different output voltages. Therefore, the main A/D function of the STM8S003F3 microcontroller is used to collect the voltage, which is converted into alcohol. The concentration value is for the system to process. The flow chart of the alcohol con-centration collection processing subroutine is shown in Fig. 5. Since the system only needs to be started once when the car is started, the system does not need to be cycled, and only needs to be started once. STM8S003F3 series ADC is a successive approximation analog-to-digital converter. A comparator, D/A converter, buffer register and control logic circuit form a successive approximation A/D converter. The basic principle is to compare bit by bit from high to low. For example, when using a balance to weigh an object, it is necessary to add a weight from the beginning of the weight and then increase or decrease the weight test. The successive approximation operation is performed under the control of a control circuit. The analog-to-digital converter has a resolution of 10 bits and a maximum of 16 channels.

Alcohol module programming
The first step after the program starts is the initialization of the system. The system initialization is usually only performed once in the program. It is used to put the hardware and software needed in the program into the appropriate initial state in the subsequent program. Normal cycle work. Intelligent drunk driving detection based on the Internet of Things-The initialization of the alcohol detection module is mainly the initialization of the external GPIO pin mode such as LCD1602 liquid crystal initialization, internal A/D function initialization. LCD1602 liquid crystal initialization is used to set the display mode of the liquid crystal, such as whether to display the cursor, shading, etc. The initialization of the internal A/D is used to gate the channel used by the alcohol concentration sensor in the STM8S003F3 microcontroller. The initialization of other external GPIO is used to set the STM8S003F3 microcontroller. The IO is the output mode or the input mode.
After the completion of the system initialization program, the main loop process of the program is started. The main loop is a necessary part of each program. If there is no main loop in the main function, the program will stop running at the end of the main function. Intelligent drunk driving detection based on the Internet of Things-The main cycle of the alcohol detection module first collects real-time alcohol con-centration values through internal A/D, and then displays the alcohol concentration values in real time on the LCD1602 liquid crystal. The system determines the measured alcohol concentration value after each time the alcohol concentration is collected, and determines whether the alcohol concentration value is higher than the thresh-old set by the user. If the value exceeds this value, the buzzer is sounded to alarm the user, and then enters the main loop. The next step. If the real-time alcohol concentration is not higher than the alarm value set by the user, it will directly enter the next step of the main loop. The alcohol concentration treatment is the main function of the system, so it is placed first, and finally it is displayed on the LCD1602 liquid crystal. In general, the driver does not drink during driving, so he only needs to perform an operation at startup and does not need to cycle.