Vehicle GPS Tracking with MikroTik's LtAP

Vehicle GPS Tracking with MikroTik's LtAP

MikroTik's LtAP is a great solution for vehicle connectivity over LTE and offers dual SIM capabilities for network redundancy. It has an integrated 2.4Ghz 802.11n radio perfect for a small mobile hotspot as well as GPS for vehicle tracking. We have always loved the idea of being able to provide basic internet services to our own company vehicles as well as being able to track them with one device and this is how we did it.


Hardware Preparation




We needed to install an external GPS antenna on the LtAP which requires drilling a small hole and fitting a UFL-SMA Female connector. It is very important to make sure the UFL connector is secure and the external antenna is connected before powering up the LtAP. Not doing so could damage the GPS radio.


Router Configuration

Once everything was re-assembled, we upgraded to the latest version of RouterOS before configuring the GPS. This requires the use of the serial interface which isn’t used for GPS by default, so you will need to disable the serial's default use via the console menu first.

/system console
set [ find ] disabled=yes




Next up was the GPS configuration where we make use of "serial0" as our default port. It's important to correctly set the Coordinate Format to "dd" as this is vital for communication and mapping to our tracking server later on. If configured correctly and you are not getting coordinates, make sure your GPS antenna is positioned either outside or near a window to connect to those satellites.

/system gps
set coordinate-format=dd enabled=yes gps-antenna-select=external port=serial0 \
set-system-time=no




You could use the default configuration as a plug and play solution for internet connectivity or customise it your way. The GPS data collected by the router can now be posted across the web to our own private server which can be done either by HTTP, HTTPS or VPN. We have created a guide and shared our web server code on GitHUB to assist you - here

Once your server is working you can start posting GPS co-ordinates by using a script in conjunction with the scheduler to your server address. We used HTTPS and decided to set ours to 1-minute intervals.

/system scheduler
add interval=1m name=gps on-event="{\r\
\n:global lat\r\
\n:global lon\r\
\n/system gps monitor once do={\r\
\n:set \$lat \$(\"latitude\")\r\
\n:set \$lon \$(\"longitude\")\r\
\n}\r\
\ntool fetch mode=http url=\"https://YOUR_WEB_SERVER/YOUR_PHP.php\" port=443 http\
-method=post http-data=(\"{\\\"lat\\\":\\\"\" . \$lat . \"\\\",\\\"lon\\\":\
\\\"\" . \$lon . \"\\\"}\") http-header-field=\"Content-Type: application/js\
on\"\r\
\n:put (\"{\\\"lat\\\":\\\"\" . \$lat . \"\\\",\\\"lon\\\":\\\"\" . \$lon . \
\"\\\"}\")\r\
\n}" policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-date=may/20/2019 start-time=07:45:41





Vehicle Installation



Once tested and working, it was time for the installation which requires power either via USB inside the vehicle or tapping into the 12v ignition supply. We selected the best placement for power where it was easy enough to run the antenna to a visible location. We found the ignition supply using a multimeter and soldered a power cable directly to the 12v line. If you are using this method, make sure you test for 12v with the ignition on and off, if you choose the incorrect supply you will drain the vehicle battery.

We connected the LtAP via its 12v input by using the included power cable and placed the hardware behind the trimming where it won't be tampered with. The antenna cable was run behind with the GPS antenna placed on top of the dashboard to ensure the best possible connectivity while on the road.




End Result

With everything set in place, our drivers are able to get basic internet services like VoIP and maps when out on the road. By using MikroTik, it is very easy for us to restrict services to this device to ensure the connectivity isn't being abused. We can track our vehicles in real-time or historically and have customised our server to display our own images as well as physical addresses. The system is working well for us and is an excellent all-in-one solution at a marginal cost.






Blog post by Timothy Symonds & Steven Krog
Reference: https://wiki.mikrotik.com/wiki/Manual:GPS-tracking



Related Products