Titan – AN24: Sending GPS Locations to a Web Platform

¿Buscas alguna otra cosa?

Scene Details

Some Titan router models have an internal GPS. That means that, apart from doing everything a 3G router does (Internet connectivity), it can manage a small fleet.

Titan routers allow to manage a GPS location in several ways. For example, it is possible to configure a Titan router to send NMEA location data through one if its three serial ports, so a third equipment can use them. It is also possible to configure a TCP server socket so a third equipment (in this case via Ethernet, Wifi or even 3G/4G) can connect to it and get NMEA location data. In this application note we are going to develop an example in which the Titan router will be configured to automatically send its GPS location periodically to a web server via HTTP.

To do that, let’s say there is an MTX-Router-Titan-mini-4G-GPS installed inside a truck for two purposes. First, it should provide 2G/3G/4G connectivity to several Ethernet devices that are connected to the router. Second, it should send its GPS location to a web server every 60 seconds. In case of lack of 2G/3G/4G coverage during some stretches, it should collect the positions internally in order to send them as soon as there is coverage.

Titan Router Configuration

The configuration of the Titan router is pretty simple. First, we need to configure the section “WAN > Basic Settings,” entering the APN, username and password according to the SIM card being used. This configuration will allow the Titan router to connect to the Internet.

Next, we need to configure the section “External Devices > Logger Configuration.” This screen allows to configure the Titan router internal datalogger needed for two tasks: storing the collected data (in this case GPS locations) in the internal Flash memory, and configuring the method and sending destination of the gathered data (meaning, where and who to send GPS locations).

For this concrete example, we choose to send the data via HTTP GET to a test web server called www.metering.es.

That is, we specify “HTTP GET (JSON)” in the Mode field, we specify the value “ID12345678 (which will identify the router in case there are several of them sending data to a server)” in the ID field, and we specify the URL to send the data to in the Server field. In this example www.metering.es/json/set.asp?data=.

That is, when a Titan router sends location data to said URL, in the “data” variable in our server, we will have a JSON object with the received data.

Finally, we configure the GPS. To do that, we need to use the section “External devices > GPS receiver.” We will configure this screen as show next.

We activate the GPS (selecting the “Enabled” field). We specify the value “Internal GPS” in the “Serial Port” field if MTX-Router-Titan has an internal GPS, as it is the case now. We specify the interval of seconds in the field “Interval” to read every GPS location (60 seconds recommended) and activate the box of the “Logger” field so the router collects the GPS locations read in the internal datalogger and sends them to the web server we configured in the previous Logger screen.

Once this is done, we just need to go to the section “Other > Reboot” and restart the router. Once the Titan router starts again, it should work according to the new configuration.

Testing the Titan Router

Once we reset the Titan router, it will connect to the 2G/3G/4G network and, as soon as it gets the GPS locations, it will send them to the configured web server.

And now, an example of the JSON sent by the Titan router to the web server with the GPS locations gathered (every 60 seconds).

{"TYPE":"GPS","IMEI":"358709050113764","P":"ID12345678","GDATE":"2017/01/31","GTIME":"16:48:08","GLAT":"41.50623","GNS":"N","GLON":"2.0388207","GEW":"E","GSPE":"0","GCOU":"","GALT":"181.1","GSTA":"2","GANT":""}

Where:
TYPE: It indicates the kind of data being sent. In this case “GPS”
IMEI: It indicates the internal modem IMEI (unique and different in each router)
P: It is the configured ID field in the section “External Devices > Logger”
GDATE: It indicates the date obtained by the GPS
GTIME: It indicates the time obtained by the GPS
GLAT: It indicates latitude
GNS: N: North, S: South
GLON: It indicates longitude
GEW: E: East, W: West
GSPE: It indicates speed
GCOU: It indicates the direction (0-359) in case it is available
GLAT: It indicates the altitude in meters
GSTA: It indicates the status (0: no location, 2= 3D, 3=3D)
GANT: It sends the antenna status in case it is available

More Configurations

It is possible to make many more aditional configurations to the Titan router, like commands via SMSOpenVPN, modbus sensor readings, etc. In this application note we have only explained the basic configurations