5 min read

Tracking boats with Meshtastic

Tracking boats with Meshtastic
Univaja.org patrol

I got in touch with Luandro Viera. We've been hacking around for while, with LibreMesh and LibreRouter, SecureScuttlebutt, Meshtastic, local services and more.

This time, he shared with me a challenge that was given to him from an indigenous community in the Brazilian Amazon Forests, tracking the location of their boats as they patrol the rivers:

Utilizing Meshtastic for tracking patrol boats in the Amazon
@kilroy those are really good tips on hardware, thanks! I remember when Echos came out, they were publicized as having over a week of battery life, that’s why I thought they would be a good choice. But seems like the Raks are the way to go. @barryhunter the MQTT in this case would be for keeping track of the sent GPS positions in a cloud database, that makes sense right? I love the bridging idea, but again, don’t think that would be necessary for this specific use-case, as mesh would probably b…

He asked me if I could build a prototype around this idea, so I gave it a go!

Luckily I already had all the required elements, two Meshtastic devices: Heltec Lora32 v3, so I started right away!

A draft plan

The behaviour of this system would be as follows:

  1. Each of the Meshtastic nodes (the devices with the M logo) communicate their realtime location over LoRa to each other, and retransmit messages for those too far to connect directly.
  2. The node to the right would be connected to internet and send the messages that arrive to it over to an MQTT Broker.
  3. There would be a client connected to the MQTT Broker that would receive the MQTT messages and store them on a MySQL Database.
  4. A Web Server would use the data on the MySQL database to show a map.

Let's start with the MQTT Broker. Initially I've used Yunohost to set up a quick and dirty instance to try out the idea. I already had a yunohost instance on the cloud, so it was as easy as running yunohost app install mosquittoto have an MQTT Broker running. I will take note of the IP address, and the username and password configured during the install, as it will be the one I'll use to test out the install.

I've used a local MQTT Client, MQTTExplorer, to make sure the setup was working, and to troubleshoot in case anything odd would happen throughout the setup.

Easily installed through snap install mqtt-explorer.

Messages might not be easy to read, as they are encoded in Protocol Buffers, an efficient format for representing data in binary form... but at least you can see that messages are arriving.

I imagined that I could enable JSON MQTT publishing (a capability available in Meshtastic), but it seems that the meshtastic-map doesn't support it, so I've sent the request... I hope they are interested in this feature!

Parse messages in JSON format · Issue #65 · liamcottle/meshtastic-map
The MQTT plugin within Meshtastic allows to send messages as JSON. It would be great for meshtastic-map to be able to process them also! Thanks for a fantastic piece of software!

At the same time, I am flashing the last stable version of the firmware to all my heltec.

For the Web Server we will for this excellent project by liamcottle called meshtastic-map, that consumes the MQTT info and sets up a nice web interface to browse current and historic information in a map... amazing! It only required for me to download the source code, install/update Docker Engine to a new-ish version (v25+), customize the docker-compose.yml for my own MQTT Broker and that was it... a map of my network!

Now that the server side is ready, let's do the Meshtastic side.

For the nodes on the boat, I've used the Heltec Lora32 v3 that I had at hand, and Luandro replicated the setup using the Liligo T-Beam and T-Echo that he had at hand, yielding the same results.

We will eventually automate the node config with YAML file configurations, but for now I will describe how they need to be set up:

One of the nodes was set up as a Gateway. To do so, we had to:
- connect the node over WiFi, so it can reach the MQTT Broker
- enabled the MQTT module pointing to the MQTT Server.
- enable uplink on the main channel. Doing so will cause for each message that this node receives to be forwarded over MQTT to the Broker.

As the boat nodes have built-in GPS, GPS location needs to be enabled for it to be used.

Excellent! Now, we wanted to add the MQTT Server to the docker-compose.yml so we could set up everything easily on their infrastructure.

To do so, we forked the repository to add this functionality in our own branch:

GitHub - nicopace/meshtastic-map at local-mqtt-server
A map of all Meshtastic nodes heard via MQTT. Contribute to nicopace/meshtastic-map development by creating an account on GitHub.

The last thing we've done (Luandro did actually), was to add a password protection to the web frontend so only them could access it. This was implemented using an nginx-proxy.

This project could be extended by:

  • Documenting how to reproduce it
  • User documentation
  • Using canned-messages for key messages

Here are some additional resources about the work of Luandro in the Amazon rainforests:

Meshtastic to connect remote villages: Deep in the Amazon
Meshtastic implementation 📡 Re-posted from Secure Scuttlebutt. Check First post on community-servers, or the full thread . Balaio elders drawing a map of their territory As with most implementations, we start off by holding a community-wide assembly, where we first introduce the idea o autonomy in communication and information infrastructures, and why that’s relevant for them. I asked the elders to draw a map of their territory, and did a beautiful job at it. Balaio map wit…