Localization and Monitoringo of Public Transport Services Based on Zigbee

Regular and systematic public transport is of great importance to all residents in any country, in the city and on commuter routes. In our environment, users of public transport can track the movement of vehicles with great difficulty, given that the current system does not meet the necessary criteria, and does not comply with the functioning of transport system. The aim of the final paper is to show the development of such a system using ZigBee and Arduino platforms. This paper shows an example of use the technologies mentioned above, their main advantages and disadvantages, with the emphasis on communication between the device and its smooth progress. In order to show the way in which the system could function, a simple mesh network was created, consisting of coordinator, routers for data distribution and end devices representing the vehicles. To view the results a web application was developed using open-source tool which is for display of the collected data on the movement of nodes in the network. Keywords—Wireless mesh network; Zigbee; Xbee; microcontroller; web development; integration


INTRODUCTION
Public transport plays a vital infrastructure link between individual cities and states, and even the major geographical regions.There are a large number of users of public transport and, therefore, we can say that its proper and smooth functioning is the imperative.However, the number of users varies and depends directly on the quality of services that the system provides.These services are conditioned by everyday occurrences such as traffic jams, accidents on the road, and some unexpected weather conditions.The causes are often unpredictable, and the delays caused by these phenomena prevent precise definition of the time of arrival of buses at specific locations, thereby creating difficulties for users, but also for the operators.The purpose of this paper is to show development of a system through which localization and monitoring of the vehicles of public transportation would be done using wireless mesh networks.Due to these factors, the establishment of a stable system of scheduling becomes extremely difficult task, both in urban and intercity lines.Since most bus station still does not have an intelligent system for localization and monitoring of vehicle users are given a fixed timetable [1].On the other hand, administrators themselves must manually enter data related to the departure and arrival of vehicles, which is time consuming and subject to error during entering.This primarily refers to the main bus station, where such information is recorded for each vehicle that arrives at the station during the day.The work of the entire system can be improved by developing intelligent system of the vehicle with automatic collection of information that would be of great benefit for consumers, but also for transport operators and administrators [2].Based on these various analyzes could be made with the aim of improving the quality of services.The current location of the vehicle, its delay, the number of vacancies or the temperature in the vehicle is information that is very important for users who still, based on it, may decide to use transport services.On the other hand, service providers can perform detailed analysis and to monitor the movement of vehicles from day to day, and that based to the results plan the development of the system, changes in the timetable, and increase or decrease of the number of vehicles for specific lines depending on the number of passengers.
The following section presents the characteristics and features of the wireless technologiese in mesh networks with advances and disadvantages and methodology of use proposed project.The third section provides explanation of use communications protocols, commands and registers for proposed system for localization and monitoring publlic transport based on Zigbee.Communication algorithm on the transmitting and receiving device is shown in the fourth part.The results of the analyses and diskussion of developed application for monitoring and localization objects are shown in the fifth part.At the end of the paper there is a conclusion.

II. FEATURES OF WIRELESS TECHNOLOGIES IN THE MESH NETWORKS AND METHODOLOGY
For the implementation of intelligent systems that could perform localization and monitoring of public transport services a variety of technologies and standards can be used.In the past, the attempts of identification and tracking of vehicles using CCTV (Closed-Circuit Television) technology have been reported, which was based on the recognition of images.The performance of such systems was extremely poor (the approximate value of the accuracy was 20%).Today, different wireless standards and technologies are used, as separate or in combination with any other wireless or wired technology.Some of them are GPS (Global Positioning System), GSM (Global System for Mobile Communication) and GPRS (General Packet Radio Service), RFID (Radio Frequency Identifier), WSN (Wireless Sensor Networks) and Zigbee [3].GPS is often used in combination with GSM or GPRS technology.The GPS system is based on the exchange of www.ijacsa.thesai.orginformation between the GPS receiver and satellite.To determine the position of an object it has to be visible to at least three satellites, which also can be an issue, for example when you have an underground station.Systems used for civil purposes are not completely accurate and often make greater or smaller discrepancies when determining the coordinates, depending on the quality of equipment.The problems also occur because of the existence of the multipath, when the signal is reflected from various obstacles before it reaches the receiver.For example, the city in this work has already implemented the network to track the movement of buses using GPS systems for satellite tracking.Each vehicle has a built-in sophisticated GPS / GPRS device that sends data on the movement of vehicles on the server.But, The GPS usage may get delay in locating the moving bus and system may mislead them to different bus stop.RFID technology is often implemented as a part of a wireless mesh network, in order to avoid wire connection of RFID reader to the host application.In this case, Bluetooth or Zigbee wireless standard is the most commonly used.However, it can also be implemented in combination with GPS and GPRS standards.RFID works on several different frequencies on which depends the range or distance at which the reader can communicate with shortcut.If you use low and medium frequency (125 kHz, 13.56 MHz) range is very small, 5cm-30cm with a maximum power of radiation.On the other hand, at high frequencies it is possible to communicate at a distance up to 10 m, but in this case it results in the drastic changes in the price and size of the equipment (reader).One of the technologies that can be used for wireless communication of RFID nodes is Bluetooth, a standard that is used for implementation of personal local networks of low range.The biggest drawback of this standard is high energy consumption; therefore it is not suitable when working with devices that can be powered using the battery.Also, the range is small and reaches a value of 10 m.The aim of this paper is to show that for the design of intelligent monitoring system, in addition to the above mentioned, we use Zigbee standard.It enables lower bit rate that is sufficient for the mentioned functionality, while it is making significant savings in terms of energy consumption in contrast to the for instance Bluetooth.Also, it is proposed to use the Arduino platform that opens the door for the implementation of various functions for communication between stations and vehicles or coordinator and vehicles, which further expands the range of functions of the system [4].
Based on set goals, as part of this work a simple wireless mesh network was implemented which relies on the Zigbee standard [5], [7].The possibility of establishing a mesh network is of great importance, because the actual implementation of the entire system with 129 stations and 60 buses would require covering a wide area (city of Tuzla), and the use of redundant links is desirable so that in case of failure on one of the nodes it does not result in congestion or even system failure.The network described in this paper consists of a small number of nodes: coordinator, router, and two end devices [6].The router is the bus station, and the end devices are buses.Communication between end devices and the coordinator is achieved through a router, although generally direct communication is possible between them.However, due to the specific development of communication protocol this form of communication does not give any results, so in determining the location of nodes it is desirable to avoid direct contact between the bus and the coordinator.Additional nodes are possible to include in the network, such as distribution routers for data transfer, while providing expansion of network range [8].All collected information is sent to a central computer where processing and storing is done.In this regard, a special web application is developed using a simple graphical interface, which provides the user an insight into the movement of vehicles.Node coordinator and bus consist of Arduino UNO platform and Xbee S2 module that communicate with one another using the UART protocol [9].For the functionality of the station only an Xbee S2 module is needed.Coordinator communicates using two UART interfaces.One is hardware and is used for direct communication with the application on a computer.The second one is software, implemented using SoftwareSerial.hlibrary and is used for communication between the Arduino and Xbee devices.The end device is made of the same components as the coordinator, but for communication it only uses software UART interface and exchanges information with the router.During the implementation and development of communication protocol, the hardware was mainly used for monitoring the device and printing errors.For powering coordinator constant and stable source is needed, so it is powered through the computer which is used for the processing of the data collected.Other nodes in the network can be powered using an external power source, such as batteries.The station is fixed, while buses are mobile and can move freely within the network.All Arduino devices are programmed using the Arduino IDE environment, where www.ijacsa.thesai.org the libraries for implementation a software serial port are used and a special library for communication of Arduino and Xbee devices.Setting of registries of Xbee modules, which work in API mode, is performed using X-CTU software.

III. COMMUNICATION PROTOCOL, COMMANDS AND REGISTRIES
Communication protocol, which was developed for this system, is based on the use of AT commands that give us insight into the value of appropriate registries of the Xbee devices.During the work the following controls were used: Serial Low (SL), Node Discovery Timeout (NT), Node Identifier (NI) and Node Discovery (ND).Within Xbee devices there are a large number of registries with fixed or variable values, but we will take a look at those that are essential to our system.
Each node in the network is uniquely defined by a 64-bit MAC address which is stored in the registries SH (Serial High) and SL (Serial Low) of the Xbee device [10].What is characteristic for Xbee devices is that the value of SH registry is the same for all and is 0x0013A200, so it is actually SL value that uniquely identifies each device.These values are assigned during production and cannot be changed.Registries DH (Destination High) and DL (Destination Low) are used for storage of the 64-bit address of the destination node.Since all devices send data to the coordinator, these registries have the same value for all devices, and they are DH = 0x0, DL = 0x0.These values can be changed, so that by sending the appropriate AT commands we can change the final destination of the package.To send a broadcast message it is necessary to set the following value DH = 0x0, DL = 0xFFFF.ID (Extended PAN ID) is a registry that stores the value of PAN ID.All devices that have the same PAN ID can communicate with each other.If the value of this registry is 0, the coordinator will during the establishment of the network and initialization of variables choose an arbitrary, available value for the given registry.If routers and end devices have the pre-set value to 0 they can connect to any available PAN network.BH (Broadcast Hops) is a registry having a functionality of great importance to the implementation of our system.Namely, this registry enables us to limit the number of hops for transmission of broadcast messages.Given that the end devices often send ND command, which is the broadcast message, it is possible that the congestion in the network appears due to overloading.However, setting this registry value to 1 we restrict ND command to be forwarded only to the nearest node, thereby reducing network load.Since the devices do not need to send broadcast messages to all devices, set limits are not ruining the overall performance of the system.Registry value NJ (Node Join Time) determines the time within which the coordinator or router allows connection of new nodes.This value is set to the maximum value of 0xFF, which is the default value and allows the connection of new nodes at any time.This registry is important in situations where the end nodes move in the network and change their parents.PL (Power Level) and PM (Power Mode) are registries by which we determine the level of emitted power of devices.PL registry can have a value of: 0,1,2,3 and 4 which correspond to the value -8dBm, -4dBm, -2dBm, 0 dBm and + 2dBm, respectively.Using this registry we limit the power of broadcasting of the end devices.Namely, let us look the scenario in which the vehicle is moving down the road, and the power level of radiation is set to default value.With a power of radiation of 2dBm the range of device can reach a value of 100m.This would mean that our bus could communicate with the stations that are not part of its route, and are, for example, on the part of the road where vehicles move in the opposite direction.In this case, information about the movement would not have a logical sense, and could create confusion in the system itself.Therefore, the value of this registry, in case of the end devices, is set to the lowest possible, so as to reduce the range in which the bus emits the ND command.PM is a registry that allows the boost mode.If enabled, boost mode increases the transmitting power for 2dB and improves sensitivity of reception for 1dB.
For all the devices values of the registry NI are predefined.This registry is used for the storage of the string that could be used to identify the device.For the value of the string we can use characters from the ASCII table, provided that the string cannot start with an empty space and it is not allowed to use the comma.For the purposes of communication protocol, devices on the network are assigned names based on their functionality.Value of the NI registry starts with one of four possible letters: C for coordinator, R for distribution router, S for the station and B for the bus.For all devices it is characteristic that an initial letter is followed by three digits that uniquely identify the device (e.g.B305, B241, S902, R301, and C141).NT (Node Discovery timeout) is registry closely related to the ND command.Specifically, this value is the timeout value for ND command or the period of time within which the device will wait for a response.The value of NT registry is included in the ND command which is sent to other devices.In addition to these, it is important to mention the MY registry which stores the network address of the device, and CH (Operating Channel) in which contains the value of the number of the channel in which the device operates.There are registries for setting up encryption and encryption key (EE, EC, NK, KY) which are used in case we want to secure the information that is sent within the network.However, for this paper, which has the presentation character, the mentioned registries are not used.

IV. COMMUNICATION ALGORITHM ON THE TRANSMITTING
AND RECEIVING DEVICE Communication between the devices takes place in the following manner.Once connected to a power source, the end device (bus) first performs initialization of variables where, among other things, a string of 20 bytes is initialized and used to send information to the coordinator.The first four bytes have a value of 5, and are used for checking on the receiving side, while others are dynamically filled.Bus first sends SL and NI command and writes responses in the specified string to positions 4-11.These functions are called within the setup() function, so they are executed only once during the initialization of the system.Bus then sends the NT command, and stores the resulting value for the timeout for further use.After that, the device enters the loop function in which, at appropriate intervals, it sends ND command.The bus is a mobile node, and moves within the network traveling from station to station.In his range in this case we can find another buses, stations and routers.We will assume that the coordinator is at the location where it is not directly accessible to mobile buses.
Each router or stations that are found on the route of the bus are potential parents of a given node.When some of these devices are in range of the bus, the bus will get a response to the transmitted ND command.The response contains a range of information such as network and MAC address, value of the NI registry, network address of parents, as well as some others.The total length of the response depends on the value of NI registry.However, since these values are pre-defined our response contains 23 bytes and characters of the NI string and SL are in positions 6-14.The idea is that the value of said device is written to the remainder of the string to be sent to the coordinator.However, sending of a string is possible only when the byte in which the value of the first letter written is equal to 83.It is the hexadecimal value for the letter 'S'.The simple comparison is done using if() loop.If this byte contains another value (82 for R, 67 for C) the package will not be sent, and the device returns to the initial position from which it again sends the ND command.From this we see that the behavior of node is defined even if there is direct communication with the coordinator.There are many reasons why the stations are chosen to carry the router functionality [11], [12], and buses carry the functionality of the end devices.On the ND command of the end device other end device never answers, so when we would have two buses close to each other they would not mutually communicate.On the other hand, the station must be able to communicate with each bus that passes.
End devices can be in sleep mode, enabling energy savings and extension of battery life for instance.The station, on the other hand, cannot be in sleep mode because it performs the functionality as a router.The final destination of all devices is the coordinator.Its role is that after receiving the package forwards the received information to the base.At the beginning of each package the coordinator adds two characters '?' which are used to determine the beginning of the string that contains the necessary information.The hexadecimal value for the mentioned character is '3F'.
Forwarding is done using the script that is written in the Python programming language.Due to the potentially large number of devices that can send data to the coordinator and that a collision is possible, the script will write the appropriate data into the database only when the hexadecimal value of the first two bytes within a string are equal to '3F'.
Otherwise, the program flow leaves the loop in which the registration is done, and we come back to the state of listening to the serial port and waiting for reception of information from the coordinator.The database is implemented using MySQL (My Structured Query Language), an open-source management system for relational databases.Within the base there is a series of tables containing data related to buses, stations and lines, which are used within a web application that is designed for end users of the system.
To establish a connection to the base, and allow the storage to full extent it is necessary to enter the parameters for the connection.After that it is necessary to enter the number of the serial port on which it is expected to receive data from the coordinator.Web application is developed using PHP, a scripting programming language that is one of the most commonly used for programming dynamic web pages.Information from the database is retrieved by sending appropriate requests.For certain functionalities of the web page Java scripts are used.The frame of the web page is written using HTML (HyperText Markup Language), and for the design of elements CSS (Cascading Style Sheets) is used.Below we will describe in detail the functionality of this application.www.ijacsa.thesai.orgV. RESULTS AND TESTING DEVELOPED APPLICATION FOR MONITORING AND LOCALIZATION All information about the vehicle's current location in the network is stored in a database.Data from the database is directly accessible to the administrator, but not to end users.Therefore a web application is developed to be an interface through which the user can obtain the desired information.When a user opens the home page he or she can see a number of basic elements.The first is certainly a scheme that shows all the city's bus lines.On the scheme all stations are indicated, and bus lines are painted different colors for clarity.
The user has the option to use Google Maps.The original coordinates and zoom are defined in a way that it shows the entire city.The user can, if necessary, move the map, or zoom in to make it easier to display the desired location.Under this scheme and map there are two elements.The right one is to display a list of city lines, with their initial and final destination.The left element allows the user to select the desired station or line.If the user selects the option 'Line', in the next field a list with the options opens.Let us assume that the user has selected the line '5a.To the right is a table of the results where the user can read where the vehicles on selected line were registered, the time and date of registration, which is the next station, and a rough estimate of the arrival of the vehicle at the next station.
On the left side the user can see which line is selected and current time, and pressing one of the buttons offered user can use their functionalities.'Location of the vehicle' in the scheme small icons will display to indicate the station where the buses of the line '5a' were last registered.Icons blink, so that the user can relatively easy see them.
'Main lines' in the menu gives the user access to a list of the main bus lines at any time.If the user on the home page decides to search based on the name of the station, then the table with results will show last location, time and date of registration on last location for all the buses which move towards the given station and which are within the range of three stations from the given station.The next figure shows the results in case where user has chosen the station 'Tenis.'What is important to mention is that it is possible that a result table is empty, depending on whether the previous stations previously registered vehicles.Regardless of whether the search is conducted based on the number of the line or the station name, the user always has available option to see the results on Google Maps.In this case, the map shows markers that mark the approximate location of the station.www.ijacsa.thesai.org

VI. CONCLUSION
The paper describes the architecture of such a network on the example of the part of the city, its advantages and disadvantages that affect the performance of the system.It was found that part of the needs of such a system can be met by using Zigbee wireless standard that is extremely suitable for large networks where the transfer of packages of small length is done.Consequently, the Xbee RF modules were used to implement Zigbee protocol, together with the Arduino microcontroller platform.Zigbee has proven to be a good solution to the problem because it is relatively easy to implement, and communication can be achieved in areas where there is no 3G, 4G or other wireless technologies of long This system will be an efficient and low cost one due to the use of Zigbee.Thus this paper gives a complete passenger friendly system.In the case of development of network for the entire city, it would be necessary to conduct additional studies that would determine which locations are suitable for setting up nodes and what is the total number of required nodes.Such a system would easily be able to integrate with mesh networks, and in addition to the location data of vehicles it could also collect other information such as: number of passengers, external and internal temperature, the level of CO 2 , the level of brightness, as well as any other information that can be collected using a variety of analog and digital sensors.

Fig. 2 .
Fig. 2. X-CTU, setting of the parameters of the Xbee device

Fig. 5 .Fig. 6 .Fig. 7 .
Fig. 5. Scheme of stations and city's bus lines and locations of the vehicles on the map

BIBLIOGRAPHY [ 1 ]
Alireza Faed, "An Intelligent Customer Complaint Management System with Application to the Transport and Logistics Industry", Springer International Publishing, 2013.
Table I shows comparison of different wireless technologies for use in public transport.