1 Introduction

In 2011, a road accident report from the South African Government and Arrive Alive stated that road accidents that were based on road factors, 50% were due to sharp bends in roads, 12.5% were due to poor visibility, 18.8% were due to poor condition of road surfaces and 12.5% were due to the road surface being slippery or wet [1]. With an increasing number of road users around the world, it is paramount that the safety of every road user is regarded as the number one priority when traveling on a road. While most accidents on roads today are caused by speeding, reckless driving and so forth, accidents based on road conditions such as potholes, speed bumps, slick surfaces and dangerous curves can be prevented [2]. Thus, a road safety is required to detect hazardous events.

In this study, a novel low cost road safety solution is developed to detect potential events that can cause an accident and the share information with other relevant users. Information regarding such incidents can assist motorists to adopt required safe driving methods as a precautionary measure aimed at improving road safety. Accident caused due to poor visibility, improper road surfaces and sharp turnings are addressed in the developed solution. Sensory systems for detecting sharp turns, speed bumps and detection of rainy and foggy conditions that reduce visibility are developed in this study.

The designed solution uses an Internet of Vehicles (IoV) approach that contains a wireless sensor network (WSN) of sensory nodes and vehicular clients. The WSN in the designed solution contain embedded systems for the vehicular user and infrastructure waypoints. The embedded system for the vehicle contains communication apparatus and sensory systems for detecting speed bumps and sharp turns. The embedded system of the waypoint contains rain and fog detection systems. Information is exchanged between vehicles though the vehicle-to-vehicle (V2 V) communication system. The vehicle-to-infrastructure communication interface is used to exchange information between the waypoints and vehicular clients.

Vehicle-to-infrastructure (V2I) communication is the wireless transmission of data between vehicles and infrastructure waypoints and Vehicle-to-vehicle (V2V) communication is the inter-vehicle exchange of data which together create a network of the IoV solution for road users [3]. V2V communication can help create awareness for road users of the environment around them with minimal effort from the user and can help prevent road accidents from occurring, improve transit time and thus, create a more efficient road network. Not all V2V and V2I implementations are the same due to different data obtained in each system. What data is obtained in each system defines the application of a V2V communication network. Applications of V2V and V2I communication include: improving traffic congestion by informing a user of alternative routes through GPS data [4], collision avoidance using sensors such as LIDAR and ultrasonic [4], data obtained from weather systems to inform users of conditions such as wet roads or limited visibility [5] and helping to improve braking, steering and cruise control [6] of a vehicle from information obtained from vehicles around the user [7]. These applications will help create driver awareness, improve travel time and costs and help reduce road hazards and accidents that exist on roads today and help with the advancement towards autonomous vehicles [8].

Various communication technologies that have been used for V2V and V2I communications and can be split into long, medium and short-range communication. Long range communications include cellular technologies and WiMAX [9]. Challenges that arise with both of these technologies include high distribution costs and coverage may not always be available in particular areas. Distance of communication of these technologies are excellent however, communicating between two vehicles at great distances may cause unnecessary congestion on the network that could result in communication delays for other users and that there may be more critical information received from a vehicle that is closer to the user than the information received from a vehicle much further away. Medium range wireless technologies, which include Wi-Fi and dedicated short range communications (DSRC), provide slightly better solutions for communications with regards to distance of communication however; availability is a major drawback [9]. Concerning Wi-Fi, multiple hotspots would need to be created as vehicles will constantly be moving into and out of different hotspots and will be required to connect and disconnect each time. This not only increases time for communication but also the cost of implementation and distribution. DSRC may suffer from fragmented network problems due to low penetration rates [9]. Short-range communication technologies, which include ZigBee, ultra-wideband (UWB) and Bluetooth, can only be used in line of sight communication as the range of each technology ranges from 10 to 100 m [9]. Other wireless technologies that have been researched include visible light communication (VLC) technology using luminance [10] and radio frequency (RF) based techniques [4] to transmit data. An example of using RF technology is the use of the low powered nRF communication module from Nordic semiconductors [11], which has a range of up to 1 km depending on how the module is configured.

A major concern with V2V communication is the communication itself as the type of communication technology used plays an important role. Factors that influence the choice of wireless technology used include high data rates, interference from other communication frequencies, mobility, frame error rates, quality of service [9] and latency [12]. Data that is transmitted may also be vulnerable and should maintain basic security standards such as confidentiality, integrity and availability [13]. Other concerns include performance of the overall system, technical standards to ensure interoperability, ensuring that drivers use V2V communications appropriately and addressing possible liability issues [14].

Speed bumps have been detected using various methods such as RADAR, LIDAR, laser or ultrasonic sensors. Video sensors can also be used to recognize the similar patterns matching to that of a speedbump [15]. Other methods include the use of accelerometers, which are commonly used together with ultrasonic sensors to detect the speedbump based on the displacement of the vehicle, using normal roads as a reference. The accelerometer, mainly using the z-axis, can be used to detect speedbumps on the road by reading and comparing the magnitude of the readings of a speedbump compared to that of a normal road. The comparisons can be made using statistical tools such as the mean and standard deviations of the readings against the expected readings of a normal road [16]. This can be fused with the readings from an ultrasonic sensor to verify the road abnormality is a speedbump. Ultrasonic sensors use sound waves, with frequencies above the human hearing levels, to measure the distance between two objects, in this case the vehicle and the road surface. Since the sensor contains both a receiver and a transmitter, a signal is transmitted and received, and the time taken for this signal’s round trip is used to measure the distance between the road and the vehicle. For the event that a speed bump is approached, the distance measured would be lower than when driving on normal roads [17].

The following sections in this paper include Sect. 2, which contains the overview of the system developed, Sect. 3 that contains the detailed design and implementation, the results are summarized in Sect. 4 and discussed in Sect. 5 and the paper is concluded in Sect. 6.

2 System Overview

The conceptual design of the entire IoV system for road safety primarily consists of two subsystems which are designed and implemented in this study. The first subsystem is the embedded system mounted on the vehicle for detection of hazards and sharing of such information with other users. The embedded system contains sensors, processing components for detecting hazards associated with presence of speedbumps and sharp turns and the user interface used to notify the user. The wireless communication related components for V2V and V2I communication are also contained in this subsystem.

The embedded system of the infrastructure point, also known as a waypoint is the second subsystem. V2I communication related components along with rain and fog detection components. Presence of rain and fog detected ahead of the user’s current location are shared with the vehicular embedded system. Figure 1 shows the various functional units (FU) of the system designed and implemented for the embedded systems in the wireless sensor network of the Internet of Vehicles solution for improving road safety. The detailed design and implementation of the hardware and software components of the functional units is described in Sect. 3.

Fig. 1
figure 1

Overview of the system

3 Methods and Procedures

3.1 Vehicle Embedded System (Subsystem 1)

3.1.1 Sensors (Fu 1.1)

3.1.1.1 Speedbump

Image processing based technique is widely used in detection of hazards such as speed bumps [15]. The technique is unreliable as it may not be possible to detect a hazard in the absence of daylight. In order to detect such hazards at night, an infrared camera needs to be used. This will however cause interference during the day as infrared light can wash out the colours of daylight and results in poor image quality during the day [18].

Two solutions that resolve the issue of using infrared cameras include using either an infrared cut off filter where a filter is physically moved in front of camera lens to block out the infrared light [18] or to make use of an infrared illuminator [19]. Both of these solutions make use of an ambient light sensor in order to determine when to make use of IR light.

As these two solutions may solve the problem of using a camera for detection of hazards, night time detection may be affected when light from sources such as a street lamp or another vehicle activate the ambient light sensor causing the infrared cut-off filter to be activated or the infrared illuminator to be deactivated. Other factors that influence the image quality of an image taken from a camera include the weather, pavement and camera placement [20]. With above factors into consideration, an array of sensors is used over image processing techniques. In order to detect whether a speedbump has been encountered, distance sensor readings as well as accelerometer impact data was analyzed.

The applications of a distance sensor include positioning and locating of objects, determining dimensions and selection of objects and counting of objects to name a few. For detection of a speedbump, a change in the height can be seen when the distance sensor scans the road surface. Three critical sensors used in distance measurement include LIDAR, ultrasound and IR. The drawback of IR is that it is susceptible to sunlight and may not read accurate distances. LIDAR uses light to measure distance and can prove to be very accurate however, LIDAR sensors are expensive to use. An ultrasonic distance sensor proved to be the appropriate option for distance measurements as it is cheap and can work in most conditions which include dust and dirt.

Ultrasonic distance sensors work with a 40 kHz frequency in order to drive a signal out of the transmitting transducer. A piezoelectric ultrasonic transducer generates sound waves above frequencies that can be heard by humans by rapidly expanding and contracting when a voltage signal is applied. Figure 2 shows the working concept of the distance sensor for measuring distances.

Fig. 2
figure 2

Working concept of ultrasonic sensor

The distance sensor is mounted on the rear of the car and is faced down towards the road surface. As the vehicle moves, the distance sensor scans the road surface. When the distance sensor passes over a speedbump, a change in height occurs. Disadvantages of ultrasonic sensors are that they could produce false positives due to loud noises and they are susceptible to environmental factors such as temperature and humidity. The HC-SR04 ultrasonic distance sensor was used in this implementation as it is capable of detecting distances of up to 4 meters, has a resolution of 3 mm and beam angle of 15 degrees.

The accelerometer outputs voltage levels proportional to the change in the force of gravity on the corresponding axis. In Fig. 3 and Fig. 4, the Z-axis will be affected by acceleration due to gravity and theoretically should output voltage equal to − 9.8 m/s acceleration due gravity.

Fig. 3
figure 3

View of accelerometer axises

Fig. 4
figure 4

Decision diagram used for ultrasonic sensor

External forces acting on the accelerometer from different directions can alter the state and therefore the experienced gravity on the axes. An accelerometer was used over a standard piezo vibration sensor as more data can be obtained from an accelerometer. From a vibration sensor, only a force exerted on the device can be measured whereas with an accelerometer, force as well as acceleration can be measured if required. The accelerometer sensor is mounted on the front dashboard of the vehicle and when the sensor makes impact with a speedbump, a change in the accelerometer axis readings is obtained. For this purpose, the MPU6050 contains a triple axis accelerometer is interfaced via the I2C interface to the ODROID (Fig. 5).

Fig. 5
figure 5

Decision diagram used for accelerometer

3.1.1.2 Sharp turn

In order to obtain the location of a detected hazard and detection of a sharp turn, a GPS module is required. Detection of sharp turns makes use of a change in the location of the GPS module, which can be viewed on a 2D plane. Location and speed data was obtained from a NEO6M GPS module. GPS data over a gyroscope data for detection of a sharp turn was chosen as GPS data is readily available due to the need to determine the location of a hazard. A gyroscope obtaining a change in the horizontal displacement and the vehicles heading angle based on the axis readings would help in the detection of a sharp turn and is done in [20].

In order to obtain the necessary GPS data needed for determining the location of a hazard and in the use of sharp turn detection, the GPS module needs to be configured correctly. This is done through the u-center software suite, which is used for configuration of the u-blox AG global navigation satellite system receiver family. The GPS module is connected to a Windows based computer via a USB cable and is listed as a COM port in the device manager. Once configured, the module is interfaced with the ODROID via the UART communication interface. To obtain latitude, longitude and speed data, the GPS module is configured with the RMC, Recommended Minimum Data, NMEA standard message scheme. To obtain a RMC message response, the following string is written to the serial interface of the GPS module:

  • $EIGPQ,RMC\r\n

Once the request is sent, a response is received however; this can only happen every 60 ms. The message structure can be seen below.

  • $GPRMC,hhmmss,status,latitude,N,longitude,E,spd,cog,ddmmyy,mv,mvE,mode*cs < CR > <LF>

The fields that were required are the latitude and longitude for detection of sharp turns and locations of hazards. From the data extracted, the latitude and longitude parameters need to be adjusted as the GPS module gives them in degrees and minutes, DM, with a decimal offset. The notation required for the software implementation is decimal degrees, DD. The speed of the vehicle was also obtained for testing of the communication modules and needs to be converted to m/s in order to determine how fast the vehicle is moving when testing the communication parameters. Once the notation of the latitude and longitude is corrected, detection of sharp turns and the location of a hazard can be determined (Fig. 6).

Fig. 6
figure 6

Decision diagram for sharp turn

3.1.2 Processing (Fu 1.2)

From the data obtained by the sensors on board the vehicle, processing and analysis of the collected data needs to be performed by an ODROID C1 + Linux Processor board as the main controller and a PIC24 as a secondary controller between the ODROID and the communication module in real time to determine if a hazard has been encountered. The ODROID contains a quad core processor and a 40 pin GPIO used to interface circuitry to the board. The PIC24 communicates to the ODROID via a UART connection.

3.1.2.1 Speedbump

For the HC-SR04 ultrasonic distance sensor, a digital input pin is used to activate a 40 kHz PWM signal for the transmitter and a digital output pin for the receiver. The input pin needs to be driven high by the ODROID for at least 10 μs in order for the 40 kHz signal to be transmitted. The receiving transducer obtains the signal sent by the transmitter and the digital output pin is driven high as long as there is a received signal. The time that the output pin of the ultrasonic sensor is high for is measured by the ODROID and based on the time, the distance between the sensor and the object can be detected. Equation 1 is used to determine the distance read by the ultrasonic distance sensor.

$$ distance = \frac{{pin\,high\,time \left( {ms} \right) \times speed\,of\,sound \left( {m/s} \right) }}{2} $$
(1)

As the speed of sound is affected by factors such as pressure and temperature, accuracy of the distance readings may be influenced. For this implementation, the speed of sound value used is 30 m/s Different threshold values are needed as speed bumps vary in size. If a distance reading of less than 37 cm was received, a possible speedbump was encountered. Figure 7 shows the decision diagram implemented in the system to determine if a speed bump has been detected by the distance sensor.

Fig. 7
figure 7

nRF long range communication module

This can result in possible false positives thus; an accelerometer was used to help improve the overall system. The accelerometer sensor was placed on the dashboard above the speedometer and is placed in such a way that the z-axis value when the vehicle is stationary is approximately equal to 9.8 /.

$$ \sigma = \sqrt {\frac{{\sum (x - \bar{x})^{2} }}{N}} $$
(2)

To detect a possible speedbump, the standard deviation formula, Eq. 2, was applied on the z-axis captured from a road segment that did not contain any speedbumps. The threshold for detection was later calculated in the equation below.

$$ Speedbump_{threshold} = \sigma_{clean\,road\,segment} + \sigma_{clean\,road\,segment} *0.05 $$
(3)

The standard deviation for a clean road segment was calculated to be 0.031, which results in the threshold for the speedbump to be 0.0325, calculated with Eq. 3. This parameter was tuned to 0.04 during the testing of detection for a speedbump. To determine the number of samples required by the system to be processed, the time taken to drive over a relatively large speedbump at 20 km/h was obtained. The total time was calculated to be approximately 4 s. The following formula was applied to determine the number of samples is needed:

$$ \begin{aligned} Number\,of\, samples & = \frac{Total \,time\,over\,speedbump}{Sampling\,time of\,the accleromter} \\ & = \frac{4}{0.003} = 1333 \,samples \\ \end{aligned} $$

The accelerometer would capture 1333 samples from the z-axis, obtain the standard deviation on the set of data, and compare the value to the fixed threshold value of 0.04. If the value is greater than 0.04, a speedbump is detected. Figure 8 shows the decision diagram implemented in the system to determine if a speed bump has been detected by the accelerometer.

Fig. 8
figure 8

Receiving messages in the vehicle system

3.1.2.2 Sharp turn

Making use of GPS location data, detection of a sharp turn is performed by obtaining a change in angle between consecutive GPS points. To calculate the angle between two coordinates, three coordinates are required to form a triangle containing three unknown angles and sides of lengths a, b and c. The distance between three coordinates needs to be calculated. The formula used to calculate the distance between two coordinates makes use of the great circle distance between two points, using the Harvesine formula shown in Eq. 4.

$$ a = \sin^{2} \frac{\Delta \varphi }{2} + \cos \varphi_{1} \times \cos \phi_{2} \times \sin^{2} \frac{\Delta \lambda }{2} $$
(4.1)
$$ c = 2 \times {\text{atan}}2(\sqrt a ,\sqrt {1 - a} ) $$
(4.2)
$$ d = R \times c $$
(4.3)
$$ \phi = \,latitude\,points, \lambda = longitude\,points,R = radius\, of\, Earth = 6371000\,{\text{m}} $$
(4.4)

The law of Cosines is used to solve the unknown angle between the two known coordinates. The law of Cosines equations used in the algorithm can be seen in Eq. 5.15.3 where a, b and c are the distances used for the lengths of the sides of the triangle to obtain the unknown angles.

$$ \cos A = \frac{{b^{2} + c^{2} - a^{2} }}{2bc} $$
(5.1)
$$ \cos B = \frac{{c^{2} + a^{2} - b^{2} }}{2ca} $$
(5.2)
$$ \cos C = \frac{{a^{2} + b^{2} - c^{2} }}{2ab} $$
(5.3)

Once the distances have been calculated, the apex of the turn can be determined. A sharp turn in this system was defined as a turn with an angle that is smaller than 135. Figure 9 shows the decision diagram implemented to determine if a sharp turn has been encountered.

Fig. 9
figure 9

Rain meter sensor with dual interlocking comb design

Once the system obtains three coordinates and computes the angle, the first coordinate is removed from the array and a new coordinate is appended to the array used to calculate the sharp turn angle.

3.1.2.3 Communication (Fu 1.3)

Communication between vehicles and waypoints is performed using an NRF24L01 + long-range radio frequency communication module which can be seen in Fig. 7. This is a low powered, 2.4 GHz ISM band operational communication module capable of communication ranges of up to 1 km. The module is interfaced via the SPI communication interface on the PIC24. Communication technologies such as Wi-Fi or cellular network are more stable however, scalability is an issue and there may be locations where signal is not present. The RF communication modules used in this design are easily available at low costs, provide a long range for communication and contains large platform for configuration concerning the application used in.

The NRF24 communication module uses a carrier frequency of 2.4 GHz to communicate to other modules. The module is interfaced through the SPI interface on the PIC24 microcontroller in order for communication between two control units to occur. The module has a variety of configuration parameters that allow for the best setup concerning the application. For this particular implementation, the module is setup as follows:

  • The air data rate is set to 250 kbps. This is done to obtain the maximum distance for communication possible, which is approximately 1000 m. Using a lower air data rate provides better receiver sensitivity than higher rates however; the use of a high air data rate gives a lower current consumption and reduced probability of on-air-collisions. The air data rate is set by configuring the RF_DR bit in the RF_SETUP register.

  • The RF channel frequency is set to 1 and occupies a bandwidth of less than 1 MHz. The channel is configured by setting the RF_CH register.

  • The payload of the module is set to 2 bytes, as the register sizes on the PIC24 are 2 bytes. A reduced payload size helps reduce errors in transmission.

3.1.2.4 Communication protocol

The vehicle communication system is designed around the possible hazards it can detect and what hazards it should receive. The vehicle only broadcasts information when a possible hazard is detected. The location of the hazard, the type of hazard as well as the source of the packet is broadcasted to other vehicles and/or waypoints.

The “Received from” field will hold a “V” parameter for vehicle, the message ID field will contain either an “S” or a “T” for a speedbump or sharp turn respectively and the location parameter will contain the longitude and latitude coordinates. The structure of the packet can be seen in Table 1.

Table 1 Structure of packet from vehicle

Only the last four digits for the latitude and longitude parameters are used respectively as these values will change within a 100 m range. An example of the packet is shown below:

$$ {\text{VS}}25012606 $$

Calculations as to how many times the message is broadcasted is shown below.

$$ Maximum\, speed \,of\,vehicle\, for\,designed\,system = 100\,{\text{km/h}} = 27.78\,{\text{m/s}} $$
$$ Time\, to\, travel \,100\,{\text{m}} = \frac{100}{27.78} = 3.6\, {\text{s}} $$
$$ Message\, to\, be\, broadcasted\, only\, twice \,every\frac{3.6}{2} = 1.8 \,{\text{s}} $$

When the vehicle system receives a message, the system would check if the message has previously been received. If it has been received, the message is discarded otherwise; the vehicle message handler handles the message. Figure 8 shows how the vehicle handles a message once it is received.

The message handler of the vehicle system breaks down the packet and relays the information to the user. The system first determines the location of the packet, then the hazard and finally, depending on the hazard, the location data is manipulated using the current user’s location and the message received. Once this is complete, the message is displayed on the screen in the vehicle system.

3.1.2.5 Notifications (Fu 1.4)

Notification of hazards detected as well as messages received from other vehicles is displayed on an LCD screen in the vehicle. A standard 16 × 2 LCD display module was used and was interfaced to the vehicle system via I2C.

3.2 Waypoint Embedded System (Subsystem 2)

3.2.1 Sensors (Fu 2.1)

3.2.1.1 Rain Sensor

A rain meter sensor, which makes use of a dual interlocking comb pattern, shown in Fig. 9, is used over an optical rain sensor and a rain gauge due to less components being used in the rain meter opposed to the optical sensor. A rain gauge is not used for detection of rain as it measures the amount of rainfall. When water falls on the surface of the sensor, the water causes the terminals to conduct and a voltage difference is obtained. When there is no water on the surface of the rain meter, there is no voltage difference across the terminals thus, the sensor output is 0 V. When there is full contact on the terminals, the voltage output will be equal to the reference voltage which is the voltage being supplied to the sensor.

3.2.1.2 Fog Sensor

An optical sensor detects fog around the location of the waypoint. Fog is a cloud that occurs at ground level, which is made primarily of water particles. As the air gets warmer, more water can be stored and as the air cools down, it loses its ability to hold the water particles. When the air cools to the dew point, it becomes fully saturated with water vapor and when further cooled, condensation occurs resulting in the formation of fog [21]. Different types of fog occur depending on the amount of visibility. A few different types of fog include aviation fog with a visibility of less than 1000 meters, valley fog which is present when cold air settles in the lower parts of a valley and evaporation fog which is caused by cold air passing over warmer areas [21]. A general visibility range for motorists is approximately 180 meters and in severe conditions could drop to 50 meters under dense fog conditions. When a driver is in the presence of fog, full beam headlights should not be used, as the fog particles [22, 23] will reflect the light back. Taking advantage of this characteristic, an optical sensor is used to detect if fog is present.

An optical rain sensor applies the principle of total internal reflection where an IR beam is transmitted into a sheet of glass at a 45-degree angle and is reflected through the glass if there is no water on the surface. If there is water present on the surface of the sheet of glass, refraction will occur and less light will be reflected through the glass [24]. Based on this, an optical sensor can measure the amount of light passed through the sheet of glass based on the amount of water on the surface of the sheet of glass.

In Fig. 10, it can be seen that if a laser light is directed at a particle, scattering of light [25] will occur in two directions namely forward scattering and backward scattering. Fog particles are typically in the range of 5 μm to 50 μm and when a light source is directed at a large density of fog particles, the light can be seen to scatter forwards and backwards. From these characteristics, it is possible to measure visibility in fog conditions.

Fig. 10
figure 10

Concept of scattering light particles

Optical sensors primarily give a local reading of density of scattered light particles under the assumption that the density of the fog is homogenous. When there is wind present, local density of fog may vary however; this can be overcome if a mean value of samples is taken over a set time range. Mounting of optical sensory is crucial and it is advised to mount where fog is usually the densest. Three different methods that have been used for detecting fog and measuring visibility using the concept of scattering light particles upon the impact of fog particles include transmission, forward and back scatter of light particles. Transmission detection is used in this implementation as forward and back scattering are useful for smaller volumes of fog at a local point of interest whereas transmission can give an indication of fog over a certain range. Natural elements such as fog or rain can have an impact on the visibility conditions as well as pollution which could result in false positives in the detection of fog. Transmission works with two units, one being a light source, such as a laser LED, acting as a transmitter and a light sensor on the opposite side, in the same line of sight of the transmitter acting as the receiver of the light source. In normal visible conditions, the receiver will always receive the light source whereas when there is fog present, the receiver will not receive the light source due to scattering of light particles.

3.2.2 Processing (Fu 2.2)

Rain Sensor In order to detect rain, the rain meter sensor needs to be exposed to water. When more water falls on the sensor, the sensor creates a larger voltage across its terminals resulting in a larger ADC value to be obtained by the ODROID. When there is no water present, the rain sensor returns an ADC value of zero therefore, the algorithm is designed to take 100 measurements, obtain an average and determine if the result is greater than zero. Figure 11 shows the decision diagram implemented to determine if there is rain present.

Fig. 11
figure 11

Rain detection algorithm

Fog Sensor Fog detection works in a similar way to the rain detection algorithm however, the threshold value is different. With the optical sensor, when there is no fog present, a constant high ADC value is obtained by the ODROID due to the laser LED shining directly into the photo resistor. When there is fog present, the reading obtained by the optical sensor is not a constant high value as the fog particles cause the laser LED light to scatter away from the optical sensor resulting in less light being received by the photo resistor. Figure 12 shows the decision diagram implemented to determine if there is fog present around the waypoint.

Fig. 12
figure 12

Fog detection algorithm

3.2.3 Communications (Fu 2.2)

The process of sending information to other vehicles from a waypoint involves more processing as there may be more than one hazard in a particular segment of road that the user needs to know about.

Construction of the message for transmission conditions:

  1. 1.

    There is a maximum of four possible hazards to report to a road user, two of the hazards (speedbump and sharp turns) which need to contain GPS location data. As it would not be required to inform other road users if there is no hazard, the waypoint needs to check its database entries to determine how many hazards of each type are present on a particular segment of road.

  2. 2.

    To limit the number of messages required to send to a vehicle, if the sum of the total amount of hazards present in all the databases is greater than 4, a single message will be broadcasted informing road users that there are multiple hazards ahead.

  3. 3.

    The maximum number of speedbump and sharp turn messages that could be transmitted is two. If there are more than two entries of the mentioned hazards in the databases, a single message will be transmitted stating that there is more than one of the particular type of hazard on the road segment. This is done with respect to point ii keeping the overall hazard transmission list to a maximum of four (Table 2).

    Table 2 Structure of pack from waypoint

The general structure of the packet originating from a waypoint tabulated as follows:

The received from field will hold a “W” parameter to state that the message is from a waypoint, the number of messages field can vary from 1 to 4, depending on the amount of messages required to transmit and will be decremented as the number of messages are sent, the message ID field will contain either a “S” for speedbump, “T” for sharp turn, “R” for rain, “F” for fog, “E” for both rain and fog and an “A” for more than 4 hazards on the road segment. The last field contains the GPS location of the hazard only for speedbumps and sharp turns. The length of the packet is 11 bytes.

figure e

This transmission list is broadcasted twice every 1.8 s to ensure that a vehicle passing the waypoint obtains the necessary information. Once the transmission is complete, the waypoint will search through the database entries again in order to construct a new transmission list. Both vehicle and waypoint system are implemented using threading in Python. Making use of queues, a function is created for detection of each hazard, the communication, and notification and location data. When a hazard is detected, it is placed in a queue that transmits the data to other road users. When a message is received, it is placed in a queue and processed by the vehicle and/or waypoint system respectively.

3.2.4 Notifications (Fu 2.4)

FU 2.4 has almost same application as in the vehicle subsystem which serves as the interface to view notification elements of the waypoint

3.3 Hardwarre Implementations

3.3.1 Power supplies

The vehicle system is powered from the vehicle’s lighter, which is connected to the vehicles car battery. This means that the system will only go on when the vehicles engine is running. The car battery used to power the vehicle system is rated at 12 V. The waypoint power supply consists of a lead acid battery, similar to that of the car battery. Figure 13 shows a block diagram of the power supplied required by the vehicle and the waypoint which include:

Fig. 13
figure 13

Powering the vehicle and waypoint systems

  • A 5V supply for the ODROID C1 + Linux Processor and all peripherals connected to it such as the LCD display, GPS module and accelerometer. An LM2596S DC-to-DC Buck Converter has been used as the ODROID uses a minimum of 500 mA and can run up to 2A usage due to other peripheral components connected to it. The waypoint does not make use of a GPS module.

  • A 3.3V supply to power the nRF24 communication module and PIC24 microcontroller. A LD1117 3.3V regulator has been used for this purpose.

Figure 14 depicts the electronic circuitry implementation for the power supplies.

Fig. 14
figure 14

Circuity used for powering each system

3.3.2 Rain sensor

The rain meter circuit contains no active or passive circuitry components on the sensor board however, a dual interlocking comb design as mentioned before. This help to create a conduction path between the terminals as water falls onto the sensor. The rain meter has a two-pin connector, one connected to the 5 V supply and the other is the output connected to a resistor network on the main waypoint circuit board. The rain meter circuit can be seen in Fig. 15 with the component calculations below.

Fig. 15
figure 15

Rain meter circuit

3.3.3 Optical Sensor

The optical sensor comprises of a laser diode and a photo resistor to receive the scattered light from the laser. The photo resistor is positioned in line with the laser, 15 cm away from the laser, for a transmission fog response. A voltage divider is used to drop the voltage from 5 to 1.8 V to be read by the ADC of the ODROID. The calculations of the voltage divider used by the photo resistor can be seen below as well as the laser circuit in Fig. 16 and the photo resistor circuit in Fig. 17.

Fig. 16
figure 16

Overview of the system

Fig. 17
figure 17

Overview of the system

3.3.4 Integrated System

In Fig. 18, the distance sensors as well as other sensors are shown.

Fig. 18
figure 18

Distance sensors and GPS module on vehicle

GPS module is shown. These sensors are attached to a metal rod and screwed on to the vehicle’s tow bar for testing purposes. A cable is fed through the boot of the vehicle to the vehicle system in the front of the vehicle. The LCD screen and the accelerometer are mounted in the front of the vehicle.

In Fig. 19, the vehicle system without the sensors can be seen in the left of the figure and the waypoint system with its respective sensors can be seen in the right of the figure.

Fig. 19
figure 19

Vehicle and waypoint systems

The overall vehicle system has two ultrasonic distance sensors, connected to the GPIO board of the ODROID using digital pins for the trigger and echo functions of the ultrasonic sensor respectively, a UART connection for the GPS module and for communicating to the PIC24 and I2C interfaces for the accelerometer and LCD display. The waypoint system has two ADC channels for the rain and fog sensor respectively, a UART connection to communicate to the PIC24 and an I2C connection for the LCD screen. The PIC24 used in both systems is implemented for the nRF communication module which is connected to the PIC24 via the SPI interface.

4 Results

Tests were performed on the communication and detection of each hazard to determine the speed and accuracy of the system. For the communication, a small scale line of sight test was performed to determine the maximum number of bytes that could be sent in a packet in the fastest possible time with the least amount of errors. Based on Table 3, it takes an average time of 3.428 s to send 20 bytes of data between two nRF communication modules.

Table 3 Time to send data between two nodes

The packet is further reduced to 10 and 11 bytes respectively as described in Sect. 4. By only taking the last four digits of the latitude and longitude parameters, the number of bytes needed to be transmitted is decreased resulting in faster transmission time and less errors from occurring. Table 4 shows the results of communication between two vehicles and between a vehicle and a waypoint.

Table 4 Communication Accuracy vs Range

For testing of speedbump and sharp turn detection, the route shown in Fig. 20 was used. This route contained various types of speedbumps as well as multiple sharp turns. For speedbumps, an overall accuracy of 88% was obtained. This was achieved with the use of an accelerometer. Looking at the response obtained from the accelerometer in Fig. 21, a sharp spike occurs when the vehicle makes impact with a speedbump.

Fig. 20
figure 20

Route driven in detecting speed bumps and sharp turns

Fig. 21
figure 21

Accelerometer sensor reading obtained

This sharp spike was observed on all the speedbumps encountered on the route shown in Fig. 20. The use of the ultrasonic sensor in detection of speedbumps showed slight drawbacks in detecting different types of speedbumps, such as the one shown in Fig. 22. This is due to the fact that the speedbump is not a solid strip across the road surface and has gaps in-between which result in ultrasonic distance readings to be distorted.

Fig. 22
figure 22

Speed bump type A

Figure 23 shows an excellent representation of the application of the ultrasonic sensor when passed over the speedbump shown in Fig. 24. From the result obtained, it can be seen that the distance between the road surface and the distance sensor decreases. This is due to the change in height of passing over a speedbump.

Fig. 23
figure 23

Distance sensor reading obtained

Fig. 24
figure 24

Speed bump type B

The accuracy of detecting a speed bump was obtained by going over multiple speed bumps. This included different types of speed bumps as well as driving at different speeds. From the route driven in Fig. 20, there are 22 speedbumps present where the system can detect all of the speed bumps however, false postives reduced the accuracy of the system.

Detection of sharp turns proved to be successful using GPS coordinate data. From Fig. 25, it can be seen that 10 sharp turns are present on the route shown in Fig. 20. Factors that influenced the results obtained included the speed at which the vehicle was moving and GPS signal. The accuracy of detecting a sharp turn was obtained by driving through various turns. As the system was able to detect all the sharp turns present in Fig. 20, detection accuracy was influenced by the speed of the vehicle and GPS signal and false positives.

Fig. 25
figure 25

Sharp turns detected on route driven in Fig. 20

A visual representation of the rain sensor response is shown in Fig. 26 when water is present on the sensor. This results in a change in ADC readings obtained by the ODROID. When there is no water present on the sensor, the voltage output is 0 V. An accuracy of 100% was obtained in detecting rain conditions.

Fig. 26
figure 26

Rain meter response when rain is present

The accuracy of determining rain detection was obtained by taking multiple readings with varied amounts of water on the rain sensor.

The response of the optical sensor is shown in Fig. 27 when there is fog present. For testing purposes, dry ice vapours were used to simulate fog as their particle sizes are similar and scatter light in the same manner. When there is no fog present, the optical sensor obtains a constant high voltage due to the laser LED shining directly into the photo resistor. When there is fog present, the laser LED light particles scatter, resulting in less light being received by the photo resistor.

Fig. 27
figure 27

Optical sensor response when there is fog present

Accuracy of fog detection was obtained by taking multiple measurements of the optical reading from the photo resistor. The intensity of the dry ice vapours was varied by placement of the dry ice as well as the amount of dry ice used.

5 Discussion

Accuracy achieved for data sent between two vehicles and the waypoint for V2V and V2I communication systems is affected by factors such as interference of radio frequencies from other sources using the same shared spectrum and loss in received frequency due to motion of the communicating nodes especially when the receiver and transmitter are moving in opposite directions. Higher accuracy is achieved for V2I communication as the waypoint remains stationary. It was observed that when the speed of the vehicle increased in both V2V and V2I communication instances, the average time to send and receive a message decreased. In the experiments conducted in this study, the communication module along with its antenna are placed in cabin of the vehicle. Antennas can be placed on the exterior of the vehicle to improve accuracy of the V2V and V2I communication as it would reduce packet loss due to reflections in the interior of the vehicle cabin and due to no- line of sight (NLOS) factors. Accuracy and range of the wireless communication in the system can be improved by using a lower carrier frequency, which would however provide lower data rates but would require regulatory approval for usage.

Challenges where faced in testing the system on public roads. Testing in this study is conducted on private roads with permission. Accuracy of the speedbump and sharp turn detection system is affected by the positioning and orientation of the accelerometer and GPS modules in the vehicle. A success rate of 100% is achieved for the rain and fog detection sensory systems and thus is effective in warning motorists about weather related hazards that can potentially cause an accident.

6 Conclusion

This paper presented the use of a sensor-based system with dedicated software implementation to detect possible hazards on the roads. Communication between two nodes in a V2V platform proved to be highly effective when communicating hazards to other users. The system achieved detection accuracies of 88% for a speed bumps, 73.86% for sharp turns and 100% for both rain and fog detection which proved to be highly effective and efficient with the current design implementation. The design and implementation in this paper shows an improvement in the communication that is used to send various messages between vehicles and/or waypoints. The reduction in packet size can improve the transmission speed of communication, packet losses and congestion on the network. Packets can be reduced further by using various compression algorithms.