1 Introduction

Railway is one of the famous worldwide transportation system and approximately 3900 Billion people uses train around the world. At the same time, it experiences multiple accidents on a larger scale which results in a loss of many precious lives. The various causes for such accidents in a world is well described in Fig. 1 [1]. It is well obvious from the Fig. 1 that the main reason of the 50% railway accidents is the trespassing [2, 3] so motivated by such problems in the existing railway setups we are proposing a smart sensor based intelligent railway transportation system for smart cities. Specifically, only in Pakistan there exists an about more than 2000 unmanned level crossings around the country. So, it is much needed to take certain steps to control the accidents of railway by implanting the smart standards to minimise the risk of human loss. It is worth mentioning here, that in the first three years of the present government in Pakistan there is no such work in the top priorities related to railway accident prevention system [4, 5]. According to a latest survey nearly 595 accidents tool place in the country which cost many lives [6, 7].

Fig. 1
figure 1

Global accident ratio

Motivated by the problems described in the literature, we are proposing such a system in which we can make our cities safe and provide our country with economic growth. One of the major problems around the world is increasing ratio of accidents [8]. A great challenge to overcome this situation, so a solution is proposed which consists of two phases.First phase is accident prevention with the help of LTE module, ultrasonic sensors and traffic indicators. In second phase accident detection is carried out when train is crashed there is a sudden change in it’s speed which is continuously monitored through GPS module on train and sent to control room [9].

Due to increasing development in automation there is a risk factor present,so there should be a system to make the fast moving tracks safe.This paper proposes a system comprised of multi-sensors. Two levels are used; a high level and a low level. In high level tracks safety is determined while in low level there is emission and detection process with the help of us (ultrasonic) sensor [10, 11]. Due to over speeding road accidents are increasing over the time, which cost life of many people so a system is proposed in this research. Which comprises of a LTE module to keep track of train location, speed and time. Which is very helpful in tracing the accident location and sending required information to alert control centre to reach at accident site [12, 13]. To make railway transportation system safe and reliable, we need to design a system that responds to certain events in a very short period of time using IOT. Through different sensors installed at different positions and locations, all data is gathered and is send to cloud for further actions [14, 15]. On the basis of the data received, we can timely make decisions. Through this method their is possibility that human interference not only can be minimized but can be removed from the level crossings and all system can be visualized through a single setup [16, 17]. Proposed mode of communication is very important in aspects of safety and it can be easily be implemented [18, 19]. Proposed model acquire the data using sensors for detection of train and provide the desired information to the control room for the further processing [20].

Furthermore, the proposed research is presented as follows. Section 2 provides the Literature review. Proposed model is presented in Sect. 3. We present simulation results in Sect. 4 and conclusion is provided in the end of the paper in Sect. 5 of the paper.

2 Literature Review

The modern world is advancing very rapidly in terms of technology and communication [21]. In today’s era, we are very much near in the introduction of the autonomous vehicle systems, industrial revolution and concepts like virtual reality, e-health, and machine learning [17]. To catch up with these up to date versions of automation we need to have a fast and wireless communication system [19]. Different modulation techniques are implemented at the transmitter end with the technological enhancement such as 256 QAM [22]. 5G provides the connectivity to everyone, everything and everywhere. There is another advancing concept called 3GPP (third generation partnership project) which can be considered as the key feature of 5G [11]. The world is very much near in implementing the 7G communication system but in our country, we are looking towards 5G which has a very high data rate and more users can be accommodated in the available bandwidth [13]. In 5G we have a new term called MM (massive MIMO) means we have a large number of transmitters and receivers and this means that the mode of communication is very much advanced and is growing very rapidly. The concept of small cells or femtocells is really the 5G because in this way more users can be benefitted [23]. 5G operates in different bands depending upon the availability [7]. With the technological advancement, we are having advanced versions of batteries and processors [3]. Along with the hardware advancement, we have link enhancement which includes smart antennas having nanotechnology, modulation, adaptivity, bandwidth and digital signal processing [15]. Then we have network enhancement which includes efficient resource allocation and after that, there is an enhancement in the application which includes soft and adaptive quality of service [24].

A technique called image recognition technology is used in Taiwan for enhancing emergency management. Image recognition and location-based services are used to improve the safety system. Railway is a very efficient mode of transportation but still, a lot of accidents occur around the country [25]. To overcome this problem vision based object detection algorithm is used, in this method different cameras are installed at different positions on the railway platform. After that the data from these cameras is checked through data fusion technique. Three-way cameras are used to determine any object placed on the track and also checking the arrival, departure, stop or in motion status of the train [26].

An algorithm called augmented reality (AR) is used now a day’s across different parts of the world. We can define AR as, “Enlarged the truth is an intelligent encounter of a true situation where the items that dwell in reality are improved by PC produced perceptual data, now and then over numerous tactile modalities, including visual, sound-related, haptic, somatosensory and olfactory”. This system uses GPS and a camera for the complete monitoring of the train [27]. After obtaining the desired results the whole communication is made through a client–server architecture. Client architecture includes the AR module, network control, data access module, and google maps. In server architecture, we have web service, image retrieval engine, and data access layer [28].

For the passenger’s safety, we studied a system namely vision-based object detection for passengers safety. This system proposes the work on three dimension position information algorithm, which trains from different angles using a stereo vision system and also the obstacle in the path of the track can also be detected. This process is so efficient that it can differentiate between the human beings and non-living things, this is the thing that makes it efficient and unique from other processes [29]. For condition monitoring of train as well as the track we can use different topologies, some of which are discussed here. One of them is a wireless sensor network which includes relay nodes, sensor nodes and GSM for communication regarding the condition of the train. We can define relay nodes as, “A relay node” is short type of network which provides a communication between two devices [5]. In such a system the source and goal can’t impart to one another straightforwardly because the separation between the source and goal is more prominent than the transmission scope of the two. Wireless communication and ad hoc networking are used to relate sensors to one another to completely transmit the information. In this way, we can easily find the status regarding the train onboard condition and railway track [30].

It’s a very important factor in terms of safety-related to railway that we know the train position either the train is coming from east, west, north or south. And also there’s no need of external supply or fuel to run the train. A load coil is installed on the train and a source coil is installed on the track. Through this way train will work on electricity and there’s no need of fuel for it. And also FPID blocks are installed to detect the position of train [31]. In particular, Pakistan railways is not at its best. Many factors are responsible for making Pakistan railways one of the unsafe transportation system for the country men. The work that is in top priority of government is to expand length of the tracks and to increase number of engines. The whole communication of the country is made by one main data center which is setup at headquarter office, Lahore. This office plays a vital role in timely decision making. It includes CISCO core switches, firewall and edge switches [32]. Different substations are linked up with the main station through wide area network (WAN) sharing databases and applications [33]. Thus we can also tell that what needs to be done to sustain over railway transportation. Furthermore, various researches [34,35,36,37,38,39,40,41,42,43] have proposed various solutions for such systems (Table 1).

Table 1 Experimental analysis between existing methods

3 Proposed System Model

In this section, a method is proposed which comprises of a control room and location tracker system and presented in Fig. 2. The communication between the control room and the tracker is by means of LTE [14, 18]. Control room in the proposed model consists of a micro-controller, ultrasonic sensors for the detection of train [20], LTE module for bidirectional communication [45], LCD for display of data related to train information like speed, direction and distance, traffic lights at level crossing, a buzzer that will sound when train is detected and an automatic motorized gates are also installed [16]. The complete system of control room is installed on the level crossing to make it human free system. On the other hand, tracking module is mounted on train to keep track of it’s data like train speed and location. Whereas, tracker module consists of a micro-controller, a GPS module and a LTE module for communication with control room [46] to share the run time information of the train.

Fig. 2
figure 2

Proposed block diagram

Figure 3 presents a smart city concept in which every thing is inter-related and communicates with each other all the time and proposed model well fit in the domain of smart transportation system. The design of the proposed model contains a number of innovative new features. Regarding the state of the environment in Pakistan. There are over two thousand instances of trespassing without gates, which leads to a hundred or more accidents every year. Few of the novelties of the proposed system are IoT-based service for round the globe availability of information, cloud for file storage and sharing, remote assistance and monitoring of railway activities, minimum Human dependency and utilization of WSN for the achievement of the United Nations’ (UN) sustainability goal of smart cities. In the era of smart technologies, every component of the society needs to be hasty and well connected to meet the requirements of the smart cities, so the proposed model of the system for smart cities is presented as under:

Fig. 3
figure 3

Proposed system model

The proposed model, works in such a way that when a train is detected at arrival end sensor-1 and sensor-2 need to be true at the same time only to set the condition true. Microcontroller sends a signal to different relays that further operate the different elements including traffic light indicators in which red LED will be turned on. In the same way, relay allows the buzzer to sound and further relay operates the motorized gate in such a way that it will be closed for the incoming traffic at the level crossing. At the same time, the other micro-controller works in a different fashion it continuously takes data from the GPS module which includes train speed, location and direction and then transmit it without any delay through LTE module. After that, the data received will be transmitted through a LCD and displayed. So that the traffic at the level crossing have an idea about the trains speed and in how much time it will reach the level crossing.

Similarly, when the train reaches the departure end sensor-3 and sensor-4 get active at that time only then the condition is met. Micro-controller sends a signal to different installed relays that further operate the different elements. Including traffic light indicators in which green LED will be turned on and the red LED will be turned off, in the same way, the relay causes the buzzer to turn off and further the relay operates the motorized gate in such a way that it will be opened for the incoming traffic at a level crossing. On the same time, the other micro-controller works differently it continuously takes data from the GPS module which includes train speed, location and direction and through LTE module and send it to the another LTE module. After that, the data received will be transmitted through a LCD and displayed so that the traffic at the level crossing has an idea about the train’s speed. Figure 4 describes the complete system implemented on the level crossing including ultrasonic sensors. Along with different output devices mainly LED, LCD, buzzer and a motor. Similarly, Fig. 5 shows the circuit installed on the train. This system continuously takes the coordinates and speed of train and send it to the control room.

Fig. 4
figure 4

Circuit installed at level crossing

Fig. 5
figure 5

Circuit installed on train

As this studies, proposes a system based on wireless sensor network, so we have considered the constraints that are imposed by wireless sensor networks in real time implementation. We have referred to a solution while keeping in mind the limitations of WSN. We have designed a unique protective box specifically for the weather, and it is capable of performing admirably in adverse environmental conditions such as (heats, cold, rain and in fire). Moreover, in the event that a node should fail, we have redundant nodes in place. They work in a redundant fashion, so if the primary node fails to function properly, the secondary node will immediately become operational and begin exchanging information with the control end. Furthermore, it has been proposed in a system that in the not-too-distant future, 5G technology will be used for reliability and to avoid communication failure in the event of a communication link failure. It is also suggested that satellite communication be used for the real-time implementation in order to avoid any communication link failures and thereby avoid any accident situations. It’s an expensive solution, but it has the potential to work well for the vast railway network that spans the country with no chance of disconnected areas.

3.1 Flow Chart

In Fig. 6, flow chart of the proposed study is projected. It consists of two parts, labeled as (a) and (b). Part (a) represents a complete flow of the system at level crossing, it is shown that initially ultrasonic sensors to go high, after this check certain tasks at output would be performed including on/off of the LED’s, buzzer and open closing of gate. Similarly we look for the sensors S-3 and S-4. In parallel it is also communicating with LTE module installed at control room. Part (b) represents a GPS module that establishes it’s connection with the satellite. After that the coordinates of train are send to LTE installed at level crossing.

Fig. 6
figure 6

a Represents flow of control room and b Represents flow of tracker circuit

3.2 Proposed Algorithm

The proposed algorithm applied in this studies is presented step by step for the better understanding of the readers.

figure f

4 Simulation Results

4.1 Mathematical Modeling

An ultrasonic sensor is used in our proposed prototype that operates in such a way that it gives the high-level time at its output pin so, we need to modify and convert this time into the distance in such away that it can easily be used as per our requirements. Following mathematical steps are involved to convert high-level time into distance.

$$\begin{aligned} d=\frac{(t*v)}{2} \end{aligned}$$
(1)

where time is duration in which echo pin receives a high pulse and then waits for it to again go to low. Speed of sound = v = 340 m/s; distance fomula; s = v*t

$$\begin{aligned} t=\frac{t}{2} \end{aligned}$$
(2)

Due to pulses ongoing and then coming back to sensor

V = 340 m/s and 1 m = 100 cm

V  = 340*100 cm/us = 0.0340 cm/us

$$\begin{aligned} distance\; ({\text {cm}})= \frac{duration*0.0340}{2} \end{aligned}$$
(3)

Similarly; 1 cm = 0.393 inches

$$\begin{aligned} V=\frac{0.0340}{0.393} \end{aligned}$$
(4)

V = 0.01330 inches/us

$$\begin{aligned} distance\; ({\text {inches}})= \frac{duration*0.01330}{2} \end{aligned}$$
(5)

So, we will use following formula for the calculation of distance;

$$\begin{aligned} distance=\frac{duartion*inches}{2} \end{aligned}$$
(6)

4.2 Proposed Simulation Setup

The complete process is simulated via Proteus and the coding for micro-controller is done in Arduino IDE. In first phase, implementation of the control room is processed which includes an Arduino mega, ultrasonic sensors for train detection, then for the safety and awareness an automatic motor sliding gate along with is installed. Also, a traffic lights signal and a LCD display is mounted to show the received information of train like its speed, location and direction. Moreover, a sounding facility which includes an alarm to aware the citizens crossing the train track. Received information regarding its current status is also communicated with the control room through real time communication for centralize control. The second phase, includes installation of Arduino UNO with GPS module and LTE module on train. GPS module provides the exact co-ordinates of train along with speed and direction, whereas this information is shared with the control room for intimation.

In Fig. 7, a circuit placement for the detection of train at arrival end is presented, which comprises of multiple sensors, micro-controller, LCD and the multiple components. Similarly, in Fig. 8 complete process after the detection of train at departure end is well presented. It is made up of the same building blocks as described in Fig. 7. The position of the departure and the arrival end circuitry can be better understandable if we refer Fig. 3. When train reaches within the sensing range of the ultrasonic sensor, it sends a message to the micro-controller which activates the signal and the received information will be displayed on a LCD installed at the level crossing. It is important to mention here that the same step of processes will be executed for both arrival and departure end. Furthermore, RTT (round trip time) of the sensors using serial monitor is shown in Fig. 9.

Fig. 7
figure 7

Detection of train at arrival end

Fig. 8
figure 8

Detection of train at departure end

Fig. 9
figure 9

RTT of sensors

Similarly, a prototype circuit is designed and mounted on the train, it includes a GPS module, LTE module and a micro-controller. Designed circuit is used to continuously acquire the position and speed of the train at its track. Circuit implemented on a train is shown in Fig. 10 for tracking the real time location and the current speed of the train.

Figure 11 reflects the received information of geographical coordinates of the train location and its speed in the serial monitor, which is further forwarded to the control room end for activating the gates closure and for information display.

Fig. 10
figure 10

Circuit installed on a train for location tracking

Fig. 11
figure 11

Monitoring of the train speed and its geographical coordinates

4.3 Installment of a Hardware Setup

Figure 12 present the detail deployment of various components in the system setup for executing the proposed study. Figure 12a and b showing the placement of 2 ultrasonic sensors to minimise the error rate on each tower specially designed for departure and arrival ends, which is already discussed in detail in the section of proposed model. Figure 12c shows a complete setup placed at the level crossing, where the gate is connected with a motor which moves forward and backward depending upon the type of action required based on the information received. Traffic light indicators and a LCD is also mounted to display the action taken on the received data.

Fig. 12
figure 12

Sensor placement at both ends

Figure 12d–f shows the train information at the arrival end and its synchronized process. As soon as a train is detected at the arrival end a signal is sent to control room which takes action and activates the traffic light and showing data on the LCD and then finally closing the gate at level crossing. Similarly Fig. 12g–i shows the demonstration of train arrival at the departure end. As, train is detected at the departure end a signal is immediately sent to control room automatically which results in lid the indication of the traffic lights and display data on the LCD for opening of the gates at level crossing.

The complete circuit implemented on the train and synchronization with the control room is shown in Fig. 13. Figure 13a presents a complete circuitry used for tracking train position and speed. This circuit is installed on the train and works in such a way that it continuously takes coordinates and speed and whenever the driver or any other staff member presses the ‘S’ button on serial monitor the coordinates along with speed are sent to control room. Figure 13b shows output of the GPS module installed on the train. This module provides coordinates and speed of train with date and time. In the figure, two outputs are shown on COM11 and other on COM9. The output shown on COM11 is the output of GPS module along with LTE module. Where, COM9 shows the output of LTE module installed in control room. This module will receive any message send by the tracker circuit and will display it on serial monitor. Similarly, Fig. 13c shows that when we press button ‘S’ in the serial monitor of COM11 only then the data that is acquired continuously by GPS will send to the control room. And the message received is displayed on the COM9 of serial monitor. The output includes longitude, latitude, altitude, date, time and speed (kmh).

Fig. 13
figure 13

System interfaced with control room

Figure 14 shows the complete circuitry installed on train. Its a tracker circuit that keeps control room informed about train speed and location. The GPS module takes about few seconds to establish it’s connection with the 24 satellites present in the earth orbit but requires only 4 of them to lock the location. Similarly, Fig. 15 presents the data received on a mobile node at control station which was sent by the train.

Fig. 14
figure 14

Tracking system installed on a train

Fig. 15
figure 15

Trains data received at remote end

In Table 2, sensitivity of the round trip time of the ultrasonic sensors is provided. It is well seen in the the acquired data that the when the train is approaching towards the sensor, the RTT of the sensor is low and vice versa.

Table 2 Measurement of RTT actual and measured for ultrasonic sensors

Figure 16 shows the graph of distance (inches) versus high level time (milliseconds). This high level time is the one in which echo pin remains high and again goes to low. It can be seen from the graph that as distance between the ultrasonic sensor and obstacle increases the high level time also increases with it. In this graph high level time is dependent upon the distance.

Fig. 16
figure 16

Graph of ultrasonic sensor

5 Conclusion

The proposed study is directly associated with the safety and quality of railway’s. The set objectives of the studies are successfully achieved in the prototype model and the train can be tracked through its coordinates and position using the GPS received information. Furthermore, ultrasonic sensors provide the timely detection of the rail on the track and automizing of the railway crossing gates are achieved based on the information received at control room end. In the future this research can be extended by introducing innovations on different sections like communication system improvement and implementing latest advance powerful micro-controllers in the real time railways track to achieve the full safety for the people.