LoRaWAN GPS Tracker Webapp
The last part of the project "LoRaWAN GPS Tracker" is about the visualization of current position on a digital map. There are already some applications available, which are perfectly designed for such a project. Partially the interfaces for this are already implemented in the LoRaWAN network (TTS, TNN etc.), which allows a very easy integration. However, this article is a selfmade development, where the current position data is sent from the LoRaWAN network to the own webserver. For this project, a small web space, which is even available for free from some providers such as bplaced, is absolutely enough.
How does the GPS tracker work?
In the first part of the project the TTGO GPS LoRa board was put into operation. The NMEA data sets with the position data are sent every second from the GPS module (serial interface) to the ESP32, processed and partially converted. In the second part of the project the LoRa module was activated and registered at TTS. Afterwards the implementation of the payload encoder at the GPS tracker and the integration of the decoder at the LoRaWAN application server took place. The position data is now visible in the LoRaWAN network in plain text. In this article the received and decoded data sets should be forwarded to a small PHP script. The PHP script contains a digital map (Open Street Map) and displays the position data there graphically. If a new data set is sent to the LoRaWAN network, it is forwarded to the PHP script and displayed in the map a few seconds later.
The AEQ-WEB test server
For all those who would like to test the GPS tracker just once, there is a corresponding application at the test server. The LoRaWAN GPS Viewer always saves the last 20 position data and displays them in a table. In addition, the last position is displayed graphically on a map. The use is free of charge and is available to everyone without restrictions until revoked. More information about the setup as well as data protection can be found at the end of this article.
Setup TTS Webook
In the application, TTS offers the option of connecting various interfaces to the application under the "Integrations" menu item. Under the menu item "Webhooks" HTTP and HTTPS requests can be integrated. The goal is that when a data set arrives, it should be automatically forwarded to a web page. During the request to the web server, the decoded payload is then passed in JSON format along with a lot of META data using HTTP post. For more information about webhook communication with JSON and PHP, see the article TTS JSON with PHP (German). To create your own webhook, select "Custom Webhook" as your template:
Then a form opens where the following parameters must be entered:
Webhook ID: An own randomly selectable ID for the webhook.
Webhook Format: select JSON
Base URL: The main URL of your web server
Uplink Message: The path to "uplink.php" file
The URL to your own web space is specified as the "Base URL". For the AEQ-WEB test server the following URL has to be use:
TTS can call different paths at the web server on certain events. For example, you could write a PHP script that logs JOIN requests or errors. If a JOIN occurs, a different file is called than during normal data transfer (uplink). For the GPS tracker only one server path is needed for the uplink. When using the AEQ-WEB test server as well as on your own server, the following uplink path is specified:
This small test program can be uploaded to your own web server and linked with TTS. Current position data is sent from TTS to this application and graphically displayed on a map in the browser. The PHP application consists of the following files:
uplink.php: This file is called by TTS as soon as a new record arrives. The already decoded payload parameters are passed via HTTP POST in JSON format by TTS during the call. Afterwards, the JSON packet will be split into individual parameters. The script creates a file on the web server in the main directory and stores coordinates, altitude, satellites and the current time (server time). Each parameter is separated with a semicolon.
index.php: The index file contains the layout of the web page. The script tries to open the "data.txt" text file created by the "uplink.php" and read in the coordinates. Then a map (Open Street Map) is generated, where the current position of the GPS receiver is displayed. In addition, the position, altitude, number of satellites and the time of data reception will be displayed as text.
How to use AEQ-WEB Testserver
Without obligation and until revoked, there is the possibility to connect the GPS tracker to the AEQ-WEB test server. As already stated in the configuration instructions, the base URL and the uplink message path of TTS must point to the test server. The test server can be reached at the following URL: http://testserver.aeq-web.com/lorawan_gps/
TTS transfers the device ID in addition to the app ID in the uplink message channel. Globally, an APP-ID can only be assigned once with TTS. The GPS tracker is located in the application with its unique device ID. Both parameters can be found in the TTS Console. Since a device ID can be assigned multiple times in different applications, the application ID is also required in addition to this ID in order to uniquely identify each GPS tracker. Similar to a login, both parameters are entered on the test server:
The server checks afterwards whether a data set is already available. In order to use the tool, at least one data record must have already been sent from TTS to the test server. If this is the case, a corresponding message with the number of current data sets will be displayed. Under "Actual Pos." the position of the GPS tracker is displayed in a map:
Under "Raw Data" there is a table which displays the last 20 received data sets. In addition to the coordinates, META-Data such as current frequency, signal strength, airtime or the ID of the gateway that sent the data to TTS is also displayed:
Note: If the data is received from a gateway in the V2 stack (TTN), the gateway ID is always "packetbrocker".
The test server only saves the last 20 data sets and deletes older ones automatically. In addition, it is possible to irrevocably delete all stored data sets under "Set Device".
Info: This page was automatically translated and may contain errors