Strathmore University SU+ @ Strathmore University Library Electronic Theses and Dissertations 2019 Real-time monitoring system for drunk driver through Internet of Things - a case of Nairobi County, Kenya Joseph M. Mbugua Faculty of Information Technology (FIT) Strathmore University Follow this and additional works at https://su-plus.strathmore.edu/handle/11071/6712 Recommended Citation Mbugua, J. M. (2019). Real-time monitoring system for drunk driver through Internet of Things— A case of Nairobi County, Kenya (Thesis, Strathmore University). Retrieved from http://su- plus.strathmore.edu/handle/11071/6712 This Thesis - Open Access is brought to you for free and open access by DSpace @Strathmore University. It has been accepted for inclusion in Electronic Theses and Dissertations by an authorized administrator of DSpace @Strathmore University. For more information, please contact librarian@strathmore.edu Real-Time Monitoring System for Drunk Driver through Internet of Things A case of Nairobi County, Kenya Joseph Muoho Mbugua Submitted in Partial Fulfillment of the Requirements for the Award of the Degree of Master of Science in Information Technology at Strathmore University Faculty of Information Technology Strathmore University Nairobi, Kenya June, 2019 ii DECLARATION I declare that this work has not been previously submitted and approved for the award of a degree by this or any other University. To the best of my knowledge and belief, the thesis contains no material previously published or written by another person except where due reference is made in the thesis itself. © No part of this thesis may be reproduced without the permission of the author and Strathmore University Joseph Muoho Mbugua Adm No. 094156 Signature: .............................. Date: ....................................... Approval The thesis of Joseph Muoho Mbugua was reviewed and approved by the following: Dr. Vitalis Ozianyi, (PhD), Academic Director, Faculty of Information Technology, Strathmore University Dr. Joseph Orero, (PhD), Dean, Faculty of Information Technology, Strathmore University Prof. Ruth Kiraka, (PhD), Dean, School of Graduate Studies, Strathmore University iii ABSTRACT One of the major causes of traffic accidents and crashes globally is drunk driving. Though driving under influence of alcohol is illegal, drivers still find themselves doing it. This has resulted to deaths and fatalities which affect the economy negatively. Currently, different technologies have been adopted to reduce the vice without success. In Kenya, breathalyzers are being used by traffic police to monitor drunk drivers. This technology has failed due to corruption. The reason being the culprits are able to buy their way out. Technological innovation needs to be implemented in a cost effective, efficient and legal manner. This enables to combat drunken driving on the roads easily. The researcher applies the V-Model Methodology to design, implement and test of a real- time monitoring system for drunk driver through IoT. The system uses fuzzy logic based algorithm to analyze the response of MQ-3 and MQ-135 sensors. Sensor fusion is achieved through processing the analog to digital converted values of the sensor output using an algorithm to determine alcohol concentration in the breath (BAC). The analyzed result determines whether the Blood alcohol concentration (BAC) is within the legally permissible standards. Upon the detection of such a situation, an alarm is activated. Additionally, an ‘alert SMS’ indicating the drunk driver’s location as tracked by the GPS receiver on the same system and the vehicle registration number is communicated to the SACCO managers using GSM cellular network to take appropriate action of intercepting the vehicle. The tested real-time results indicated the successful implementation of the system. iv TABLE OF CONTENTS DECLARATION........................................................................................................................... ii ABSTRACT .................................................................................................................................. iii TABLE OF CONTENTS ............................................................................................................ iv LIST OF FIGURES ....................................................................................................................... ix LIST OF TABLES .......................................................................................................................... x LIST OF ACRONYMS ................................................................................................................ xi DEFINITION OF TERMS .......................................................................................................... xii ACKNOWLEDGEMENT ......................................................................................................... xiii CHAPTER ONE ........................................................................................................................... 1 INTRODUCTION ........................................................................................................................ 1 1.1 Background ......................................................................................................................... 1 1.2 Problem statement .............................................................................................................. 2 1.3 Research objectives ............................................................................................................. 3 1.4 Research questions ............................................................................................................. 3 1.5 Significance of the study.................................................................................................... 3 1.6 Scope of the study .............................................................................................................. 4 CHAPTER TWO ........................................................................................................................... 5 LITERATURE REVIEW ............................................................................................................... 5 2.1 Introduction ......................................................................................................................... 5 2.2 Traffic Road Accident Review .......................................................................................... 5 2.2.1 Global Traffic Road Accident ..................................................................................... 5 2.2.2 Africa Traffic Road Accident ..................................................................................... 6 2.2.3 Kenya Traffic Road Accident ..................................................................................... 7 2.2.4 Nairobi County Traffic Road Accident..................................................................... 8 2.3 World Adopted Technology for Reducing Alcohol related Traffic Accidents.......... 8 2.3.1 Technology Used in USA to reduce Road Traffic Accidents ................................ 9 2.3.2 Technology Used in Asia to reduce Road Traffic Accidents ................................. 9 2.3.3 Technology Used in Africa to reduce Road Traffic Accidents .............................. 9 v 2.3.4 Technology Used in Kenya to reduce Road Traffic Accidents ........................... 10 2.3.5 Technology Used in Nairobi County to reduce Road Traffic Accidents ........... 11 2.3.6 Conclusion on already existing technology ........................................................... 12 2.4 Internet of Things ............................................................................................................. 12 2.4.1 Internet of Things and Transportation Industry ................................................... 13 2.4.2 Internet of Things Architecture ............................................................................... 13 2.5 Real-Time technology ...................................................................................................... 14 2.5.1 MQTT Application in a Real-time Technology ..................................................... 14 2.6 Air Quality Monitoring Systems .................................................................................... 15 2.6.1 Application of Machine Learning in Drunk Driver Detection ...................... 15 2.7 Fuzzy Logic ....................................................................................................................... 15 2.7.1 Fuzzy Inference System ............................................................................................ 16 2.7.2 Application of Fuzzy logic ....................................................................................... 17 2.7.3 Application of Fuzzy Logic to detect Abnormal Odor ........................................ 17 2.7.4 Use of Fuzzy Inference System in Target gas Identification from other Odors 18 2.7.5 Characteristics of Alcohol Sensor module ............................................................. 20 2.7.6 Characteristics of MQ-135 Sensor ........................................................................... 20 2.7.7 The Archtecture of the Proposed System ............................................................... 21 CHAPTER THREE ..................................................................................................................... 22 METHODOLOGY ...................................................................................................................... 22 3.1 Introduction ....................................................................................................................... 22 3.2 Research Design ................................................................................................................ 22 3.3 Data collection ................................................................................................................... 22 3.3.1 Secondary data ........................................................................................................... 22 3.3.2 Primary Data .............................................................................................................. 23 3.4 Instruments of data collection ........................................................................................ 23 3.4.1 Interviews ................................................................................................................... 23 3.4.2 Questionnaire ............................................................................................................. 23 3.5 Data Analysis .................................................................................................................... 23 vi 3.5.1 Data Presentation ....................................................................................................... 24 3.5.2 Prototype System Testing ......................................................................................... 24 3.6 Target Population and Sampling Frame ....................................................................... 24 3.7 System Implementation Methodology .......................................................................... 25 3.7.1 The V-Model ............................................................................................................... 25 3.8 Quality Aspects of the Research ..................................................................................... 27 3.8.1 Validity ........................................................................................................................ 27 3.8.2 Reliability .................................................................................................................... 28 3.9 Ethical Code of Conduct Considerations ...................................................................... 28 CHAPTER FOUR ....................................................................................................................... 29 SYSTEM ANALYSIS AND DESIGN ....................................................................................... 29 4.1 Introduction ....................................................................................................................... 29 4.2 Interview Analysis ........................................................................................................... 29 4.2.1 Social Demographic profile of road users in Nairobi, Kenya ............................. 29 4.3 Questionnaire Analysis ................................................................................................... 30 4.3.1 Major causes of the RTAs in Nairobi ...................................................................... 30 4.3.2 Relationship between the day of the week and RTAs .......................................... 31 4.3.3 Number of victims directly or indirectly involved in Road Traffic Accidents . 31 4.3.4 Effectiveness of “SMS alert” notification ............................................................... 32 4.4 Requirement Specifications ............................................................................................. 33 4.4.1 Functional Requirement ........................................................................................... 33 4.4.2 Non- functional Requirement .................................................................................. 33 4.5 System Architecture ......................................................................................................... 33 4.6 System Analysis ................................................................................................................ 34 4.6.1 Use Case Diagram ..................................................................................................... 34 4.6.2 Use case description .................................................................................................. 36 4.7 UML Sequence diagram .................................................................................................. 37 4.7.1 System Flow Chart .................................................................................................... 38 4.8 System Design ................................................................................................................... 39 vii 4.8.1 Context Diagram ........................................................................................................ 39 4.8.2 Level 1 Data Flow Diagram ...................................................................................... 40 4.8.3 Partial Domain Model ............................................................................................... 41 CHAPTER FIVE ......................................................................................................................... 42 SYSTEM IMPLEMENTATION AND TESTING ................................................................... 42 5.1 Introduction ....................................................................................................................... 42 5.2 Components of the System ............................................................................................. 42 5.2.1 Hardware Components ....................................................................................... 42 5.2.2 Application layer ....................................................................................................... 43 5.2.3 Sensor data Analysis ................................................................................................. 44 5.2.4 Fuzzy Rules ................................................................................................................ 45 5.2.5 Sample Drunkard Driver alert SMS to the SACCO Managers ........................... 45 5.3 Implementation of the System and Experimentation ................................................. 46 5.4 System Testing .................................................................................................................. 46 5.4.1 Functionality Testing................................................................................................. 46 5.4.2 Integration Testing .................................................................................................... 47 5.4.3 Usability Testing ........................................................................................................ 47 CHAPTER SIX ............................................................................................................................ 50 DISCUSSIONS ............................................................................................................................ 50 6.1 Introduction ....................................................................................................................... 50 6.2 System functionality ........................................................................................................ 50 6.3 The results of the study .............................................................................................. 50 6.4 Advantages of IoT based real-time driver monitoring system .................................. 51 6.5 Disadvantages of IoT based real-time driver monitoring system ............................. 52 CHAPTER SEVEN ..................................................................................................................... 53 CONCLUSIONS AND RECOMMENDATIONS .................................................................. 53 7.1 Conclusion ......................................................................................................................... 53 7.2 Contributions to the research ......................................................................................... 53 7.3 Recommendations ............................................................................................................ 54 viii 7.4 Suggestions for future research ...................................................................................... 54 REFERENCES ............................................................................................................................. 56 APPENDICES ............................................................................................................................. 62 Appendix A ............................................................................................................................. 62 Turnitin Originality Report ................................................................................................... 62 Appendix B ................................................................................................................................. 63 Participant Information and Consent Form ....................................................................... 63 Appendix C ................................................................................................................................. 66 Research Questionnaire ......................................................................................................... 66 Appendix D ................................................................................................................................. 68 Interview Questions ............................................................................................................... 68 Appendix E ................................................................................................................................. 69 Desktop Application Graphical User Interface .................................................................. 69 Appendix F ................................................................................................................................. 70 GPS Tracking of a Vehicle ..................................................................................................... 70 Appendix G ................................................................................................................................. 71 Pairing a Driver to a Vehicle ................................................................................................. 71 Appendix H ................................................................................................................................ 72 Pictorial Representation of the system ................................................................................ 72 Appendix I .................................................................................................................................. 73 Sensors Setup Code ................................................................................................................ 73 Appendix J .................................................................................................................................. 79 php code for ' Alert SMS ' Notification ............................................................................... 79 Appendix K ................................................................................................................................. 82 Ethical review approval letter .............................................................................................. 82 ix LIST OF FIGURES Figure 2.1 IoT Architecture (IEEE standards 1451.2, 1997) .................................................. 13 Figure 2.2 Linguistic variable fuzzification to defuzzification of output process. ........... 16 Figure 2.3 Output value as calculated by Fuzzy system (Szulczyński, et al., 2018) ......... 19 Figure 2.4 Proposed Architecture of the real-time driver monitoring system .................. 21 Figure 3.1 V-model (Systems Engineering Process, 2016).................................................... 26 Figure 4.1 Major causes of road accident in Nairobi. ........................................................... 30 Figure 4.2 Victims of RTAs ....................................................................................................... 32 Figure 4.3 Effectiveness of an “SMS alert” ............................................................................. 32 Figure 4.4 System Architecture ................................................................................................ 34 Figure 4.5 Use Case Diagrams.................................................................................................. 35 Figure 4.6 Sequence diagram ................................................................................................... 37 Figure 4.7 Flow chart diagrams ............................................................................................... 38 Figure 4.8 context diagram ....................................................................................................... 39 Figure 4.9 Level 1 DFD diagram .............................................................................................. 40 Figure 4.10 Partial Domain Model ........................................................................................... 41 Figure 5.1 Fuzzy logic systems ................................................................................................. 44 Figure 5.2 sample alert SMS ..................................................................................................... 46 Figure 5.3 Ability to embed the system into a Public Service Vehicle ............................... 48 Figure 5.4 System Acceptance .................................................................................................. 49 x LIST OF TABLES Table 4.1 Social Demographic Profile of Road Users in Nairobi ........................................ 29 Table 4.2 Number of road accidents in 2018 and 2017 (NTSA, 2017/2018) ...................... 31 Table 4.3 Monitoring status of the Device .............................................................................. 36 Table 4.4 Access Notification Service ...................................................................................... 36 Table 5.1 Fuzzy Rules ................................................................................................................ 45 Table 5.2 Functional testing ...................................................................................................... 47 Table 5.3 Usability Test ............................................................................................................. 48 xi LIST OF ACRONYMS API - Application Programming Interface BAC – Blood Alcohol Concentration FIS- Fuzzy inference system GDP- Gross Domestic Product GPS - Global Positioning System GUI – Graphical User Interface HIV/AIDS – Human Immunodeficiency Virus infection / Acquired Immunodeficiency Syndrome IDE - Integrated Drive Electronics IEEE - Institute of Electrical and Electronics Engineers IoT- Internet of Things NTSA- National Transport and safety Authority ppm - particles per million PSV- Public Service Vehicle RTAs - Road Traffic Accidents SMS - Short Message services UML- Unified Modeling Language WHO- World health Organization xii DEFINITION OF TERMS Gross Domestic Products: It is the total market value of the goods and services produced by a country’s economy during a specified period of time. It includes all final goods and services—that is, those that are produced by the economic agents located in that country regardless of their ownership and that are not resold in any form. It is used throughout the world as the main measure of output and economic activity (Commission on Growth and Development, 2008). Internet of Things (IoT) - Refers to the inter-connection of everyday objects which are often equipped with ubiquitous intelligence (Kopetz, 2011). Matatu: The term matatu refers to small-scale public transport vehicles in Kenya. The term is derived from the Kikuyu word “mang’otore matatu”, which means thirty cents the then standard charges for fare by these vehicle operators when they were licensed to operate (Aduwo, 1990). Road Traffic Accident (RTA): is any injury due to crashes originating from, terminating with or involving a vehicle partially or fully on a public road (World Health Organization (World Health Organization, 2013). xiii ACKNOWLEDGEMENT I would first like to immensely thank my supervisor Dr. Vitalis Ozianyi (PhD) for his consistent guidance and patience through the entire research period. I would also like to thank my parents and my brother for constantly motivating and supporting me. May God bless you all. 1 CHAPTER ONE INTRODUCTION 1.1 Background Over the years, technological advancement in automotive industry has produced smart vehicles that are now being part of the intelligent transport system. The intelligent transport system applies information processing, communication and sensor technologies in vehicles to increase the safety and effectiveness of the transport systems (Guerrero-Ibáñez, Zeadally, & Contreras-Castillo, 2018). Even though the vehicles are becoming more intelligent, the persons driving the vehicles are becoming careless, ignorant and irresponsible on the roads thus road traffic accidents (RTAs). Road carnage is an emerging public health problem globally with over 1.2 million deaths and 10 million wounded or incapacitated annually (World Health Organization, 2015). Road traffic fatalities are the ninth leading contributor to the burden of disease and the tenth leading cause of death by injury globally. Deaths from injuries are predicted to rise exponentially up to 8.4 million worldwide by 2020 (World Health Organization, 2015). The major cause of road accidents and crashes is due to human error. The common human errors which result in accidents are: - Over Speeding, Drunken Driving, Driver Distraction, Failure to observe traffic lights, Avoiding Safety Gears, Non-adherence to lane driving and overtaking in the wrong manner. The National Transport Safety Authority 2015, report shows that 80% of road accident deaths in Kenya were attributed to drunken driving. Road accidents come after HIV/AIDS and malaria as the well- known cause of deaths in Kenya according (Odero, Khayesi & Heda, 2003). The researcher was interested in combating road accidents by commercial vehicles as a result of drunk driving. Drunk driving is the major cause of road accidents in Kenya (National Transport Safety Authority, 2015). Technically, Kenya’s permissible Blood Alcohol Concentration limit is 0.08 g/dl or 80mg/100ml (National Transport and safety Authority, 2018). If the BAC exceeds the 2 limit at the same time driving, you are considered as a drunk driver. Driving under intoxication is called drunk driving. Drunk driving impairs driver’s ability to judge, see and think so as to take appropriate timely action for safe driving (Shield, Kehoe, Gmel, Rehm, & Rehm, 2012). Prohibiting drunk driving is one of the major road safety challenges globally (Shield, Kehoe, Gmel & Rehm, 2012). Today, technological development is the only hope the countries have to play the great role of combating the traffic road accidents (Kumar Jakkar, Pahuja, Saini, & Sahu, 2017). Motivated by the idea of making our roads safer, the research revolves around making the commercial vehicles smart enough to check the driver’s drunken state and alert the SACCO managers giving them the GPS location and Registration of the vehicle. The SACCO managers should intercept the vehicle immediately before any accident happens. Fuzzy logic compares and analyzes the response of different sensors for the ‘alert SMS’ to be sent via GSM to Managers. 1.2 Problem statement In 2011, the government of Kenya introduced the breathalyzer on roads through the ministry of transport by Legal Notice No. 138 of 2011 dated October 5, 2011. The breathalyzers were to comply with the law which clearly states that drunk driving must be proven. Corruption by the parties involved has made it almost impossible to get the culprits. A series of scientifically, rigorous and randomized control by Georgetown University in United States of America, Direct Line Assurance Kenya and other insurance companies tested the efficacy of the “Zusha!” stickers; found that vehicles with the stickers were up to 50 per cent less likely to be involved in an accident (Standard Digital Published Wed, May 13th 2015). The sticker was to encourage the passengers to protest in case the driver is found driving in a manner that endangers their lives. The stickers are not effective since after the passengers protest and alight from the matatu, pedestrians are still at the risk of becoming the victims. Therefore, a more efficient technology needs to be developed to help intercept the driver immediately alcohol is detected by the system. 3 To address the problem of drunken driving, the researcher develops an expert system using fuzzy logic inference engine which is more effective and reliable in monitoring drunk commercial drivers. Internet of Things is used in real-time communication on the drunken status of the driver. The solution is a long-term solution to reduce RTAs due to drunken driving. 1.3 Research objectives i. To analyze the challenges of drunk driver monitoring in Kenya. ii. To examine the existing drunk driver monitoring methods and systems used in Kenya. iii. To review and develop a system that can be used in monitoring drunk drivers. iv. To test the developed system. 1.4 Research questions i. What are the challenges faced of monitoring drunk drivers in Kenya? ii. What are the existing drunk driver monitoring methods and systems in Kenya? iii. How can an efficient system for drunk driver monitoring be developed? iv. How can the system be tested to ensure it meets the requirement of drunk driver monitoring? 1.5 Significance of the study If Kenya is to achieve its aspirations as stipulated in its Vision 2030 document in eradicating poverty, road safety must be given priority. Reduction of poverty cannot be a reality if billions of dollars are spent on the aftermath of road crashes. Despite the large social and economic costs, there has been a relatively small amount of investment in road safety research and development compared with other types of health losses. It is high time that the government of Kenya invests in research in order to come up with the best technology to deal with this menace. Therefore, there exists the need to develop a good system that receives a warm reception from the market and at the same time help to reduce accidents of drunken driving. The study aims at aiding in policy formulation that addresses the major causes 4 of accidents thus reducing the number of deaths resulting from Road Transport Accidents in Kenya. 1.6 Scope of the study To develop an alcohol monitoring system that sends the output in real-time through Internet of Things within Nairobi County. The out is an alert message sent to the Sacco manager’s mobile phone if alcohol concentration exceeds the set threshold. 5 CHAPTER TWO LITERATURE REVIEW 2.1 Introduction In this section we conduct a critical review of the existing literature on the alcohol related road traffic accidents. It also discusses how RTAs has been managed previously. The Researcher also examines already existing theoretical framework and conceptual framework from which helps identify relevant parameters used in the study. It also covers past relevant studies, identifying the gaps that helps come up with a system that can be adopted by transport systems in Nairobi County. 2.2 Traffic Road Accident Review The global loss due to road traffic injuries is estimated to be US $ 518 billion. It is estimated that traffic crashes cost the governments between 1% and 3% of their gross product- more than the total amount received in low-income and middle-income countries in development assistance (World Health Organization, 2013). Therefore, there is a great need to focus on research that ensures that in future more money goes to development and at the same time experience a reduction of road traffic injuries that have been consuming much of the money. 2.2.1 Global Traffic Road Accident Alcohol is among the world’s top three priority areas in public health (WHO, 2009). A survey by WHO shows about 2 billion people (33%) worldwide who consume alcoholic beverages (World Health Organization, 2004). This means that 33% of the world population is at risks of becoming the victims of road accident if at any time the driver drives while drunk (World Health Organization, 2004). The resolution 64/2551 proclaiming a Decade of Action for Road Safety to stabilize and reduce the increasing trend in road traffic fatalities was adopted (United Nations General Assembly, 2010). Interestingly Road Traffic Accidents in already developed countries is expected to fall by 2020, while the converse is true for the developing countries (International Road Assessment Program me, 2009). World Health 6 Organization report shows that the cost to the economy due to Road Traffic Accidents costs an approximately 1- 2% of a country’s gross national product (World Health Organization, 2012). 2.2.2 Africa Traffic Road Accident Alcohol hangovers may cause impairment in performance and attendance (Rehm & Eschmann, 2002). This may cause serious road fatalities due to poor judgments while driving thus Road Traffic Accidents. In Africa, the average fatality rate is ± 24.1 fatalities/100,000 people whilst, globally the average is ± 18 fatalities/ 100,000 people (World Health Organization, 2013). In 2010, a report issued by World Health Organization clearly shows that South Africa has one of the world’s poorest road safety records of ± 31.9 fatalities/100,000 people (World Health Organization, 2010). This is very high since comparable developing countries have much lower fatalities. Early December 2018, South Africa Minister of Transport, Blade Nzimande released an update to South Africans on the mid festive season road accident statistics which he said they had increased by 16% claiming 767 lives (Ministry of Transport, 2018). The blame was on drunken driving, violations of road rules and excessive speeding (Ministry of Transport, 2018). A population based survey study on Road Traffic Accidents conducted in Nigeria (Libinjo, 2009) revealed that Road Traffic Accidents was a serious problem claiming almost 200,000 Nigerian lives annually and injuring 4 million more (Libinjo, 2009). The study indicates that men were more likely to be at a risk of being involved in road accidents than women, while younger people formed the bulk of road accident victims. The economy was being affected negatively at rate of $25 million per annum (Libinjo, 2009). When the young population is affected the productivity of the region goes down (Libinjo, 2009). Uganda experiences Road Traffic Accidents deaths at ± 28.9/ 100,000 population of people (World Health Organization, 2010). This is quite concerning as it even exceeds World ± 18 and Africa ± 24.1/ 100,000 population of people (World Health Organization, 2010). Uganda is among the top-ranking countries for Road Traffic 7 Accidents along with South Africa and Nigeria (World Health Organization, 2010). The road fatalities have affected the economy negatively since the productive population suffers most (World Health Organization, 2010). 2.2.3 Kenya Traffic Road Accident In December 2018, The Global status report on road safety 2018 was released. It highlighted that the number of annual road traffic deaths has reached 1.35 million (World Health Organization, 2018). In their survey, more than 13,463 people were killed in road traffic crashes were reported in Kenya last year (World Health Organization, 2018). Even though WHO has accused NTSA of under reporting on Road Traffic Accidents (World Health Organization, 2018), the released report shows that 2,965 died at the scene of accident (National Transport and safety Authority, 2018). However, more than one-third of these deaths are among the passengers, many of whom are killed in unsafe forms of public transportation (National Transport and Safety Authority, 2018). Kenya Police report clearly records 85.5% of crashes are caused by poor driver behavior, of which driver error represents 44.4%, pedestrians and passengers 33.9% and pedal cyclists 7.2% (Odero et al., 2003; Odero etal. 1997). This resulted to different reactions from transport authorities in Kenya which includes the ban on night travels of all Public Service Vehicles until the government stated requirements are met (National Transport and safety Authority, 2017). Drunk driving intensifies the probability of being involved in a crash (World Health Organization, 2013). Impairment of senses starts at very low levels of alcohol with the probability of being involved in a crash growing rapidly as consumption increases (World Health Organization, 2013). Majority of adult drivers get impaired with a BAC level of 0.05 g/dl, while at 0.1 g/dl the risk of crashing is five times higher than that of a sober person (Hurst, 1994). Traffic police have also been on the receiving end on their role in reducing road accidents. Corruption has been cited as one of the reasons the traffic police have failed to arrest the drivers found to have infringed on the regulations of road use (National Transport and Safety Authority, 2016). 8 2.2.4 Nairobi County Traffic Road Accident Nairobi, the capital city of Kenya hosts national government and Nairobi county government offices. It is also the economic hub of East and central Africa and acts as an opening point to all land locked countries in East and Central Africa (East African Economic report, 2012). The population of Nairobi city has experienced a continued growth since the year 2009 when it was at 3,138,000 (Population and Housing Census, 2009). The County’s population continues to grow at the rate of 4.0% (World Urbanization Prospects, 2018). Continued urban growth has increased transportation growth of public transport comprising of minibuses, taxis, matatus and more recently by commercial motorcycles with a large population relying on public transport system, which has been marked with unstructured operations due to poor monitoring (World Urbanization Prospects, 2018). Poor monitoring due to unstructured operations means drivers flouts traffic rules resulting to externalities such as accidents, congestion and corruption (National Transport and safety Authority, 2018). The distance of the road network in Nairobi as of 2012 was about 58,000 kilometers long (Kenya Road Board, 2012), with an approximate 1.2 million vehicles using these roads. Today, Nairobi road network has 177,800 Kilometers of road (Kenya National Highway Authority, 2019). According to the Kenya Traffic Police department pedal, driver, pedestrian, cyclist, passengers are categorized as the human factors directly responsible for accidents in Nairobi County (Ministry of Transport and Communication, 2004). There are different factors that are connected to immediate cause of accidents. Drunken driving has made the Nairobi County to be the leading county in road accidents (National Transport and safety Authority, 2016). 2.3 World Adopted Technology for Reducing Alcohol related Traffic Accidents There is no technology that has been documented as a universal solution to the alcohol related Road Traffic Accidents. This is due to different requirement in terms of supporting infrastructure and culture of different communities in the world. However, various countries have tried to adopt different technologies that suite it’s culture and can be supported by available infrastructure to reduce this menace. 9 2.3.1 Technology Used in USA to reduce Road Traffic Accidents United States of America through government funded research consortium used infra-red technology (Bud Zaouk, 2009). The technology uses a finger touch-based sensor where screening happens immediately the driver touches the start button, or any other designated surface in the car (Bud Zaouk, 2009). Alcohol levels would be measured under the skin's surface on a touch-pad with an infrared light scanner. If alcohol is detected the engine won’t start (Bud Zaouk, 2009). 2.3.2 Technology Used in Asia to reduce Road Traffic Accidents In Asia artificial intelligent have been used. India has used Artificial Intelligent to improve on road safety (Kumar, 2017). Artificial intelligence addresses the issue of safety through Advanced Driver Assistance Systems (ADAS) (Kumar, 2017). The tool detects driver’s drunken behavior (Kumar, 2017). With assistance parameters such as eye blinking etc., after detecting funny behavior it locks the engine through a message from a GSM modem (Sandeep, Ravikumar, & Ranjith, 2017) 2.3.3 Technology Used in Africa to reduce Road Traffic Accidents In Africa, there is no universal technology that has been documented to have been used to regulate Road Traffic Accidents. However, governments in Africa are putting the resources into a research to identify suitable technology to assist in reducing the Road Traffic Accidents. In South Africa, a self-policing technology solution to reduce RTAs has been devised. The devised system works on any type of vehicle and essentially consists of a mobile digital event recorder ‘black box’ (Sung, 2015). The technology works as a stand- alone and fixed system, to monitor the vehicle through cameras, real-time sound recording, GPS receiver and video activated by certain events, such as over speeding or use of emergency lights (Sung, 2015). These are useful pieces of information that can be used by transport expert to analyze the severity and major cause of a traffic crash with precision, and suggest tailored solutions to prevent them. Mauritius, as a result of urbanization has generated centralized and intensive population resulting to gradual deterioration of public safety (Prelims, 2018). In 2010, 10 Closed-Circuit Television surveillance (CCTV) system was installed to improve on the existing safety mechanisms (Ministry of Public Infrastructure and Land Transport, 2010). However, the technology features low video resolution (720p) and cannot be used with intelligent applications. There is a lot of manual work done to comprehensively detect, analyze, and then disperse urban traffic in real-time (Ministry of Public Infrastructure and Land Transport, 2018). In 2018, the government of Mauritius national strategy commenced installation of safe city infrastructure which is in line with their vision 2030 document (Ministry of Public Infrastructure and Land Transport, 2018). They contracted Huawei in collaboration with Mauritius Telecom, a state owned telecom company to help build an all-cloud Safe City based on the concept of ‘one cloud and one pool’ to bring the digital world to every corner of the island (Ministry of Public Infrastructure and Land Transport, 2018). The Safe City construction has the following aspects; converged command, public safety monitoring, Intelligent Traffic Systems (ITS) and Service through cloud computing (Ministry of Public Infrastructure and Land Transport, 2018). Delivery of the project’s first phase is currently underway, with completion expected in the end of 2019 (Ministry of Public Infrastructure and Land Transport, 2018). The new technology strengthens public safety and optimizes transportation (Mauritius Police Force, 2018). 2.3.4 Technology Used in Kenya to reduce Road Traffic Accidents The Kenyan government signed various bills into Traffic law in order to reduce Road Traffic Accidents. Many of these Road Traffic Accidents were given a lot of attention from 2004 to 2007 (Ministry of Transport and Communication, 2007). This was because year 2003 saw the enactment and enforcement of more stringent traffic rules by the then Minister for Transport, the late Hon. John Michuki (Scalar & Alexander, 2007). The rules mainly targeted the PSVs, (Scalar & Alexander, 2007). The passenger capacity for matatus was reduced to 14, speed limit set at 80kph, speed governors introduced and safety belts for all passengers were made mandatory as well as vetting of drivers and conductors, who had to meet stricter guidelines. Through Gazette Notice number 384 of 2004 the then minister of transport gave a specification of the types of speed 11 governors approved by himself pursuant to the purported Rule (Integrated National Transport Policy (INTP) report, 2009). NTSA body was formed through an Act of Parliament; Act Number 33 on 26th October 2012 after the government found that the public has relaxed to observe the ‘Michuki rules’. In 2014, the government through the ministry of interior security contracted Safaricom Ltd to install surveillances cameras in Mombasa and Nairobi city (Ministry of interior security, 2014). Safaricom in collaboration with Huawei installed systems that provide real-time data to a central point at the police headquarters in Nairobi and to connect all police stations in the two cities to high-speed (4G) Internet (Ministry of interior security, 2014). The systems have improved security on the two cities and on the roads (Ministry of interior security, 2014). However, road traffic accidents are still happening and therefore need for more sophisticated technology. 2.3.5 Technology Used in Nairobi County to reduce Road Traffic Accidents After formation of NTSA by an act of parliament, their vision was to ensure zero traffic accidents. Therefore, the government invested $ 30,000.00 to buy 15 breathalyzers (National Transport and safety Authority, 2014). They were distributed in Nairobi County roads on the areas that were considered black spots by then (National Transport and safety Authority, 2014). However, this technology has experienced a lot of challenges in its implementation as the rule 3(1) of the breathalyzer rules was declared inconsistent with the Traffic Act, and hence cannot be used to enforce charges (Kakah, 2017). The rules were considered unconstitutional as they were found not able to reinforce the provisions of the Traffic Act as was intended (Kakah, 2017). The judges also faulted the fact that rules alone cannot amend statutory provisions considering that the breathalyzer rules do not make it an offence to drive after consuming alcohol beyond the prescribed limits (Kakah, 2017). In 2016, mobile night vision speed cameras were deployed on the roads (National Transport and safety Authority, 2016). The cameras were to monitor speed day and night in all-weather condition putting motorists under 24-hour surveillance on Kenyan roads (National Transport and safety Authority, 2016). However, the 12 technology has not served the purpose, reason being the corrupt traffic police (Njoroge, Kiplagat, Kariuki, & Mutua, 2016). Motorists have also complained of being wrongly targeted by the traffic police (Njoroge, Kiplagat, Kariuki, & Mutua, 2016). 2.3.6 Conclusion on already existing technology It is very clear from above review that there is no universal technology that has been adopted to reduce alcohol related traffic accidents globally. Therefore, it is the work of the government research institutions and Universities to research on a suitable technology that helps in reducing Road Traffic Accidents problem. 2.4 Internet of Things Internet of Things is a system of interrelated computing devices, mechanical and digital machines, objects, animals or people that are provided with unique identifiers and the ability to transfer data over a network without requiring human-to-human or human-to-computer interaction (Kopetz, 2011). The term Internet of Things according to the 2020 conceptual framework is expressed through a formula such as: - Internet of Things = Services+ Data+ Networks + Sensors (Muhammad, 2017). Internets of Things applications are vast and innumerable (Muhammad, 2017). Devices that have been used in Internet of Things have constrained functionalities and minimal footprint; which employ lower internal storage, memory and computation power than typical devices (Suh et al., 2007). Through use Internet of Things, it has enabled physical devices to hear, see and perform tasks by allowing them to communicate with each other to share information and collaborate to make decisions (Gartner, 2017). After connecting the objects to the internet, they can be recognized by other objects and controlled remotely across existing network infrastructure to contribute information to a database (Rajiv Desai, 2016). Therefore, the internet of things describes internet where data is created by things (Doshi, Apthorpe, & Feamster, 2018). Internet of Things systems has given users opportunity to achieve deeper automation, analysis and integration within a system in many institutions (Doshi, Apthorpe, & Feamster, 2018). 13 2.4.1 Internet of Things and Transportation Industry Transportation industry is among the most promising sectors for the internet of things (Intel Corporation, 2014). The interconnected things in transportation industry collect data which is stored in databases at the point of collection (Intel Corporation, 2014). World Health Organization, in collaboration with other bodies of various countries collect vast amount of data that is converted into meaningful and actionable knowledge (World Health Organization, 2018). The internet of things is of great use in solving many of modern society’s automotive safety and transportation efficiency (Huang, Zhang & She, 2018). Such technology as fleet management has helped to solve many transportation problems. 2.4.2 Internet of Things Architecture Figure 2.1 IoT Architecture (IEEE standards 1451.2, 1997) Figure 2.1 is the most popular architecture of Internet of Things. It has three layers; Perception layer, network layer and application layer. Actuators and sensors are connected to the Internet of Things from the Perception layer. Communication between 14 “things” and human being is aided by Network layer. Applications are always implemented in the application layer (Ashton, 1999). The Internet of Things Architecture in Figure 2.1 shows the process of data acquisition, data processing, data storage and its’ transmission functions for all kinds of devices and equipment under the umbrella of Internet of Things (Vermesan, 2014). It also supports real-time monitoring of the environment to acquire data (Vermesan, 2014). The Institute of Electrical and Electronics Engineers standard in Figure 2.1 enables the researcher to simplify the development of the system by defining hardware and software blocks that do not depend on specific network control. Each sensor has its own strength and weaknesses for specific application class (Mark, Corporation, & Hufnagel, 1997). The Internet of Things platform ensures that web enabled devices communicate to one another and act on the processed data from the environment (Saxena & Gupta, 2017). Internet of Things technology allows a level of real-time information (Saxena & Gupta, 2017). 2.5 Real-Time technology Real-time communication is a major requirement in internet of things technology (Saxena & Gupta, 2017). Development of this technology cannot be explained well without mentioning instant messaging. In history, instant messengers were consumer friendly, internet connected real-time communication clients (Saxena & Gupta, 2017). Most popular Real-time protocols today are: - extensible Messaging and Presence Protocol (XMPP), Constrained Application Protocol (CoAP), Message Queue Telemetry Transport (MQTT) which is a publish-subscribe messaging protocol (Kurt, 2015). 2.5.1 MQTT Application in a Real-time Technology Message Queue Telemetry Transport has a light weight packet structure designed to conserve both memory usage and power (Mala, 2019). A connected device subscribes to a topic hosted on the Message Queue Telemetry Transport broker (Hillar, 2017). Every time another device or service publishes data to a topic, all of the devices subscribed to it automatically get the updated information (Hillar, 2017). Therefore, the researcher chooses to use MQTT technology for this research study. 15 2.6 Air Quality Monitoring Systems Modern society has experienced an exponential growth in industries and transportation. In this study; the author discusses how the air quality has been affected by pollution from the two industries (Yang & Pun, 2017). However, air quality monitoring systems have increasingly gained more attention (Yang & Pun, 2017). Over the years, a wide range of sensor technologies has become available on the market enabling revolutionary shift in air monitoring and assessment (Morawska, et al., 2018). The cost of the sensors has also gone down (Morawska, et al., 2018). Internet of Things has provided a real-time monitoring platform and the researchers can get air quality status in real-time (Ahasan, Roy, Saim, Akter, & Hossain, 2018). 2.6.1 Application of Machine Learning in Drunk Driver Detection Driver’s behavior plays a critical role in driving safety. Alcohol concentration in the blood may lead to change of behavior for a driver while driving (Kenntner-Mabiala, Kaussner, Jagiellowicz-Kaufmann, Hoffmann, & Krüger, 2015). Images and videos have been widely used over the past years as the most advancing applications in artificial intelligent transportation (Baran, Rusc, & Fornalski, 2015). The change of driver’s behavior has been categorized into three major categories namely; Biological indicators, Facial Expression Feature analysis and Vehicle behavior. Use of biological techniques has the best detection technique but they have been found to be intrusive (Baran, Rusc, & Fornalski, 2015). Use of vehicle behavior information to detect drunkenness, by taking the lane position measurement, car speed, the turning angle etc. is a no-intrusive and is easy to measure but they have several limitations such as driving conditions, road condition and require considerable time to analyze them (Baran, Rusc, & Fornalski, 2015). Facial Expressions like yawning cannot be used to detect driver’s drunkenness (McDonald, Lee, Schwarz, & Brown, 2018). 2.7 Fuzzy Logic Fuzzy logic is a form of computing based on “degree of truth” rather than usual Boolean logic that the modern computers are based (Shamim, Enam, Qidwai, & Godil, 2011). Use of Fuzzy logic algorithms have enabled machines to understand and respond 16 to vague human concepts such as high, moderate, low, e.tc. (Shamim, Enam, Qidwai, & Godil, 2011) Fuzzy logic can model complex, nonlinear problems linguistically rather than mathematically and using natural language processing (Shamim, Enam, Qidwai, & Godil, 2011). Fuzzy logic is closer to the way our brain works. We aggregate data and form a number of partial truths which can also be aggregated to higher truth that can cause a result like motor reaction (Babanli, 2019). 2.7.1 Fuzzy Inference System Fuzzy inference is a process of formulating the mapping function from a given input to an output by use of fuzzy logic (Straszecka, 2017). The mapping function then provides the bases of which the decision is made (Straszecka, 2017). Fuzzy rules are based on Fuzzy premises and Fuzzy consequences (Xiong, 2008). Use of IF- THEN type of fuzzy rules converts the fuzzy inputs to the fuzzy output. Inference evaluates all these rules and to determine their truth values (Xiong, 2008). All the rules are considered when making the final decision. Figure 2.2 Linguistic variable fuzzification to defuzzification of output process. Figure 2.2 shows input of two sensors. The two gas sensors collect values from the environment. Classification of gases is done using fuzzy logic approach. The rules of the fuzzy inference system are defined and mapped on the member function. The 17 inputs from the two sensors are combined by AND operation. By applying the rules to the fuzzy Inference system (FIS) the output is obtained. The results (output) obtained from fuzzy inference system is verified based on the closeness of the output fixed value. 2.7.2 Application of Fuzzy logic Fuzzy logic is a technique in artificial intelligent (AI) that is widely used to control environmental factors (Rasyidah & Nadiah, 2013). The effectiveness of fuzzy logic has been proven through a lot of creation of intelligent system using fuzzy logic application (Rasyidah & Nadiah, 2013). 2.7.3 Application of Fuzzy Logic to detect Abnormal Odor In modern society, human activity and in particular waste water treatment and city council waste management, are the major sources of odor nuisance (Szulczyński, Gębicki, & Namieśnik, 2018). For this reason, monitoring of odor nuisance is now an extremely important issue to be addressed in developing countries (Szulczyński, Gębicki, & Namieśnik, 2018). Practically, it is more valuable to directly determine the odor nuisances by use of results from analytical air monitoring (Szulczyński, Gębicki, & Namieśnik, 2018). The solution to air nuisances would keep the public more informed about the status of odor air quality. It would also make it possible to forecast the extent of significant nuisance of the projected objects based on the results of simulation of odor spread in the environment of emitters (Szulczyński, Gębicki, & Namieśnik, 2018). Semiconductor Gas sensor coupled with pattern recognition algorithm has been used to detect odor (Zhang, Tian, & Zhang, 2018). However, abnormal odors like perfume, alcohol etc. would show strong sensor response (Zhang, Tian, & Zhang, 2018). One of the characters that characterize the smell is odor intensity. It is perceived as strength of odor sensation is triggered by a specific stimulus (Zhang, Tian, & Zhang, 2018). Quantitative odor intensity determinations are based on sensory analysis in which a sensory panel determines the intensity of the odor using a verbal point scale (Szulczyński, Gębicki, & Namieśnik, 2018). An example of such a scale is the seven point scale (German Standard VDI 3940, 2006). The odor intensity is measured in a range of 0 to 6. That is from ‘Not perceptible’ which 0 is, Very Weak is 1, Weak is 2, 18 Distinct is 3, Strong is 4, Very strong is 5, and extremely strong as 6. The classification according to the intensity was able to give the researcher viable results. The obtained results using fuzzy logic algorithms were compared by the author with the values obtained using multiple linear regression model and sensory analysis. The above analysis gives a chance for holistic analysis of the concentration of gasses. Sensors change gas information into an analytically useful signal. The signal is then sent to the recognition system using appropriate mathematical algorithm. Fuzzy logic system uses the following independent elements (Szulczyński, Gębicki, & Namieśnik, 2018):- i. Sampling system; provides stable conditions for getting the readings e.g. gas flow velocity, humidity, temperature and removes all undesirable factors that can affect the sensor response. ii. Detection system; measuring chamber which exhibits different sensitivity. iii. Data processing system; it processes the signal received from the sensor. iv. Pattern recognition system; assigns the received signals to one of the pattern classes. 2.7.4 Use of Fuzzy Inference System in Target gas Identification from other Odors The relationship between two sensors and the output data level is determined by fuzzy rules in the inference system. Fuzzy rules are determined using perception level by human judgment (Hajek, 2010). Fuzzy logic is a multivalued logic where truth values lie between any real numbers 0 and 1(Hajek, 2010). Fuzzy logic handles the partial truth concept (Hajek, 2010). In decision-making the evaluation of different options occurs. This lead to dropping out those that do not fit established procedures (Caballero & Mitrani, 2000). The researcher used the Fuzzy logic procedure to clearly show how he gets the target odor that was nuisance to the public. Procedure I; the fuzzification process starts when the input data is gathered by the sensors and using membership function, they are converted to fuzzy input set. The gathered data is raw data. 19 Procedure II; the formulation of fuzzy logic rules is done at this stage. The system uses IF-THEN formulated rules. These rules are constructed from linguistic variables that take on fuzzy values that are represented by words and modeled as fuzzy subsets of the given domain. Procedure iii; using the member function the fuzzy input is finally mapped to give the output. The output is usually useful information that the users of the system can act on. Figure 2.3 Output value as calculated by Fuzzy system (Szulczyński, et al., 2018) In Figure 2.3 the output shows the odour intensity which must correspond to specific set of signal values. The set of rules based on conjuctive operations are applied. The example set of rule is:- IF (S1 € STRONG ODOUR AND S2 € STRONG ODOUR Then O€ ODOUR STRONG The key idea that has been used to get the target Odor from disturbances is through fuzzy logic where they are categorized. Alcohol being an abnormal odor faces interference from other gases in a real world air scenario (Szulczyński, Gębicki, & Namieśnik, 2018). This interference is caused by close sensitivity characteristics of gas sensors (Szulczyński, Gębicki, & Namieśnik, 2018). 20 2.7.5 Characteristics of Alcohol Sensor module MQ-3 Sensor module is the most preffered for gas detection in industries and homes (Zhang, Tian, & Zhang, 2018). It is used to detect Alcohol, Benzine, Hexane, LPG,CO, CH4. The sensor has high sensitivity and fast response time making it possible to take measurement in real-time. The sensor signal value reflect the approximated trend of gas concentration in permissible error range (Zhang, Tian, & Zhang, 2018). Therefore, MQ-3 gas sensor DOES NOT give exact gas concentration (Zhang, Tian, & Zhang, 2018). MQ-3 module sensor features are:- High sensitivity to alcohols and small sensitivity to benzine, it is stable and long life, it has high capability of fast response and high sensitivity. The study by the seeed international (Manufacturer of IoT devices) the minimum concentration that can be tested is 0.1mg/L and the maximum is 10mg/L equivalent to 10ppm-1000ppm. The readings are measured in particles per million and indicated as either mg/L or ppm (0.4 mg/L = 220 ppm in air). 2.7.6 Characteristics of MQ-135 Sensor MQ-135 is designed to monitor indoor air condition. It responds to a wide range of toxic gases namely-: Carbon monoxide, alcohol, acetone, formaldehyde etc. Because of its measuring mechanism, the MQ-135 sensor can’t output explicit data to characterize target gas’s concentrations quantitatively. Even though, the output is still competent enough to be used in applications that require only qualitative results. The sensor values reflect the approximated trend of gas concentration in permissible error range (Zhang, Tian, & Zhang, 2018). Therefore, MQ-135 gas sensor DOES NOT give exact gas concentration (Zhang, Tian, & Zhang, 2018). MQ-135 sensor has low conductivity to clean air. Its conductivity increases as the concentration of sensing gases increases. The module provides both digital and analog outputs. MQ-135 sensor Air Quality Sensor module can be interfaced easily with Micro controllers, Arduino Boards, Raspberry Pi. The study by the seeed international (Manufacturer of IoT devices) the range of alcohol sensitivity using MQ135 is 10ppm- 300ppm. 21 2.7.7 The Archtecture of the Proposed System In Figure 2.4, the process of data acquisition is achieved by the breathe alcohol sensor and odor sensor. Sensors translate the measurements from the driver’s environment (real world) into data for the digital domain. The GSM module sends the data to the cloud. Once the data gets into the cloud is processed. The processed data results to information which becomes useful to the end user. This is through a text alert to the end user. Graphical User Interface helps to locate the driver on a Google map. Figure 2.4 Proposed Architecture of the real-time driver monitoring system The proposed system is an embedded system which is a microcontroller-based, software driven, reliable, real-time control system, operating on diverse physical variables and in diverse environments. A GSM shield is used to transmit data from the micro-controller to the Internet of Things server for storage, data analysis and classification. The researcher connects to the Internet of Things server to display the driver drunk status through the android mobile application and a desktop application. The system is used to notify the SACCO managers in real-time the drunken status of the driver and the GPS location. 22 CHAPTER THREE METHODOLOGY 3.1 Introduction The general objective of this study is to develop a real-time drunk driver monitoring system through Internet of Things. The chapter explains the procedures that the researcher used in the different stages of the research. The chapter also indicates the different locations where the research took place, the purpose of the research as well as the techniques used in collection and analysis of data. 3.2 Research Design The design that was adopted to carry out the research was meant to solve a practical problem. Through extensive discussion the researcher identified a problem in the domain of road accidents where there is need to come out with an innovation of a real-time drunk driver monitoring system through the Internet of Things. Through quantitative research relevant data was subsequently collected and analyzed appropriately and conclusions were drawn using questionnaires and interview responses. The researcher reviewed the conceptual literature concerning concepts, empirical literature consisting of earlier studies that are close to the proposed solution. 3.3 Data collection The researcher employed both primary and secondary data. 3.3.1 Secondary data Secondary data sources include past researches on the topic that have been published. Publication includes newspapers, articles, government publications and Journals. The method provides efficiency in data collection since the data is already collected by other researchers or interested parties on the same topic. In this study, primary and secondary data is used to give a clear understanding of the current technology used to detect drunkenness in drivers when performing their duty. 23 3.3.2 Primary Data It is raw data collected from the field of study and within the same scope. Qualitative research is always unstructured and helps to give insight to the topic of the research. Tools used in data collections are interviews and questionnaires. 3.4 Instruments of data collection The researcher used questionnaires and interviews for data collection. 3.4.1 Interviews The interview follows structured predetermined questions prepared in advance by the interviewer. This type of interview ensures consistency and accuracy of the data at the same time. A specific response is given since all the respondents were asked the same set of questions. 3.4.2 Questionnaire The researcher used questionnaires as the most frequent method of data collection. The respondents were the members of the Matatu SACCOs and passengers travelling at the time of questionnaire admission, and any report documented by the NTSA. The collected data aided in understanding the problem domain and consequently laid the foundation for the development of the proposed solution. Relevant data collected was analyzed appropriately and sound conclusions were drawn. 3.5 Data Analysis “Analyzing the data in a qualitative study essentially involves synthesizing the information the researcher obtains from various sources into a coherent description of what he has observed or otherwise discovered.” (Fraenkel & Wallen, 2000, p.505). Deciding how the qualitative and quantitative data are mixed is an important procedural consideration as well as the timing and weighting (Cresswell & Plano Clark, 2007). Data was processed and analyzed using Microsoft Excel spreadsheets and visualized using Microsoft Excel. Data processing is the manipulation of items of data into meaningful information. Microsoft excel is a spreadsheet application that enables 24 the researcher to perform necessary calculations and graphical processing e.g. creating tables for easy visualization. 3.5.1 Data Presentation Data presentation is a method of summarization, organization and communication of information using a variety of tools, such as diagrams, distribution charts, and histograms and graphs (Alabi, 2013). The researcher used pie charts diagrams to present the feedback from the respondents. The main advantage of pie charts is that they display relative proportions of multiple classes of data and are visually simpler than other types of graphs. Tables were used by the researcher to get the frequency of occurrence of certain events in the study. 3.5.2 Prototype System Testing The researcher tested the system to identify all possible issues before the releasing it to the users. Usability testing involved the intended users in their working environment and enabled the developer to identify problems before they are coded and ensure that the system is user-friendly. 3.6 Target Population and Sampling Frame In order to estimate the target population, sampling was used. Kenya has 200 registered matatu SACCO’s (National Transport and Safety Authority, 2017). Nairobi city alone has 75 Matatu SACCO’s (National Transport and Safety Authority, 2017). The target population comprised the Commercial Vehicles SACCOs with the highest Alcohol Related Road Accidents as profiled by National Transport and Safety Authority. Through homogenous purposive sampling the researcher identified 20 Matatu SACCOs with high NTSA accident rating of Alcohol Related Road Accidents. A homogeneous purposive sample is selected for having a shared characteristic. It is very useful in situations where you need to reach a targeted sample quickly, and where sampling for proportionality is not the main concern (Gentles, Charles, & Ploeg, 2015). The drivers helped to determine the feasibility of creating a drunk driver monitoring system its benefits and potential future features. 25 3.7 System Implementation Methodology 3.7.1 The V-Model For successful implementation of the system, early testing is critical. Therefore, the model that supports this is the V-Model. The V-model saves time for development and it is cost effective. It easily allows change to take place during development and the developer can introduce another module comfortably. The V- Model is divided into three phases namely: - Project definition, Implementation, project test and integration. a) Project definition Project definition is divided into three phases: - concept of operation, requirement and architecture and detailed design. i. Concept operation This is where requirement are understood. This is the most critical part for the researcher because most of the time the requirements are not well defined at the initial stage. A lot of communication happens at this stage and it can be said that acceptance test design planning happens at this stage as business requirements are used as inputs. ii. Requirement and Architecture After getting clear and detailed definition of the requirement, the researcher designed the system. The system design portrayed the details of the complete hardware and understanding of the functionalities for the drunken driving monitoring system. The system test plan was based on system design. The development scheme gave the researcher enough time for the actual testing and execution. Architectural design gave an insight to the actual system and how it links up all its various components, either internally or externally via outside integrations. iii. Detailed design The design contains detailed specifications for how all functions and logic of the system were implemented. It also gives a clear insight of how the system functions. b) Project Implementation At this phase the researcher implemented the design of the system. The implementation followed logic to convert previously generated design and specification document into 26 a real functional project system. Implementation was done completely for the system testing and integration to begin. c) Project Testing and Integration Project testing and integration was done in three phases: - Integration test and verification, system verification and validation and operation and maintenance. i. Integration test and verification The researcher tested the blueprint of the system during architectural design. ii. System verification and validation System verification enabled the researcher to check the entire system functions and its communication to the external system. Mostly, system verification and validation enabled the researcher identify any issue with the hardware compatibility. iii. Operation and maintenance This is where the system is taken into the user’s environment. The drunk driver monitoring system is a functional at users’ live environment. Figure 3.1 V-model (Systems Engineering Process, 2016) 27 Figure 3.1 shows different stages of the system implementation. The researcher chose the V-model since at every stage of developing the system, verification and validation is essential. The researcher tested every component individually before its implementation into the project. The Real-Time Drunk Driver Monitoring System through IoT main component is the Arduino UNO (Internet of Things Development Board). In software part, Arduino IDE was interfaced with Arduino board. Arduino IDE is an open-source environment that makes it easy for the user to write code and programmed to the Arduino board. The Arduino IDE software consists of an Integrated Development Environment (IDE) and the core libraries. The MQ-3 and MQ-135 sensors are directly connected to it. A GSM shield was connected to the Arduino UNO board with the cloud. The ngrok platform enabled real- time data streaming and visualization for driver monitoring from a local computer making it global. Mobile application was developed for SACCO managers to monitor the drivers. In case the driver is drunk, the SACCO managers were notified in real-time in order to act immediately. 3.8 Quality Aspects of the Research The aspects of Quality research are measured as the degree to which research was carried correctly (Gentles et al., 2015). To ensure quality is maintained, validity and reliability are achieved without any compromise. The researcher adhered to the principles of accountability, transparency, auditability and professionalism. 3.8.1 Validity Validity refers to a well-designed study that is appropriate to generalize the population of interest. The validity of this study was achieved through review of the instruments to be used. It enabled the researcher to get an appropriate result that maintains the quality of the study. The researcher categorizes validity into three namely: - Internal validity, construct validity and External Validity. 28 i. Internal validity in this study seeks to establish a relationship between two variables. It refers to the degree to which a study can make good inferences about this causal relationship. Internal validity is achieved if a researcher can definitively state that the effects observed in the study were due to the manipulation of the independent variable and not due to another factor. Variables that cannot be controlled by the researcher and can affect the outcome of the study can affect or prevent the internal validity. ii. Construct Validity helps in generalizing from the specificities of a study to the broader concept that the study attempts to measure or attempts to draws conclusions. iii. External validity involves the extent to which the conclusions can be generalized to the broader population. The sample group taken is a representative of the target population to ensure external validity is achieved. 3.8.2 Reliability In this research reliability was attained by giving respondents of the target population questionnaires to fill. During development various surveys were initiated so as to check the correlation between the two. It kept the researcher in touch with the user to ensure the purpose of the study is achieved. 3.9 Ethical Code of Conduct Considerations To adhere to ethical codes of conduct, data was collected willingly from correspondents and no one was coerced to share individual’s private information, Sacco’s private data, institutions data and companies. Any of the correspondents private data collected remains private and only used for analysis purposes unless otherwise defined in agreements by the respondents. The driver monitoring system was attached only to the willing owners of commercial vehicles. 29 CHAPTER FOUR SYSTEM ANALYSIS AND DESIGN 4.1 Introduction Chapter four in this study reports on the design of the system. The design was done with consideration of the requirement collected in chapter three through questionnaires with the probable sampled target population. To visualize the system in multiple dimensions, Unified Modified Language is used to draw diagrams. Requirement and data analysis were also carried out at this stage. 4.2 Interview Analysis The researcher used live structured interview questions. The aim was to determine the social demographic of road users within Nairobi. The interview gave the researcher an insight of the road user and their occupation. 4.2.1 Social Demographic profile of road users in Nairobi, Kenya Out of the group sampled for the interview, 70.0% were males, while 30.0% were females. Again, 65.0% were in the age group 20-30 years, while 20.0%, were in the age group 31-40 years. In addition, 10.0% were between 41-50 years. Table 4.1 Social Demographic Profile of Road Users in Nairobi Age Years Frequency Percentage 20-30 13 65.0% 31-40 4 20.0% 41-50 2 10.0% Above 1 5.0% Total 20 100% Occupation Formal employment 9 45.0% Student/informal employment 6 30.0% Business people 3 15.0% None of above 2 10.0% Total 20 100% 30 From the Table 4.1 the study shows majority of the road users were between the ages of 20-30. In the study, 45% had formal employment, 30% were student and people who had informal way of getting income, 15% were business people while 10% did not fit in any of the category above. Majority of people who travelled frequently by the road included informal employed/student and formally employed people. From the table, there exists a significant relationship between occupation and vulnerability to road accident related fatalities. From the Table 4.1 the researcher deduced a conclusion that the youth and working in the society have a very high risk of becoming victims of Road Transport Accidents. 4.3 Questionnaire Analysis The respondents were sampled from 20 matatu Saccos profiled as the worst to travel with chosen through simple random sampling technique. The respondents to the study were defined since the target population was matatu Sacco members recovering from the effects of the accidents. Positive response was registered since 90% of the participants responded. 4.3.1 Major causes of the RTAs in Nairobi Figure 4.1 Major causes of road accident in Nairobi. From figure 4.1, it was reported that 60% of road accidents in Nairobi are caused by drunk driving. Poor state of the road and over speeding recorded 15% each while negligence was by 10%. 60% 15% 10% 15% Major Causes of RTAs in Nairobi Drunk driving Poor State of the roads Negligence Over Speeding 31 4.3.2 Relationship between the day of the week and RTAs Table 4.2 Number of road accidents in 2018 and 2017 (NTSA, 2017/2018) 2018 January – 11th November,2018 (ROAD ACCIDENTS) 2017(ROAD ACCIDENTS) Monday 48 37 Tuesday 20 25 Wednesday 10 16 Thursday 9 11 Friday 55 75 Saturday 58 76 Sunday 79 80 The data in Table 4.2 was obtained from National Transport and Safety Authority records on 25th January, 2019. The aim of getting the data was to get an insight of how and when the road accidents are likely to happen most in Kenya and in particular in Nairobi County. The information was used to advice the Public Service Vehicle management on when to be more vigilant on monitoring the drunken drivers using the system. Table 4.2 data shows that, weekends are deadliest days to travel as they recorded the highest number of accidents. Sunday recorded High number of accidents with 79 Saturday is 58 and Friday 55. The researcher was able to make an inference that on weekends the probability of getting a drunkard road user is high compared to any other day of the week. Therefore, drunken driving is likely to happen on this day more than other days of the week. The inference was made after comparison between Figure 4.1 and Table 4.2 4.3.3 Number of victims directly or indirectly involved in Road Traffic Accidents Figure 4.2 Indicates that 79% of the people who filled the questionnaire were victims of road accident. This was family members, friends or people they well knew. 32 Figure 4.2 Victims of RTAs 4.3.4 Effectiveness of “SMS alert” notification Question 4.3.4 was directed to the management of the Public Service Vehicle’s. The researcher sought to know the effectiveness of the response immediately they get an “SMS alert” of a drunk driver in the line of duty. From figure 4.3, 85% of the respondent agreed to respond immediately after getting an “alert SMS”. This was after them consenting that they have chase cars. 15% of the respondents were not sure of taking action reason being that they do not have chase cars. The other reason was that the matatu SACCO was young and they don’t have resources to invest in one. They also consented if they get resources or any support to buy one they would act on the SMS alert. The effectiveness of an “SMS alert” was also an indicator that the system is effective and meets its expectation. Figure 4.3 Effectiveness of an “SMS alert” 80% 20% A victim directly/ indirectly involved in RTAs YES NO 85% 15% An "alert SMS" Effectiveness YES Not Sure 33 4.4 Requirement Specifications Requirement specification describes the behavior of drunken driver monitoring system through Internet of Things. They are divided into functional and non-functional requirement. 4.4.1 Functional Requirement Functional requirements explain complete events of the system. This is through identification of the necessary task carried by the system, actions taken or activities that must be accomplished. They include: i. The system should read analog alcohol and purity of air in the Matatu environment. ii. The system should convert the sensor data into digital form and send it to an online MySQL database. iii. The system should send a text alert to the SACCO managers on duty once alcohol is detected from the breath of the driver. iv. The system mobile application should display vital readings of the of the drivers breath in real-time. v. The Internet of Thing cloud platform i.e. thinger.io which is part of the system should save sensor readings from the device in its database and provide visualizations of the data via its web-portal. 4.4.2 Non- functional Requirement A non-functional requirement goes into the specificity of the criteria used to judge the operation of a system, rather than specific behaviors. The requirement of Non- Functional Requirement in Internet of Things system design is distinct since the design relies on physical components, network protocols and software integration (Mahalank, 2016). The key non-functional requirements identified for the system are security, scalability, performance, availability, usability and reliability. 4.5 System Architecture In Figure 4.4, the Arduino Uno microcontroller converts analog values from the sensors into digital values. The data collected is stored in a fully scalable MySQL 34 database. An alert SMS is sent to the SACCO managers immediately an alcohol signal is detected. The SACCO managers are equipped with a mobile app and desktop app connected to the database via API to enable them continuously monitors the driver’s breath. Figure 4.4 System Architecture 4.6 System Analysis The researcher was able to examine the system structures, the goals to achieve within the boundaries of the system. The researcher was also able to get an insight of how the system handles important information like data structures and repositories. 4.6.1 Use Case Diagram Use Case diagram is used to summarize the details of the systems actors through Unified modeling Language (UML). In the drunk driver monitoring system, the actors in the system are the SACCO managers, Sensor nodes, GSM communication unit and the system administrator. A more detailed depiction might result to a use case as:- i. A pattern of behavior the system exhibits MQ-135 35 ii. A sequence of related transactions performed by an actor and the system iii. Delivering something of value to the actor. Through use cases the researcher was able to capture requirements, create a room to communicate with end users and domain expert to develop the system and finally test the system. Figure 4.5 illustrates the use case diagram that is made up human actors and system actors. The users of the system who include the manager and the supervisor would be monitoring the breath of the driver and use cases provide the sequence of actions of how the system is expected to behave. Figure 4.5 Use Case Diagrams Drunk Driver Monitoring System 36 4.6.2 Use case description This shows detailed interactions between system actors and system itself. It gives description of a complete business transaction either successful or unsuccessful. Table 4.3 Monitoring status of the Device Use Case Name: Status of the Device Description: The Device is always on either of the two states, that is online or offline. The System allows the Administrator to check the online or offline status of the device. Primary Actor: SACCO manager. Trigger: Device not sending data for prolonged duration Pre-condition  The Device must be configured to connect to the database.  The Device must be registered on the database. Post-condition Device is online. Table 4.4 Access Notification Service Used Case Name: Access Notification Service Description: Alcohol in breath is reported via a text message to the SACCO Managers. Primary Actors: SACCO Managers Trigger: Alcohol sensor captures abnormal concentration of alcohol in drivers environment Pre-condition SACCO Manager have a Mobile phone Post-condition SMS alert is successfully sent 37 4.7 UML Sequence diagram UML Sequence diagrams allow the researcher to model how the events are going to occur in drunk driver monitoring system. It gives the researcher a chance to visualize and validate various runtime scenarios with an aim of predicting how the system behaves. Figure 4.6 Sequence diagram Figure 4.6 explains how the drunk driver monitoring system captures data from the sensors and sends it to the IoT database. The data is continually stored and analyzed. The Managers who are the end users receive notifications when positive alcohol detection is made by the device. The sensor nodes capture analogue sensor 38 values () to the microcontroller where it is converted to digital values. It is then transmitted via the GSM module to the Internet of Things server via a transmit data value () message where it is continuously stored and analyzed. Once the Internet of Things server receives and analyses a sensor reading as abnormal reading a Send text alert () message is initiated to alert the manager and supervisor immediately in order to follow up. 4.7.1 System Flow Chart System flow chart represents the work process of the Real-time Drunk Driver Monitoring System illustrating how the system arrives into the final decision making. Figure 4.7 shows how collected data was processed until information is received by the end user. If there is no alcohol detected the system does not send any alert otherwise the sensors continues to scan the environment for Alcohol. Figure 4.7 Flow chart diagrams 39 4.8 System Design System design assists the researcher in identifying the components, modules etc. that address specific needs identified during the research process. 4.8.1 Context Diagram Context diagram graphically identifies the systems external factors and relationship between them. This is a high level view of the system. In figure 4.8, the main user of the system includes the SACCO managers. The sensor gets the data from the driver’s breath and sends it for analysis by the system. Then the feedback is relayed back to the SACCO managers. Figure 4.8 context diagram 40 4.8.2 Level 1 Data Flow Diagram A data flow diagram (DFD) in figure 4.9 depicts out the flow of information for the processes in proposed system. This is as a result of expansion of context diagram in Figure 4.8 into several related levels. Figure 4.9 represents the system’s main processes, data stores and data processes with high level details. Level 1 DFD illustrates how the system works and in a way that is understandable by both the users, developers and any other interested party. The model describes the following processes;- i. The first process is where the sensor captures drivers’ environment data. ii. The data is then analyzed as either clean or high alcohol level is recorded by the IoT server. iii. Finally, based on the analyses, SMS messages are sent to the manager and supervisor. Figure 4.9 Level 1 DFD diagram 41 4.8.3 Partial Domain Model Figure 4.10 shows conceptual classes of the proposed system. The Partial Domain Model shows the association within different classes and how they interact. A notification message is sent to one of the SACCO Manager for a follow up. Figure 4.10 Partial Domain Model 42 CHAPTER FIVE SYSTEM IMPLEMENTATION AND TESTING 5.1 Introduction This chapter explores details of the implementation and testing of the drunk driver monitoring system. The implementation focuses on the different modules of the system, how they are implemented and their functionality. Testing of the system involves verifying that the system satisfies usability requirements as well as the functional requirements. The sensors were deployed in drivers’ environment to capture data in real-time. The GSM module uploaded the data to the server successfully. A fuzzy expert model was used with uploaded data to detect the quality of air and presence of alcohol in drivers’ environment, after which it sends a notification message the both manager and the supervisor if alcohol is detected. 5.2 Components of the System The model comprises of: sensor network level with alcohol sensor and air quality, a transmission layer which contains a GSM module fitted with a local network SIM card, an application layer comprising of a MySQL database and a web application. The hardware was programmed using Arduino IDE. The monitoring application was developed via ionic framework and compiled for both android and OS devices. 5.2.1 Hardware Components i. Arduino UNO Microcontroller- this is the micro-controller that coordinates the interfacing of the GSM and sensors. Arduino UNO is an ATMmega328P based microcontroller board containing 6 analog inputs, 14 digital input/output pins, a 16 MHz quartz crystal, a power jack, a USB connection, an ICSP header and a reset button. ii. GSM Shield -this allows the Arduino board to send and receive Short Messages. It is used to transmit sensor data values to the IoT server for storage and analysis. A local network SIM card is fitted into it. 43 iii. Alcohol sensor (MQ-3) - it contains sensitive material SnO2, Tin Oxide has a lower conductivity in clean air. Immediately on detection of the targeted alcohol gas, the sensor’s conductivity rises along with the gas concentration. MQ-3 gas sensor is more sensitive to alcohol, and has commendable resistance to outrage of gasoline, smoke and vapor. The sensor can detect different alcohol concentration; it is cost effective and suitable for different application. MQ-3 sensor module is an Analogue output sensor. The sensor needs to be connected to any analog socket on the Arduino UNO. Its range of detecting alcohol is between 0.05- 10mg/L. Changes in temperature and humidity affects sensitivity of the sensor. iv. LM2596 DC-DC Buck Converter Step-down Power Module- It is a high-precision potentiometer, capable of driving a load up to 3A with high efficiency, which can work with the arduino UNO, other mainboards and basic modules while the output current keeps greater than 2.5A (or output power greater than 10W). v. A 12 V adapter with 2A current- The adapter powers GSM module. It protects the system from short circuiting and thermal overload conditions. vi. Air Quality sensor (MQ 135) – It contains micro AL2O3 ceramic tube, Tin Dioxide (SnO2) sensitive layer to measure Air Quality. iv. LED – Light Emitting Diode is a semiconductor light source that emits light when current flows through it. In the system, when the alcohol intensity is beyond the set threshold it lights up. 5.2.2 Application layer The Internet of Things architecture was adopted, the application layer is where data from sensors was analyzed and then presented graphically. MySQL database helped to present data in a more scalable and reliable way in that it stored real-time data analytics. The dashboard provided end-to-end business analytics solution indicating the activities occurring throughout the time scope. Its scalability and reliability ensured that security of the data was achieved. Data analysis was done through fuzzy logic. Analyzing the collected data using IoT, SACCO manager were able 44 to get the data from the timestamp which the first case of alcohol was reported in the database. Immediately upon confirmation of High Alcohol on the sensor values, an alert SMS was sent to the SACCO manager on real-time. 5.2.3 Sensor data Analysis A set of linguistic rules described the behavior of the fuzzy logic system used to monitor driver’s breath. The rules illustrate the relationship between the linguistic inputs and the output based on the expert knowledge for the system behavior. The set of IF-THEN rules description are in the form of; IF (set of conditions are satisfied) THEN (set of conditions can be inferred).These rules were meant to determine the intensity of alcohol in the breath in form of a range through defuzzification. Figure 5.1 Fuzzy logic systems 45 Figure 5.1 shows the proposed design of using fuzzy logic system to estimate the alcohol intensity. Fuzzy logic allows a fuzzy description of real systems as an alternative to describe systems using classical binary logic. Inferences are fuzzy rules to relay fuzzy set to make decision. At the end, defuzzification process produces alcohol intensity output from fuzzy functions. The output is then used to influence decision making by the expert. 5.2.4 Fuzzy Rules Fuzzy rules were generated using open source FIS pro fuzzy logic tools. The rules were useful to get training data set. The actual data was used immediately the system started to run on the environment Table 5.1 Fuzzy Rules IF (Input MQ-3 ) is ≥ 800 AND (Input MQ 135) ≥ 550 THEN (Send SMS Alert) IF (Input MQ-3 ) is ≥ 600 AND (Input MQ 135) ≥ 750 THEN (Send SMS Alert) IF (Input MQ-3 is ≥ 800) AND (Input MQ 135 ≥ 750) THEN (Send SMS Alert) In Table 5.1 the inference mechanism calculates the value in which the input data match the condition of the fuzzy rules. It also calculates the rules conclusion based on the matching value, then combining all the inferred rules into the final conclusion. If the alcohol in the breath meets the defined intensity, the final conclusion was to send an alert to the managers. If the response is high alcohol the system makes a decision to notify the SACCO managers through an alert SMS. From the notification, it is upon their decision to take action. 5.2.5 Sample Drunkard Driver alert SMS to the SACCO Managers Figure 5.2 is a sample alert SMS notification showing the vehicle registration number and his location. The figure shows the standard text that the SACCO Manager gets. The GPS co-ordinates enable the SACCO Manager to get the location of the culprit using the Google Map on their phones. If the managers and supervisor use desktop application, he/she views the location directly. The system allows only one driver to be paired to one vehicle at a time thus making it easy to track the culprit. 46 Figure 5.2 sample alert SMS 5.3 Implementation of the System and Experimentation To demonstrate the system effectiveness, the researcher used simulated data to validate each rule. The simulated results were useful in identification of cases when the SACCO managers should be notified of strong blood alcohol concentration (BAC) through an alert SMS. The system also did show its ability to send notification on real- time. The system also keeps track of the vehicle location. The different reference cases were used to reflect the driver’s everyday duty. 5.4 System Testing In chapter three of this research, the researcher identifies the methodology to test the system. The methodology was adopted immediately on implementation of the project research. 5.4.1 Functionality Testing The functionality testing was carried iteratively during the development process. The researcher followed the process to ensure that all bugs were fixed and ensure that problem definition is addressed by the solution developed. The functionality testing ensured that user requirements were met, and that the system executed perfectly. The experiment was successfully implemented to validate the researcher’s approach to monitor drunk drivers. 47 Table 5.2 Functional testing Test Case Description Priority Functional Confirm that the system sends an SMS when alcohol is detected to be above the limit High Functional Confirm that the mobile application displays the gives an alert incase the driver is found drunk. High Functionality Does the system correctly to give an alert when alcohol is detected. High 5.4.2 Integration Testing Integration testing was done to verify and validate the functionality of the whole system. Alcohol was used in a Matatu environment to test the entire system. The system responded positively. This was motivation to the user to continue to the next level of system testing. 5.4.3 Usability Testing There researcher carried a posttest survey on how effective the application is in terms of usability, acceptance and experience. The SACCO Managers and some of the drivers of Five Matatu SACCOs were given six questionnaires which they responded to accordingly. The researcher analyzed results from different respondents. The system was easily attached to the vehicle at strategic position without interfering with driver’s driving environment. The 80% of the respondents agreed to use the system in the belief that it is able to reduce alcohol related accidents. The 73% of the respondents were able to use mobile applications successively after training them for less than 15 minutes. They could get the GPS location using Google Map on their mobile application from the 48 longitude coordinates and latitude co-ordinates sent to them through alert SMS by the system. Table 5.3 clearly shows the results of the questionnaires from the respondent. Table 5.3 Usability Test User Experience, functionality and Usability Respondents=30 Yes No Don’t Know Was device effectively attached to the Matatu? 65% 10% 25% I am willing to use the system to monitor the drivers/be monitored to determine drunken status? 80% 3% 17% The mobile and desktop application is easy to use 73% 20% 7% The device would make it possible to reduce road accidents. 80% 10% 10% i. Ability to embed the system on a matatu According to Figure 5.3, 60% of the intended system users agreed that it was possible to embed the system in a strategic position in the public service vehicles without interfering with its’ normal operation. However, 30% of the users agreed it is still a challenge to embed the system. 10% of the users were not on either side. Figure 5.3 Ability to embed the system into a Public Service Vehicle 60% 30% 10% Ability to embed the system Easily embedded A challenge to embed Not sure 49 ii. System Acceptance The researcher desired to know the users response on how much they want solution. There was 85% acceptance from the respondent. The 13% of the respondents felt that monitoring their drunken status would interfere with their working environment. In their defense, they said that the effects of monitoring them reflected if they fail to hit the target fixed by the SACCO of their daily collections. Figure 5.4 show the results. Figure 5.4 System Acceptance 87% 13% System Acceptance Acceptance No Acceptance 50 CHAPTER SIX DISCUSSIONS 6.1 Introduction This chapter discusses the results of previous chapters in the light of the research and solution provided by the researcher. The researcher developed a system of a Real- Time IoT based Drunk Driver Monitoring System. In the discussion the researcher sheds light on how the system functionality conforms to the objectives of the research as well as the solution provided. 6.2 System functionality In the literature review, the researcher identified different methods that have been used by different governments and even the world recognized bodies to fight alcohol related road accidents. The study describes the challenges that have been met when trying to solve drunken driving problems. The researcher spotted the need to develop a real-time monitoring system that keeps the supervisory and management body informed on the drunken status of their drivers. The system of an Internet of Things based real-time drunk driver monitoring system collects the contamination readings of the driver’s environment. If the system detected a considerable amount of alcohol it sent a notification SMS to both the manager and supervisor. 6.3 The results of the study The first objective was to analyze the challenges of drunk driver monitoring in Kenya. With the current technology, the driver needs to be checked now and then using a breathalyzer. The result is time wasting since in the public transport system; it also depended on how many trips you make. It has also caused an alarm to the health sector since incase of communicable disease, it can be transferred easily from one driver to another. The second objective was to examine the existing drunk driver monitoring methods and systems used in Kenya. Breathalyzers are used by Kenya police at different targets in busy roads connecting Nairobi County. Police men work tirelessly 51 with an aim of monitoring drunk drivers and punishing them if found guilty. Zusha! Stickers on matatus have been used with an aim of motivating the passengers to forcefully command the driver to slow down or stop the vehicle when they notice weird behavior. The third objective was to review and develop a system that can monitor drunk drivers. A real-time drunk driver monitoring system is the system the researcher found suitable to notify the management where they should take action against the driver. The model has sensors that are attached near the steering wheel and also on the drivers’ seat. The sensor data is analyzed using sensor inference rules. The fourth objective was to test the developed system. Chapter three describes different methods used to test the system. Various results collected were used to analyze the viability of the system. The results proved that the system can monitor the drunk driver and give the required results thus in combination with the management good results can be achieved. 6.4 Advantages of IoT based real-time driver monitoring system Transportation industry has constantly been seeking critical real-time information to monitor their business. Such information has resulted to tremendous competitive advantages in the business arena. The ability of the management to track real-time driver’s behavior develops trust that makes clientele base grow more rapidly. This leads to more profit for the business. In many businesses decision making follow four broad steps namely: - collection, transmission, Analysis and Visualization. Data collected, transmitted and analyzed can help the industry make viable decisions when hiring drivers. Drivers with record of driving while drunk can be identified easily from a shared database. The industry gets a chance to employ only those who are qualified and have no or minimal history of driving under the influence of alcohol. Therefore, the four steps provide a means to an end. Real-time IoT can function as tool that can reduce time wastage and save money. National Transport and Safety Authority in collaboration with Kenya Traffic Police has 52 worked all through to monitor driver’s drunkenness day and night using breathalyzers. They have used chase cars to get the unruly drivers. This work can be reduced by using the Real-Time IoT based Drunk Driver Monitoring System. The database should give an alert in-case of drunken alert SMS from the sensors. 6.5 Disadvantages of IoT based real-time driver monitoring system The system can only give a range of alcohol concentration and sometimes the readings can be misleading. This can result to the driver being charged wrongly. The system also depends on availability of the internet. The users of the system must be technically trained to use the system. The respondents did sign the Participant Information and Consent Form as a means of confirming that everything about the project was explained to their satisfaction and they willingly participated in giving the feedback. 53 CHAPTER SEVEN CONCLUSIONS AND RECOMMENDATIONS 7.1 Conclusion According to National Transport and Safety Authority (NTSA), in the first 10 months of 2018, 2,585 people had lost their lives on Kenyan roads. This was an 11 percent increase from 2,331, in the same period in 2017. The causes and nature of Road Traffic Accidents have been analyzed for the longest time now. In the report 80% of the accidents were as a result of drunken driving. This resulted to the main objective of this study being development of Real-time IoT based Drunk Driver Monitoring System. The system monitors the driver’s environment and records any strange alcohol concentration on the environment. Then the data collected is analyzed to determine whether the driver can be categorized to be drunk or sober. The system then sends an alert SMS to both the supervisor and manager for them to take action against the drunkard driver. From the study, the researcher was able to identify different technologies used to monitor driver’s drunkenness. The most used technology monitors the biological behavior of the driver like body movement. This technology cannot be adopted in Nairobi due to poor roads and lack of proper management in the industry by the government. Therefore, monitoring driver’s breath on real-time is the best method that can be used in Nairobi and help reduce Road Traffic Accidents. The reason being you can stop the driver as a manager from operating a vehicle when the system reports he is drunk. The V-Model methodology used to implement the project enabled continuous testing of the system functionality. This helped in ensuring that the constraints are managed early enough thus success in implementation. 7.2 Contributions to the research This research has made contribution to the IoT field and real-time data collection. Use of fuzzy logic algorithm enabled the researcher to perform analysis on the data collected. The technology is a tremendous contribution to the transportation industry 54 where the business community can monitor drivers’ drunkenness in real-time. The Technology forms a blueprint to the technology that is suitable for Nairobi County. The technology can be advanced through technological research to suite any changes in the future. The data collected can be kept in a database where the history of the Matatu operator’s (Drivers) behavior can be analyzed in a clearance process when the drivers want to move from one SACCO to another. Issuing of clearance certificate can be made possible by the management of the SACCOs if the driver wishes to leave or transfer to work in any other transportation field. This makes sure that only credible drivers are employed making RTAs reduce at a high rate. 7.3 Recommendations Kenya is positioned 61 among 190 economies in the ease of doing business by World Bank (A World Bank Group Flagship Report, 2018). This gives an opportunity for more investors to come to Kenya thus increasing the population of road users. Population increase in the developing countries has resulted to increase of Road Traffic Accidents (World Health Organization, 2013). Real-Time Monitoring System for Drunk Driver through IoT for safety is a good technology that can help in monitoring driver’s drunken behavior. Based on the research, the following are the recommendations; i. In conjunction with National Transport and Safety Authority the system can be adopted in public and private transport industry. ii. The data collected could be used for analysis. The result can be used to issue clearance certificates that can assist in profiling of drivers. iii. The Matatu SACCOs management could use it to create a portfolio that wins customers confidence thus becoming competitive in the transport industry. 7.4 Suggestions for future research The researcher envisions an advancement of this model to integrate technologies like Data Stream Management System (DSMS). The real-time data enriches the drunk driver monitoring functions such as continuous query, windowing, and aggregation. The data can further be mined to create awareness of most secure transport SACCOs in the industry thus competitively eliminating the affected SACCOs. By using this 55 method, the transport industry works to ensure improved safety thus remaining in the market competitively. The government of Kenya has been issuing certificates of good conduct for the longest period of time. In addition to that certificate, the clearance certificate from various SACCOs is essential. The system should be able to generate a certificate showing the gross conduct of each driver in terms of drunken driving. 56 REFERENCES Ahasan, M. A., Roy, S., Saim, A. H., Akter, R., & Hossain, M. Z. (2018). Arduino-Based Real-Time Air Quality and Pollution Monitoring System. International Journal of Innovative Research in Computer Science & Technology, 6(4), 81-86. doi:10.21276/ijircst.2018.6.4.8 Babanli, M. B. (2019). Fuzzy Logic and Fuzzy Expert System-Based Material Synthesis Methods. Fuzzy Logic. doi:10.5772/intechopen.84493 Balikuddembe, J. K., Ardalan, A., & Khorasani-zavareh, D. (2016). Road traffic incidents in Uganda: A systematic review study of five years trend. Journal of Injury and Violence Research, 9(1). https://doi.org/10.5249/jivr.v9i1.796 Banzi, M. (2011). Getting Started with Arduino. Sebastopol, CA: OReilly & Associates. Baran, R., Rusc, T., & Fornalski, P. (2015). A smart camera for the surveillance of vehicles in intelligent transportation systems. Multimedia Tools and Applications, 75(17), 10471-10493. Doi: 10.1007/s11042-015-3151-y Booch, G. (1994). Object-oriented Analysis and Design with Applications. https://doi.org/10.1007/s00894-009-0527-9 Boza, A., Cortés, B., Cuenca, L., & Alarcón, F. (2015). Internet of things applications in production systems. In ICEIS 2015 - 17th International Conference on Enterprise Information Systems, Proceedings (Vol. 1, pp. 330–337). https://doi.org/10.5220/0005378903300337 Caggiano, A. (2014). Fuzzy Logic. CIRP Encyclopedia of Production Engineering, 562–568. https://doi.org/10.1007/978-3-642-35950-7 CDC. (2009). Data Collection Methods for Program Evaluation: Interviews. Evaluation ETA: Evaluation Briefs. Doshi, R., Apthorpe, N., & Feamster, N. (2018). Machine Learning DDoS Detection for Consumer Internet of Things Devices. 2018 IEEE Security and Privacy Workshops (SPW). doi:10.1109/spw.2018.00013 Drowsy Driver Detection System. (2016). International Journal of Science and Research (IJSR), 5(2), 2134-2137. doi:10.21275/v5i2.nov161716 European facts and the Global status report on road safety (pp. 1-21, Rep.). (2015). Copenhagen Ø, Europe: World Health Organization. 57 Gartner Says 8.4 Billion Connected "Things" Will Be in Use in 2017, Up 31 Percent From 2016. (n.d.). Retrieved from https://www.gartner.com/en/newsroom/press- releases/2017-02-07-gartner-says-8-billion-connected-things-will-be-in-use-in-2017- up-31-percent-from-2016 Ghosh, S., Kundu, D., & Paul, G. (2015). A Fuzzy Logic Approach in Emotion Detection and Recognition and Formulation of an Odor-Based Emotional Fitness Assistive System. International Journal of Synthetic Emotions, 6(2), 14-34. doi:10.4018/ijse.2015070102 Global status report on road safety 2013: supporting a decade of action. (pp. 1-318, Rep.). (2013). Geneva, Switzerland: World Health Organization. doi: http://www.un.org/en/roadsafety/pdf/roadsafety2013_eng.pdf Global status report on road safety 2015. (2018, November 16). Retrieved December 5, 2018, from http://www.who.int/violence_injury_prevention/road_safety_status/2015/en/ Global status report on road safety 2018. (2019, January 09). Retrieved February 5, 2019, from https://www.who.int/violence_injury_prevention/road_safety_status/2018/en/ Google Cloud. (2017). Overview of Internet of Things. April 19,2017. Retrieved from https://cloud.google.com/solutions/iot-overview Guerrero-Ibáñez, J., Zeadally, S., & Contreras-Castillo, J. (2018). Sensor technologies for intelligent transportation systems. Sensors (Switzerland), 18(4), 1–24. https://doi.org/10.3390/s18041212 GSM Association. (2014). Understanding the Internet of Things ( IoT ), (July). Hajek, P. (2010). Fuzzy Logic. In Stanford Encyclopedia of Philosophy. Retrieved from http://plato.stanford.edu/entries/logic-fuzzy/ Hariyanto, Sarno, R., & Wijaya, D. R. (2017). Detection of diabetes from gas analysis of human breath using e-Nose. 2017 11th International Conference on Information & Communication Technology and System (ICTS). doi:10.1109/icts.2017.8265677 Hillar, G. C. (2017). MQTT Essentials. Place of publication not identified: PACKT Publishing Limited. 58 Huang, Q., Zhang, G., & She, C. (2018). A Tentative Research of Internet of Things (IOT) in Automotive Transportation. Proceedings of the 2018 International Conference on Transportation & Logistics, Information & Communication, Smart City (TLICSC 2018). doi:10.2991/tlicsc-18.2018.14 Jack. (2015, May 8). Zusha! Road Safety Campaign Nationwide in Kenya. Retrieved December 5, 2018, from https://gui2de.georgetown.edu/projects/zusha# Kaithuru, Stephen (2015) Alcoholism and its Impact on Work Force: A Case of Kenya Meteorological Station, Nairobi. J Alcohol Drug Depend 3: 192. doi: 10.4172/2329- 6488.1000192 Kenntner-Mabiala, R., Kaussner, Y., Jagiellowicz-Kaufmann, M., Hoffmann, S., & Krüger, H. (2015). Driving Performance Under Alcohol in Simulated Representative Driving Tasks. Journal of Clinical Psychopharmacology, 35(2), 134-142. doi:10.1097/jcp.0000000000000285 Kopetz, H. (2011). Internet of Things. In Real-Time Systems: Design Principles for Distributed Embedded Applications (pp. 307–323). Boston, MA: Springer US. https://doi.org/10.1007/978-1-4419-8237-7_13 Kumar, R., Pahuja, R., Saini, R. K., & Sahu, B. (2017). Natwar. Drunk-Driver Detection and Alert System (DDDAS) for Smart Vehicles. American Journal of Traffic and Transportation Engineering, 2(4), 45–58. https://doi.org/10.11648/j.ajtte.20170204.12 Mahidhar, V., & Schatsky, D. (2013). The Internet of Things. Deloitte University Press. https://doi.org/10.5480/1536-5026-34.1.63 Mala, D. J. (2019). Integrating the internet of things into software engineering practices. Hershey, PA: Engineering Science Reference. Mark, J., & Hufnagel, P. (1997). The IEEE 1451.4 Standard for Smart Transducers. Sensors And Actuators, 1–13. Mcdonald, A. D., Lee, J. D., Schwarz, C., & Brown, T. L. (2018). A contextual and temporal algorithm for driver drowsiness detection. Accident Analysis & Prevention, 113, 25-37. doi:10.1016/j.aap.2018.01.005 Menachem Domb (August 1st 2018). An Adaptive Lightweight Security Framework Suited for IoT, Internet of Things - Technology, Applications and Standardization, Jaydip Sen, IntechOpen, DOI: 10.5772/intechopen.73712. Available from: https://www.intechopen.com/books/internet-of-things-technology-applications- and-standardization/an-adaptive-lightweight-security-framework-suited-for-iot 59 Morawska, L., Thai, P. K., Liu, X., Asumadu-Sakyi, A., Ayoko, G., Bartonova, A., Williams, R. (2018). Applications of low-cost sensing technologies for air quality monitoring and exposure assessment: How far have they gone? Environment International, 116, 286-299. doi:10.1016/j.envint.2018.04.018 Murata, A., Urakami, Y., & Moriwaka, M. (2014). An attempt to prevent traffic accidents due to drowsy driving -Prediction of drowsiness by Bayesian estimation. 2014 Proceedings of the SICE Annual Conference (SICE), 1708-1715. doi:10.1109/sice.2014.6935295 Njoroge, K., Kiplagat, S., Kariuki, J., & Mutua, J. (2016, November 08). NTSA acquires night vision cameras to nab speeding drivers. Retrieved from https://www.businessdailyafrica.com/economy/3946234-3446000- 3faf7s/index.html Pandian, P. P., & Kalpanapriya, D. K. (2012). Analysis of Variance For Crisp Data with Membership Grades of Fuzzy Sets. International Journal of Scientific Research, 2(12), 548-552. doi:10.15373/22778179/dec2013/174 Prelims. (2018). SDG11 – Sustainable Cities and Communities: Towards Inclusive, Safe, and Resilient Settlements, I-Xi. doi: 10.1108/978-1-78756-921-820181007 Pujol, F., Pujol, M., Jimeno-Morenilla, A., & Pujol, M. (2017). Face Detection Based on Skin Color Segmentation Using Fuzzy Entropy. Entropy, 19(1), 26. doi: 10.3390/e19010026 Raghavanm, R., & Bhuvaneswari, N. (2015). Intelligent Safety and Security systems in automobiles. 2015 IEEE Technological Innovation in ICT for Agriculture and Rural Development (TIAR), 188-192. https://doi:10.1109/tiar.2015.7358555 Ramanath, T. S., Sudharsan, A., & Udhayaraj, U. F. (2010). Drunken driving and rash driving prevention system. 2010 International Conference on Mechanical and Electrical Technology, 599-603. doi:10.1109/icmet.2010.5598429 Report on Road Traffic Injury Prevention (pp. 1-301, Rep.). (2009). Geneva, Switzerland: World Health Organization. Reporter, D. N. (2018, December 28). SA has the world's poorest road safety records - WHO report. Retrieved from https://www.iol.co.za/dailynews/news/kwazulu- natal/sa-has-the-worlds-poorest-road-safety-records-who-report-18631896 60 Road safety status report 2015 (pp. 1-43, Rep.). (2016). Nairobi, Kenya: National Transport & safety authority. Rock, Frank; Barsan, Nicolae; Weimar, Udo (2008). "Electronic Nose: Current Status and Future Trends". Chemical Reviews.108 (2):705–25.doi:10.1021/cr068121q. PMID 18205411. Rojas, R. (1996). Fuzzy Logic. Neural Networks, 289–310. https://doi.org/10.1007/978-3- 642-61068-4 Sandeep, K., Ravikumar, P., & Ranjith, S. (2017). Novel Drunken Driving Detection and Prevention Models Using Internet of Things. 2017 International Conference on Recent Trends in Electrical, Electronics and Computing Technologies (ICRTEECT). doi:10.1109/icrteect.2017.38 Saxena, S., & Gupta, S. (2017). Practical Real-time Data Processing and Analytics. Birmingham: Packt Publishing. Selase, A. E., Xing, C., Agbadze, O. K., & Thompson, B. E. (2015). The General Overview of the Phrase ‘ Fuzzy Logic ,’ (5), 68–73. Shamim, M., Enam, S., Qidwai, U., & Godil, S. (2011). Fuzzy logic: A "simple" solution for complexities in neurosciences? Surgical Neurology International, 2(1), 24. doi:10.4103/2152-7806.77177 Sharma, S., & Kumar, R. (2016). Fuzzy relative entropy based classification scheme for discrimination of odors/gases using a poorly selective sensor array. 2016 IEEE International Conference on Fuzzy Systems (FUZZ-IEEE). doi:10.1109/fuzz- ieee.2016.7737824 Shield, K. D., Kehoe, T., Gmel, G., Rehm, M. X., & Rehm, J. (2012). Societal burden of alcohol. Alcohol in the European Union. Consumption, Harm and Policy Approaches. Straszecka, E. (2017). Diagnostic Inference with the Dempster-Shafer Theory and a Fuzzy Input. Advances in Fuzzy Logic and Technology 2017 Advances in Intelligent Systems and Computing, 361-370. Doi:10.1007/978-3-319-66827-7_33 Sunehra, D., & Jhansi, K. (2015). Implementation of microcontroller based driver assistance and vehicle safety monitoring system. 2015 International Conference on Information Processing (ICIP), 426-428. doi:10.1109/infop.2015.7489420 Szulczyński, B., Gębicki, J., & Namieśnik, J. (2018). Application of fuzzy logic to determine the odour intensity of model gas mixtures using electronic nose. E3S Web of Conferences, 28, 01036. https://doi.org/10.1051/e3sconf/20182801036 61 Umrani, S., Shaikh, S., Mujawar, A., & Yadav, P.S. (2017). International Research Journal of Engineering and Technology (IRJET). Alcohol Sensing Alert with Engine Locking Using IOT, 2. (Shiraj Umrani, 2017) Vermesan, O., & Friess, P. (2013). Internet of things: Converging technologies for smart environments and integrated ecosystems. Aalborg: River. Vijay, J., Saritha, B., Priyadharshini, B., Deepeka, S., & Laxmi, R. (2011). Drunken Drive Protection System. International Journal of Scientific & Engineering Research, 2(12), 1– 4. Retrieved from http://www.ijser.org WHO: Kenya road deaths grossly under-reported. (2018, December 13). Retrieved from https://www.nation.co.ke/news/Kenya-road-deaths-grossly-underreported-- WHO/1056-4893792-ve7d07z/index.html World Report on Road Traffic Injury Prevention (pp. 1-88, Rep.). (2012). Geneva, Switzerland: World Health Organization. World Urbanization Prospects: The 2018 Revision - Urban Agglomerations. (n.d.). Retrieved March 7, 2019, from https://knoema.com/UNWUPUA2018/world- urbanization-prospects-the-2018-revision-urban-agglomerations Xiong, N. (2008). Generating fuzzy rules to identify relevant cases in case-based reasoning. 2008 IEEE International Conference on Fuzzy Systems (IEEE World Congress on Computational Intelligence). doi:10.1109/fuzzy.2008.4630698 Yang, Z., & Pun, L. (2017). Vehicle Detection Using Imaging Technologies and its Applications under Varying Environments: A Review. Proceedings of the 2nd World Congress on Civil, Structural, and Environmental Engineering. doi:10.11159/icte17.110 Zheng, K., Zhao, S., Yang, Z., Xiong, X., & Xiang, W. (2016). Design and Implementation of LPWA-Based Air Quality Monitoring System. IEEE Access, 4, 3238-3245. doi:10.1109/access.2016.2582153 Zhang, L., Tian, F., & Zhang, D. (2018). Self-expression-Based Abnormal Odor Detection. Electronic Nose: Algorithmic Challenges, 279-298. doi:10.1007/978-981-13- 2167-2_17 62 APPENDICES Appendix A Turnitin Originality Report 63 Appendix B Participant Information and Consent Form 64 65 66 Appendix C Research Questionnaire 67 68 Appendix D Interview Questions 69 Appendix E Desktop Application Graphical User Interface 70 Appendix F GPS Tracking of a Vehicle 71 Appendix G Pairing a Driver to a Vehicle 72 Appendix H Pictorial Representation of the system 73 Appendix I Sensors Setup Code void setup() { myGsm.begin(9600);//sets the baud rate Serial.begin(9600); delay(500); pinMode(DOUTpin, INPUT);//sets the pin as an input to the arduino pinMode(ledPin, OUTPUT);//sets the pin as an output of the arduino //initialize GSM 74 myGsm.println("AT+CGATT=1"); delay(200); printSerialData(); myGsm.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");//setting the SAPBR,connection type is GPRS delay(1000); printSerialData(); myGsm.println("AT+SAPBR=3,1,\"APN\",\"\"");//setting the APN,2nd parameter empty works for all networks delay(5000); printSerialData(); myGsm.println("AT+SAPBR=1,1"); delay(10000); printSerialData(); myGsm.println("AT+HTTPINIT"); //init the HTTP request delay(2000); printSerialData(); //Test GSM POST // Replace url myGsm.println("AT+HTTPPARA=\"URL\",\"http://5700c005.ngrok.io/ptc/api/getD ata/12/\"");// setting the httppara 75 delay(1000); printSerialData(); myGsm.println(); myGsm.println("AT+HTTPACTION=0");//submit the GET request delay(8000);//the delay is important if the return data is are very large, the time required longer. printSerialData(); myGsm.println("AT+HTTPREAD=0,20");// read the data from the website you access delay(3000); printSerialData(); myGsm.println("AT+CIPGSMLOC=1,1"); delay(10000); printSerialData(); } String printSerialGPS() { String gps; while (myGsm.available() != 0) { gps = myGsm.readString(); } return gps; 76 } void sendToServer(int alcohol_level) { myGsm.println("AT+CIPGSMLOC=1,1"); delay(10000); String gps = printSerialGPS(); Serial.println("---------"); String gps_string = gps; String longitude = gps.substring(33, 42); String latitude = gps.substring(43, 52); Serial.println(gps_string); Serial.println(latitude); Serial.println(longitude); Serial.println("---------"); myGsm.println("AT+HTTPPARA=\"URL\",\"http://76e82638.ngrok.io/ptc/api/getD ata/" + String(alcohol_level) + "/" + longitude + "/" + latitude + "/\""); // setting the httppara, delay(1000); printSerialData(); myGsm.println("AT+HTTPACTION=0");//submit the GET request delay(8000); 77 printSerialData(); myGsm.println("AT+HTTPREAD=0,20");// read the data from the website you access delay(3000); printSerialData(); } void printSerialData() { while (myGsm.available() != 0) Serial.write(myGsm.read()); } void loop() { mq3_sensorValue = analogRead(AOUTpin); // read analog input pin 1 mq135_sensorValue = analogRead(AOUTpin2); // read analog input pin 0 // mq3_digitalValue = digitalRead(2); // mq135_digitalValue = digitalRead(2) if (mq135_sensorValue > 750) { if (mq3_sensorValue > 800) { Serial.println("HIGH"); 78 digitalWrite(13, HIGH); sendToServer(mq3_sensorValue); } } else { digitalWrite(13, LOW); } Serial.println("Sensor mq3_sensorValue"); Serial.println(mq3_sensorValue, DEC); // prints the value read Serial.println("Sensor mq135_sensorValue"); Serial.println(mq135_sensorValue, DEC); // prints the value read delay(1000); // wait 100ms for next reading } 79 Appendix J php code for ' Alert SMS ' Notification load->model('ApiModel'); } function getData($alcohol_level, $longitude, $latitude){ echo $alcohol_level," ",$longitude," ",$latitude; $data = array( 'content_level' => $alcohol_level, 'latitude' => $latitude, 'longitude' => $longitude, 'pair_id' =>12 ); Modules::run('general/insertData', 'alcohol_level',$data); $this->getDifference($longitude,$latitude); } function getDifference($longitude, $latitude){ $result = $this->ApiModel->getRecent(); $result2 = $this->ApiModel->getDetails(12); // print_r($result2[0]->phone); $date1 = strtotime($result[2]->timestamp); 80 $date2 = strtotime($result[0]->timestamp); // // Formulate the Difference between two dates $diff = abs($date2 - $date1); $determinant = ($diff/60); if ($determinant <10){ $message = "Alcohol level are high dont drive !!!"; $message2 = "Driver ".$result2[0]->fname." (".$result2[0]->number_plate.") is driving under the influence. Lat:".$latitude." Long:".$longitude; // $this->sendSMS($result2[0]->phone,$message); $this->sendSMS("0712487511",$message); $this->sendSMS("0712487511",$message2); } } function sendSMS($number,$message){ require_once(APPPATH.'libraries/AfricasTalkingGateway.php'); // Specify your authentication credentials $username = "alcoblow"; $apikey = "0b4262ab2a678e4cf175b799a8be207c9f1a477e36593122df153205899e86f2"; // Specify the numbers that you want to send to in a comma-separated list $recipients = $number; // Specify your AfricasTalking shortCode or sender id // Create a new instance of our awesome gateway class $gateway = new AfricasTalkingGateway($username, $apikey); // Any gateway error will be captured // so wrap the call in a try-catch block try { // Thats it, hit send and we'll take care of the rest. 81 $results = $gateway->sendMessage($recipients, $message); foreach($results as $result) { // status is either "Success" or "error message" echo " Number: " .$result->number; echo " Status: " .$result->status; echo " MessageId: " .$result->messageId; echo " Cost: " .$result->cost."\n"; } } catch ( AfricasTalkingGatewayException $e ) { echo "Encountered an error while sending: ".$e->getMessage(); } } } 82 Appendix K Ethical review approval letter