You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

Introduction

Many RouterOS devices have GPS support. It allows RouterOS to determine the precise location of its GPS receiver. GPS coordinates will indicate latitude and longitude values of the current position.

Let's say, you have LTAP (or any other device with GPS support) and you wish to track its location. You want the router to send this data to a server, where the data will be stored and integrated into a map, as it is more convenient to monitor. In this guide, we will showcase how you can do that. This scenario will utilize MQTT protocol communication with a platform called ThingsBoard.

Please check our MQTT and ThingsBoard guide as it will have more useful information. ThingsBoard has a cloud solution and local installation options (on different OS).

Since we've added a container feature to RouterOS, it became possible to also run the platform/instance within another RouterOS device. Meaning, you can build this scenario, solely on RouterOS units.

Please check the guide on how to run thingsboard-postgres instance using the container feature by following the link. If you want to choose this route, make sure to pick the devices that you plan on using carefully and as this implementation can be heavy on RAM usage (it is suggested to have a device that has at least 2 GB min. RAM and is either ARM64 or AMD64 architecture).


Configuration


###Configuration###
#Enter pre-configured broker's name within "":
:local broker "pc"
#Enter the topic name within "", per the broker's configuration:
:local topic "v1/devices/me/telemetry"

###Variables####
:global lat
:global lon

###GPS####
:put ("[*] Capturing GPS coordinates...")
/system gps monitor once do={
:set $lat $("latitude");
:set $lon $("longitude");}

:local message \
"{\"latitude\":$lat,\
\"longitude\":$lon}"

###MQTT###
:if ($lat != "none") do={\
:put ("[*] Sending message to MQTT broker...");
/iot mqtt publish broker=$broker topic=$topic message=$message} else={:put ("[*] Lattitude=none, not posting anything!");:log info "Latitude=none, not posting anything!"}

  • No labels