Smart Rash Driver System via Internet of Things (IoT)

Nearly half a million accidents on Malaysians road occur in 2015. The aim of this research is to detect car speed, capture the photo of the speeding car and then transfer the data like car speed, date and time, location and lane number to an online database. A distance sensor is used to measure the distance range between two points on the road. The ESP8266 NodeMCU will be the control unit to process the data and calculate the speed with the formula of speed equal to distance over time. The ESP8266 NodeMCU is also a Wi-Fi module to help in transferring data via IoT to an online database. The Google spreadsheet acted as an online database and will receive all the data if detected a speeding car. In conclusion, the Smart Rash Driver System is successfully invented and able to detect vehicle speed, capture the photo of over speed vehicle and save it to the SD card and lastly transfer all data via IoT to the Google Spreadsheet. This invention will be able to help to decrease the road accident rate efficiently.


Introduction
In 2015, nearly half a million accidents on Malaysians road were recorded [1,2]. Most of the cases happened were caused by the human error, faulty vehicle, driving under the influence of alcohol, drug effect and speeding [3][4][5][6][7]. Moreover, according to the cause of death record of World Health Ranking which is updated on 2014, road accident is rank 5 in Malaysia and rank 34 in worldwide [8][9][10].
The government has figured out a solution for this problem by placing Automated Enforcement System (AES) speed tracker near major roads in Malaysia [11]. According to Jabatan Pengangkutan Jalan Malaysia, after the first eight months since the AES was implemented, the accident rates at 14 locations nationwide have dropped by up to 30% [12]. Therefore, more speed trackers need to be installed to decrease the rate of road accident as mentioned by Malaysian Institute of RoadSafety (Miros) Chairman [13]. Road users might not be stopped from speeding in camera-free section, but they will be more aware on the speed limit all along the road. However, a huge cost needed to install those speed monitoring system such as AES in whole Malaysia, therefore human intervention as well is needed to detect the speed of moving vehicle [11]. The drawback of human intervention is human unable to work 24 hours and besides, human error might occur [14][15][16][17].
The objective of this project is to develop a low cost speed monitoring system, which can capture the photo for car that are speeding. Besides, this research also will provide real-time wireless reporting data speed, location, date and time, location and lane to the centralized database via Internet of Things (IoT). NodeMCU which is an open source IoT platform will be used for the data transfer as it promotes a breakthrough in wireless sensor networks [19] and very popular among various applications [20][21][22][23]. The smart rash driver system is a speed monitoring system, which able to capture car speed, date, time, lane, location and then transfers the data to a database via IoT. Besides, when the system detected a speeding car, it will trigger the camera automatically to capture the car's photo. Therefore, the input of the ESP8266 NodeMCU is a Sharp GP2Y0A21YK0F distance measuring sensor and the output of the ESP8266 NodeMCU will be the camera and Google spreadsheet. Figure 1 shows the overview of the system block diagram and the schematic diagram of the design.

Proposed architecture
The main input for the speed monitoring system is the Sharp laser sensor and the main control unit will be the ESP8266 NodeMCU. ESP8266 NodeMCU will act as a control unit and Wi-Fi module at the same time. After processing the data, ESP8266 NodeMCU will send it via IoT to Google spreadsheet. Lastly, the authorities will able to observe the data from the Google spreadsheet.
Resistor in the circuit act as the voltage divider of the circuit. It can change the input voltage of the Sharp distance sensor from 5 to 3.3 V. Therefore, it will not burn out the ESP 8266 NodeMCU because of the high voltage. ESP 8266 NodeMCU only able to support the input voltage that less than 3.3 V. Moreover, the transistor used in the circuit is to push the input voltage to the maximum so that it can provide enough power to trigger the camera. The breadboard power stick can be powered by two 3.6 V batteries. Therefore, it makes the system become portable. Figure 2 shows the system design flowchart. At the beginning, the ESP8266 NodeMCU will check the Wi-Fi connection with the Internet. Then, the Sharp GP2Y0A21YK0F distance sensor will start to detect the distance range. The distance between two points will be calculated when the vehicle passed through the sensor. The system on road diagram in Figure 3 shows the measurement of the distance while speeding.

System design
The system will calculate the speed with the distance range that is received from the sensor and the time range that provided by the Arduino IDE in the unit of a millisecond. The data of distance1, time1, distance2, and time2 are then collected. The formula of calculating the speed is: After calculating the speed, the unit of the speed will be cm/ms, therefore a conversion needed for changing the unit to km/hour. For getting the timing, time will be provided from the Arduino IDE with the coding of "millis ()". The timing will be count in the unit of milliseconds. The reason of using millisecond instead of a second because it is the smaller unit of time and able to increase the accuracy of calculating the speed of the moving vehicle.  After the speed is calculated, the ESP8266 NodeMCU will begin to process the data. If the speed of the vehicle are over the speed limit that being set, it will trigger the camera to capture the photo of the speeding vehicle. The photo captured will be saved on an SD card. Besides, the ESP8266 NodeMCU will also provide the Wi-Fi connection ability for sending the data wirelessly to an online database.  Google account and create a new "Google Sheet". This is the spreadsheet which will be populated with all the data of speed, location, date and time happened, lane number and location via Wi-Fi. After creating the Google spreadsheet, the spreadsheets URL key is copied and saved. This key is listed in the URL between the "/d/" and the "/edit" of the new spreadsheet. Lastly, the title of the spreadsheet is renamed. Figure 5 shows the example of Google spreadsheet.

Fig. 5. Google spreadsheet.
Next, a Google app script (similar to JavaScript) is created which will process the data and populate to the specific spreadsheet correctly. To insert the Google app script, first navigate from the spreadsheet to the script editor. Then, the coding that prepared for the Google spreadsheet is keyed in to Google script and then the Google spreadsheet URL key is inserted to make sure the data point to the right spreadsheet as shown in Figure  6. Users need to program the Google Scripts so that user able to program a build in date and time, all the data are then populated into specific rows and columns. Next, the Google spreadsheet is saved in other to receive the web app URL to be used in the next step. Then the Web app URL need to be saved.
The current web app URL that is shown in Figure 7 will be used for PushingBox so that the PushingBox able to communicate with the Google app scripts. For the last step of the IoT is configuring PushingBox. The need for using the PushingBox API is to convert the HTTP transmitted data into Google compliant HTTPS encrypted data. The web app URL will be used now for PushingBox to send the data to a right Google sheet. First, a service must be created in PushingBox to let the user interface with any API of any product. Figure 8 shows how to create a service in PushingBox.  Next, the web app URL that is shown in Figure 7 will now be used in the PushingBox while creating the services. Figure 9 shows the web app URL of Google scripts will be filled in the column of Root URL. There are two options able to choose in the column of method, which is Get or Post. For this project, the PushingBox need to fetch the data from the ESP8266, therefore, the option that chosen need to be Get. Then a scenario is created and user able to receive a Device ID as shown in Figure 11. Device ID will be used in the program code of Arduino IDE as shown as Figure  10. The device ID is used to locate the right service of PushingBox device. The yellow highlight section in Figure 10 is the place that placing the Device ID. The Device ID can be changed for other different services.   Figure 11 is the place that placing the command string to tell the PushingBox which data it should fetch and what data should be posted. The data that with the symbol of $Distance$ is means that the data is getting from the microcontroller. User also able to set a constant data that desire to be posted to the Google spreadsheet, the data must be wrote without the symbol of $. Lastly, through those processes, the data is able to transfer wirelessly to the Google spreadsheet successfully and accurately. Figure 12 shows the result of the prototype that is made for this project. The prototype contains a Sharp GP2Y0A21YK0F distance sensor, ESP8266 NodeMCU, camera, resistor and transistor. Fig. 12. Prototype of the smart rash driver system. Figure 13 shows the result that the ESP 8266 NodeMCU has connected to the Internet. It will show "Credentials accepted! Connected to wifi" at the serial communication of Arduino IDE. After the successful connection, the data will be able to be transferred wirelessly. Figure 14 shows the condition for the serial communication of Arduino IDE when the ESP 8266 NodeMCU unable to connect to a Wi-Fi Server. If the ESP 8266 NodeMCU did not connect to an Internet, the serial communication will keep showing "……….." until it connected to an Internet.   Figure 15 shows the result of the data that are uploaded to the Google spreadsheet. The data uploaded to the Google spreadsheet consist of vehicle speed, date and time, lane number and the location of speeding. As for testing purpose, the system has been set to capture the vehicle with speed over 0.5 km/h.

Conclusions
This work demonstrated a smart rash driver system that manage to capture of the speeding car, calculating the speed and transfer the data to online database via IoT through PushingBox service. Compared to the existing AES, this system does not need LAN cable to transfer the data besides of it is a portable system (easy to install and operate). Based on the evaluation, the data and photo collected were in real time condition and successfully transferred to the database when speeding car triggered the sensors. Therefore, this system is expected to help the authorities to reduce the road accidents in the future with an efficient monitoring system.