Development of software and hardware complex of GPS-tracking Mykola V. Klymenko, Andrii M. Striuk Kryvyi Rih National University, 11 Vitalii Matusevych Str., Kryvyi Rih, 50027, Ukraine Abstract The paper considers the typical technical features of GPS-tracking systems and their development, as well as an analysis of existing solutions to the problem. Mathematical models for the operation of hard- ware and software of this complex have been created. An adaptive user interface has been developed that allows you to use this complex from a smartphone or personal computer. Methods for displaying the distance traveled by a moving object on an electronic map have been developed. Atmega162-16PU microcontroller software for GSM module and GPS receiver control has been developed. A method of data transfer from a GPS tracker to a web server has been developed. Two valid experimental samples of GPS-trackers were made and tested in uncertain conditions. The GPS-tracking software and hardware can be used to monitor the movement of moving objects that are within the coverage of GSM cellular networks. Keywords satellite navigation system, GPS receiver GN-801, microcontroller Atmega162-16pu, transport monitoring, GPS, GSM, GPRS, GPS tracker, SIM800L, Atmel Studio 7 1. Introduction Today, most companies of all forms of ownership use vehicles to carry out their business activ- ities. The number of such vehicles can number several hundred in one enterprise, for example, fleets of police units, municipal road cleaning and repair equipment, ambulances, taxis, car and construction equipment rental agencies, delivery services, passenger transport, fire de- partments, agricultural equipment and others. All these vehicles are movable property that requires operational management and supervision by the head of the enterprise for the suc- cessful implementation of economic activities. It is important for the head of the company to know the location of the vehicle at any time to control the work schedule or delivery of goods. Also necessary information is the history of movement of the vehicle for some period of time to prevent misuse of the company’s fleet, which leads to additional costs. However, not only business leaders but also anyone wants to control the location of their movable property. Common car thefts require prompt search. In such situations, every second CS&SE@SW 2020: 3rd Workshop for Young Scientists in Computer Science & Software Engineering, November 27, 2020, Kryvyi Rih, Ukraine " fxnik777@gmail.com (M.V. Klymenko); andrey.n.stryuk@gmail.com (A.M. Striuk) ~ http://mpz.knu.edu.ua/pro-kafedru/vikladachi/224-andrii-striuk (A.M. Striuk)  0000-0001-9240-1976 (A.M. Striuk) © 2020 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). CEUR Workshop Proceedings http://ceur-ws.org ISSN 1613-0073 CEUR Workshop Proceedings (CEUR-WS.org) is decisive. It is possible to help solve these problems by developing GPS-tracking software and hard- ware systems that use data obtained from satellite navigation systems, such as GPS (Global Positioning System) or GLONASS (Global Navigation Satellite System). GPS-tracking software and hardware can be used in various sectors of the economy to mon- itor a variety of mobile objects in real time, which are within the coverage of GSM-cellular networks. Such objects can be not only vehicles, but also employees of the enterprise, a group of tourists in an unfamiliar country, children, animals, mobile equipment. To achieve the goal, you must perform the following tasks: • to analyze the current application of GPS-tracking; • analyze the existing means of GPS-tracking; • develop a functional diagram of the software and hardware complex of GPS-tracking; • develop mathematical software for this complex; • develop an electrical circuit of the hardware of this complex; • develop the structure of the database; • develop a user interface for the software and hardware complex; • implement an test the hardware and software complex. 2. Urgency of tasks of monitoring of mobile objects and means of their solution 2.1. Analysis of the modern application of GPS-tracking in industry and society A typical GPS tracking system consists of three structural elements: 1. Terminals that are installed on the transport. 2. A server that stores information about the movement of the vehicle. 3. Client workplaces, with appropriate software for transport monitoring. The terminal is a specialized GPS tracker that contains a GPS receiver and cellular tools. The server can be either a regular personal computer with server software installed for sim- ple GPS tracking systems, or a large distributed system with specialized software for complex specialized GPS tracking systems. In some cases, the client software can be combined into one program together with the server part. However, it is often permissible to connect many workstations to the server. In some GPS tracking systems, thanks to the installation of special software on client computers, it is possible to quickly obtain information through the use of web feeds. Therefore, the operation of the GPS-tracking system is divided into the following stages: 116 Figure 1: “Gelios” user interface • GPS-tracker calculates the geographical coordinates of the vehicle; • GPS-tracker transmits the received coordinates and other data to the server via cellular or satellite communication channels; • the server receives GPS tracker data, analyzes and writes them to the database; • the customer receives information about moving the vehicle to a smartphone or personal computer. 2.2. Analysis of existing GPS tracking tools Today, a large number of hardware and software solutions are offered for vehicle monitoring on the GPS tracking system market. Figure 1 shows the user interface of the software-hardware complex of GPS-tracking “Ge- lios”, developed by the company “GeliosSoft” (www.geliossoft.ru). Users access the system through a web browser. Real-time transport monitoring with the Gelios system makes it possible to increase the efficiency of vehicle operation, optimize money costs, increase the level of transport safety, and improve the work discipline of the company’s staff. Gelios GPS-tracking software and hardware uses third-party GPS trackers, one of which is shown in figure 2. This tracker is designed to determine the exact location of the object and other parameters and then transfer them to the server via GSM networks. The device has two analog and four digital inputs, which allows you to connect fuel level sensors, axle pressure sensor, temperature sensors and more. 117 Figure 2: “Ruptela” GPS-tracker 2.3. Principles of satellite navigation The main parts of satellite navigation systems [1] are: • space equipment; • ground equipment; • custom equipment. Space equipment includes navigation satellites. The main functions of navigation satellites include the transmission of the necessary information as part of its radio signal to determine the location of ground objects. The ground equipment includes a control center, spaceport, measuring equipment. The control center coordinates the work of all parts of the satellite nav- igation system. The user segment includes satellite receivers of consumers. They are designed to receive signals from navigation satellites, calculate navigation parameters and process cal- culations. 2.4. Basics of GSM cellular networks Cellular communication is a type of mobile radio communication based on a cellular network [2]. The main feature of cellular communication is that the coverage area is divided into sepa- rate cells, which is due to the service areas of the base stations of the BS. Zones of cellular cells intersect in some places and together form a cellular network. The service area of the base station on a flat surface, in its form, is a circle. The cellular network composed of these circles has the form of hexagons. The network consists of cellular base stations spaced apart. They allow you to determine the location of moving objects, but with a significant error, which can reach several hundred 118 meters. Base stations provide continuity of communication as a network subscriber moves from one cell area to another. When a cell phone leaves the coverage area of a base station with a radius of approximately 35 kilometers, the phone establishes a connection with the base station using the base station. The phone measures the signal level of the thirty-two nearest base stations simultaneously. Data on the top six signal levels are transmitted by telephone through the service channel to the switching center. Then, the communication control is transferred from one station to another. The maximum distance between the phone and the nearest base station for communication is 120 kilometers, but with the use of GSM amplifiers and directional antennas. Base stations of the cellular network are located in the center of the cell on top of the iron towers, on the roofs of multi-storey residential buildings. The radio is constantly scanned by the cell phone to search for the base station signal. If a base station signal is found, the phone transmits an ID to that station. The telephone and the base station are in constant radio contact. Different cellular networks are connected to each other and to a fixed telephone network. GSM cellular networks are 2G networks, i.e. the second generation of digital cellular com- munication. Mobile phones are made to support the ability to operate in four frequency bands: 850, 900, 1800, 1900 MHz, because different parts of the world use different frequency bands for GSM networks. GSM-network allows you to use a common packet data service, i.e. GPRS. This is a standard that uses a voice line to transmit any information. The service is used by mobile devices to access the Internet. There are GPRS classes from the first to the twelfth. As the class grows, the data rate increases. The average GPRS data rate is 20 to 40 kilobits per second. 3. Design of software and hardware complex of GPS-tracking 3.1. Design of the functional scheme of the software and hardware complex of GPS-tracking The work of the software and hardware complex of GPS-tracking should consist of the follow- ing stages: • GPS-tracker receiver calculates the geographical coordinates of its position; • the microcontroller of the tracker receives geographical coordinates from the GPS re- ceiver; • GSM-modem of the tracker receives geographical coordinates from the microcontroller and transmits them to the web server via GSM-network; • the web server receives the geographical coordinates of the GPS-receiver, checks them for integrity and stores them in the database; • the user software displays the received new geographical coordinates of the tracker on the electronic map in the web browser window. 119 Figure 3: Two points on the sphere Let’s make the functional scheme of this complex. You must have two domains on the web server. The domain mygps.pp.ua must be installed SSL certificate [3] to use the HTTPS protocol [4] when exchanging data between the user and the web server. The second domain will be used to receive geographical coordinates from the tracker via HTTP protocol [4] using PHP scripts [5]. Trackers must transmit geographical coordinates in the parameters of the GET request [5]. The two domains must use a common database. It has been decided to develop two types of GPS trackers. The first type of trackers will transmit the coordinates of its position approximately every 15 seconds, working contin- uously. The data rate of such a tracker will allow you to display the movement of the car with sufficient accuracy. The second type of trackers will transmit the coordinates of their position approximately every 5 minutes. After each successful transfer of coordinates, the tracker will enter sleep mode, which is designed to save battery power, which will significantly increase the battery life of the device. Each tracker will have a unique number for the tracker to access the web server. To access the Internet, the Internet tracker will use sim-cards of the cellular operator "lifecell". 3.2. Development of mathematical model for GPS-tracking complex Consider a mathematical model for calculating the distance between two points on the surface of the globe by geographical coordinates. The shape of the Earth can be described as a sphere. In Euclidean geometry, the smallest distance between two points is a straight line. However, straight lines are not possible in the sphere. These lines on the sphere are part of large circles [6], the centers of which coincide with the center of the sphere (figure 3). Figure 4 shows a sphere as a model of the globe. On the surface of the sphere are points 𝑄, 𝑃, the distance between which must be calculated. Therefore, the distance 𝐿 between points 𝑄 and 𝑃 is calculated by the formula: 𝐿 = Δ𝜎 𝑅, 120 Figure 4: Model of the globe with two points on the surface where Δ𝜎 is the angular distance between the points 𝑄 and 𝑃, rad; 𝑅 - radius of the Earth, m. The angular distance Δ𝜎 between the points 𝑄 and 𝑃 is calculated by the modified formula of haversine [6, 7]: √ (cos 𝜙2 sin(𝜆2 − 𝜆1 ))2 + (cos 𝜙1 sin 𝜙2 − sin 𝜙1 cos 𝜙2 cos(𝜆2 − 𝜆1 ))2 Δ𝜎 = arctan , sin 𝜙1 sin 𝜙2 + cos 𝜙1 cos 𝜙2 cos(𝜆2 − 𝜆1 ) where 𝜙1 , 𝜙2 - latitudes of two points, rad; 𝜆1 , 𝜆2 - longitudes of two points. Consider a mathematical model for calculating the data rate for the USART microcontroller Atmega162-16PU. USART (Universal Synchronous and Asynchronous serial Receiver and Trans- mitter) is a universal synchronous-asynchronous serial transceiver. This is a peripheral device that is part of the microcontroller Atmega162-16PU [8] from the company "Microchip". USART data rate is the number of bits transmitted or received per second. The data transfer rate via USART is calculated by the formula: 𝑓𝑜𝑠𝑐 𝐵𝐴𝑈 𝐷 = , 16(𝑈 𝐵𝑅0 + 1) where 𝑓𝑜𝑠𝑐 is the clock frequency of the microcontroller, Hz; 𝑈 𝐵𝑅𝑅0 - the contents of the register pair UBRR0 in decimal form. Consider a mathematical model for calculating the overflow time of 16-bit timers-counters of the microcontroller Atmega162-16PU. Numbers from 0 to 216 - 1 can be written in 16-bit case. Overflow time of 16-bit timers-counters is calculated by the formula: 𝑡 = 𝑇 (216 − 1), where 𝑇 is the increment time of the 16-bit register. The increment time of the 16-bit register is calculated by the formula: 121 Figure 5: Electronic circuit of the GPS tracker 𝑑 𝑇 = , 𝑓𝑜𝑠𝑐 where 𝑑 is the clock divider of the microcontroller; 𝑓𝑜𝑠𝑐 - clock speed of the microcontroller, Hz. 3.3. Development of electrical circuit diagram of hardware The development of the electrical circuit of the GPS-tracker, which is shown in figure 5, was carried out using a specialized software package "Proteus 8 Professional". Consider the design features of this scheme. The power supply of the tracker is a lithium-ion battery with a voltage of 3.7 volts and a built-in short circuit protection circuit. The tracker is turned on and off by switch K1. The MT3608 module [9] is designed to increase the voltage from 3.7 to 5 volts. This module is shown in figure 6. The AMS1117-3.3 circuit is designed to reduce the voltage from 5 to 3.3 volts. Polar elec- trolytic capacitors, denoted as C3, C4, have a capacity of 100 𝜇𝐹 and 10 𝜇𝐹 , respectively. The Atmega162-16PU microcontroller [8], shown in figure 7, is powered by the MT3608 module. 122 Figure 6: Appearance of the MT3608 module Figure 7: Atmega162-16PU microcontroller This microcontroller is programmed through the contact group J1 by USBASP programmer [10], which is shown in figure 8. Quartz resonators X1, X2 have frequencies of 4 MHz and 32768 Hz, respectively. Resonator X1 is designed to clock the microcontroller. Resonator X2 in the microcontroller helps to im- plement time measurements. According to the [8], the capacitances of the capacitors C1, C2 can be from 12 to 22 pF. The GPS receiver GN-801 [11, 12] is shown on two sides in figure 9. This receiver has a UART interface with RX, TX contacts. The RX contact is for receiving data and the TX is for transmitting. The PPS contact with its high signal level warns the microcontroller about data transmission. The presence or absence of voltage at the EN contact turns the GPS receiver on or off. To activate the EN contact, it is necessary to remove the resistor from the surface of the GPS receiver as shown in the [11]. Resistors R3, R4 are a voltage divider and have a resistance of 10 k ohm each. 123 Figure 8: USBASP programmer Figure 9: GN-801 GPS receiver The GSM module SIM800L [13], which is shown in figure 10, is designed to transmit data to a web server via the Internet. The module uses micro-SIM phone cards. This GSM module has a UART interface [8] with RX, TX contacts. The RST contact is for rebooting the device. The DTR contact is designed to exit the GSM module from sleep mode. The ANT contact is for connecting a GSM antenna. Bipolar transistors BC547, denoted in the diagram as Q1 and Q2, are designed to reboot the GSM-module and wake it from sleep, respectively. When you open the transistor Q1, the voltage level at the contact RST changes from high to low. When you open the transistor Q2, 124 Figure 10: GSM module SIM800L the voltage level at the contact DTR changes from high to low. Resistors R5, R6 are designed to limit the current through the bases of transistors Q1, Q2. Each of these resistors has a resistance of 2.2 k ohm. 4. Results 4.1. Implementation of hardware The Atmel Studio 7 development environment was chosen for the development of the Atmega162- 16PU microcontroller software [14]. It is an integrated platform for developing and debug- ging AVR and SAM (Smart ARM-based Microcontroller) programs. Atmel Studio 7 provides an easy-to-use environment for writing, compiling, and debugging programs written in C/C++ or assembly code. This environment supports interaction with debuggers, programmers, devel- opment kits that support AVR or SAM devices. Consider data transfer to a web server. The process of data transfer to the web server is based on the cyclic execution of a constant sequence of AT-commands [15] by the GSM-module, the list of which is shown in figure 11. The command in line 62, i.e. "AT", checks the readiness of the module to execute commands. The command in line 63 checks the registration of the module in the cellular network. Com- mands in lines 64, 65, 66 connect to GPRS. The command in line 67 initializes the HTTP session. The command in line 68 sets the ID for the HTTP session. The command in line 69 sets the GET request. The "id" parameter is assigned the value of the tracker number by which the tracker is identified on the web server. If a tracker has a number that is not in the database on the web server, the data of such a tracker is not stored in the database. The gps-data pa- rameter is assigned the value of the data packet from the GPS receiver. The command in line 70 sets the header "User-agent" of the HTTP request. The command in line 71 executes a GET request. The command in line 72 terminates the HTTP session. The command on line 73 termi- 125 Figure 11: GSM module SIM800L nates the GPRS connection. The command in line 74 enters the GSM module into sleep mode. The command in line 75 wakes the GSM module from sleep mode. It is not enough to simply send the last command to the GSM module, as in this mode the UART interface of this module is blocked. To unlock the UART of this module, you need to change the voltage level from high to low at the DTR contact. Next, execute the command in line 75. After executing each command, the GSM module returns an alphanumeric response code that must be received and analyzed. Commands and response codes are exchanged through the USART0 interface of the microcontroller. As a result of hardware development for the GPS-tracking complex, two working prototypes of GPS-trackers are made, which are shown in figure 12. These GPS trackers are the same in structure, however, each of them may have different software. 4.2. Testing of software and hardware complex of GPS-tracking As a result of testing the software and hardware complex of GPS-tracking, the movement of the vehicle in the city of Kryvyi Rih on Kuprina and Petro Kalnyshevsky streets was traced, which is shown in figure 13. In this figure, the path of movement is shown by black circles, which are connected by a gray line. If you click on such a circle, a pop-up window with additional information appears. Among this information is the length of the track from the beginning to this point. 5. Conclusions Today, satellite monitoring of moving objects is still relevant. The latest advances in science and technology are involved in this activity. In this work the design and implementation of software and hardware complex of GPS-tracking with the use of modern web technologies and electronic components is carried out. On the basis of the analysis of modern application and existing means of GPS-tracking, the decomposition of these systems is carried out. GPS- trackers, web server, client software are the main structural elements of software-hardware complexes of GPS-tracking. Based on the analysis, a functional diagram and mathematical 126 Figure 12: Prototypes of GPS trackers software of GPS-tracking software and hardware have been developed. Based on the analysis of the functions of GPS-trackers, the necessary electronic components, such as microcontroller, GPS-receiver, GSM-module, were selected. It was found that they all have a serial UART data interface. Based on research data, an electrical circuit of a GPS tracker has been developed. A web-based user interface of the software and hardware complex has been developed, which allows access to this system via a computer or smartphone using popular web browsers. Based on the design results of this GPS-tracking software and hardware, software for the Atmega162- 16PU microcontroller, as well as user software with a web interface have been developed. Testing the operation of this software and hardware complex of GPS-tracking was carried 127 Figure 13: The path of movement of the vehicle out in the form of tracking the path of movement of the vehicle in real time. Testing has shown that the accuracy of the tracker’s measurements of the coordinates of a moving object depends on the environment. The fewer high-rise buildings around the tracker, the more accurate the coordinates. GPS-tracking software and hardware can be used to monitor the movement of moving objects that are within the coverage of GSM cellular networks. Such objects can be not only vehicles, but also employees of the enterprise, a group of tourists in an unfamiliar country, children, animals, mobile equipment. References [1] N. Bonnor, A brief history of global navigation satellite systems, Journal of Navigation 65 (2012) 1–14. doi:10.1017/S0373463311000506. [2] P. Morgan, Approaches to optimising radio performance of gsm/gprs/edge/w-cdma cel- lular handsets, Microwave Engineering Europe (2004) 23–26. [3] P. Robinson, Understanding digital certificates and secure sockets layer (SSL), CRC Press, 2004. doi:10.1201/9780203498156. [4] D. Naylor, A. Finamorey, I. Leontiadisz, Y. Grunenbergerz, M. Mellia, M. Munafòy, K. Pa- pagiannakiz, P. Steenkiste, The cost of the "s" in https, Association for Computing Ma- 128 chinery, Inc, 2014, pp. 133–139. doi:10.1145/2674005.2674991, conference of 10th ACM International Conference on Emerging Networking Experiments and Technologies, CoNEXT 2014 ; Conference Date: 2 December 2014 Through 5 December 2014; Confer- ence Code:125893. [5] W. Jason Gilmore, Beginning PHP and MySQL 5: From novice to professional, Apress Media LLC, 2006. doi:10.1007/978-1-4302-0117-5. [6] M. Dubinin, Calculation of distance and initial azimuth between two points on the sphere, 2006. URL: https://gis-lab.info/qa/great-circles.html. [7] C. Veness, Calculate distance, bearing and more between Latitude/Longitude points, 2020. URL: http://www.movable-type.co.uk/scripts/latlong.html. [8] Atmel, 8-bit AVR Microcontroller with 16K Bytes In-System Programmable Flash. ATmega162, ATmega162V, 2013. URL: https://ww1.microchip.com/downloads/en/ DeviceDoc/Atmel-2513-8-bit-AVR-Microntroller-ATmega162_Datasheet.pdf. [9] Aerosemi Technology Co.,Ltd, MT3608: High Efficiency 1.2 MHz 2A Step Up Converter, 2012. URL: https://www.mikrocontroller.net/attachment/212877/MT3608.pdf. [10] USBASP Programmer for AVR microcontrollers, 2013. URL: https://arduino.ua/docs/ USBASP_Datasheet.pdf. [11] TOPGNSS, STOTON GNSS Module. GN-801 UART GNSS Module Ubx- 8030-kt chipset, 2018. URL: http://www.stotoncn.com/upload/file/201801/1516180733487356.pdf. [12] u-blox, u-blox 8 / u-blox M8: Receiver description. Including protocol specification, 2021. URL: https://www.u-blox.com/sites/default/files/products/documents/u-blox8-M8_ ReceiverDescrProtSpec_%28UBX-13003221%29.pdf. [13] Downloads Simcom.ee, 2019. URL: https://simcom.ee/documents/?dir=SIM800L. [14] Microchip Technology, Microchip Studio for AVR® and SAM Devices, 2021. URL: https://www.microchip.com/en-us/development-tools-tools-and-software/ microchip-studio-for-avr-and-sam-devices. [15] SIMCom, SIM800 Series_AT Command Manual_V1.09, 2015. URL: https://www.elecrow. com/wiki/images/2/20/SIM800_Series_AT_Command_Manual_V1.09.pdf. 129