Off-Grid Field Test: Meshtastic-Python, Heltec & custom board, hop connections

Hallo! Just going to just post some quick pics from this weekend’s field test of the Mesthastic system below.

(Note: you can find more pics, code, and other details in a writeup post here; I hope to add better explanations there soon!)


Above: Newfound Lake in New Hampshire, USA. This is the view from the shore by the cabin; the hill to the left is what I intended to create the LoRa ‘shadow’ behind which I wouldn’t be able to receive messages without a relay node ‘hop’.


Above: the location of the ‘base station’ (inside the cabin) on the lake, using GPS on my phone (none of the Meshtastic devices I was using had a GPS module).


Above: the relay node, using my own simple custom Meshtastic board (based on an ESP32 + RFM95, no GPS).


Above: the base station node, controlled via laptop by Meshtastic-python. It replies to messages sent to it with the SNR of the incoming message.


Above: example of an exchange between the field node and the automated ‘base station’.


Above: The field node with me in a kayak, controlled via my Android phone.

Background

The goal was to test ‘hop’ dynamics with a system of 3 Meshtastic nodes, by first setting up a ‘base station sender’ and a ‘target receiver’ on opposite sides of a hill that blocks direct LoRa transmission; and then placing a ‘relay’ node on the ‘corner’ of that hill, so that messages might ‘hop’ around it.

The ‘sender’ was located in a cabin on a lake, and was controlled by Meshtastic-python, using a script (linked to in the above post) that would ‘reply’ to received messages with the SNR of the incoming message. The idea was that from the field I could send messages from my ‘end node’ (controlled via the Android app), and if the ‘relay’ node was able to relay my message via a ‘hop’ to the ‘base station sender’, I might ultimately get a reply relayed back to me at the end node.

I was able to nicely communicate among all the nodes directly; but in my quick test wasn’t able to accomplish a ‘hop’. Not yet sure why, but my test was a bit goofy and rushed, so I might have been doing something dumb. The ‘hop_limit’ parameter seems to have been set to ‘1’ – which should allow a single hop beyond the immediately adjacent nodes, from what I understand?

Anyway, more writeup / tests soon … just wanted to post some fun motivational lakeside pics for folks ::slight_smile:

Cheers!
Don

7 Likes

(filling in details in spare moments today :slight_smile: ) …

In case it’s useful, below is the Meshtastic-Python script I used on my ‘base station’ (a laptop with a Heltec Meshtastic widget plugged into a USB port) to listen for messages and reply to them, adding the SNR. I also added ‘hopLimit’, because at the time I thought it was a measure of the number of hops (not, as I now realize should have been obvious, a limit on the number of hops).

import meshtastic
import time
from pubsub import pub

def onReceive(packet): # called when a packet arrives
    print(f"Received: {packet}")
    if packet['decoded']['data'] is not None:
        msg = packet['decoded']['data']['text']
        rxSnr = packet['rxSnr']
        hopLimit = packet['hopLimit']
        print(f"message: {msg}")
        reply="got msg \'{}\' with rxSnr: {} and hopLimit: {}".format(msg,rxSnr,hopLimit)
        print("Sending reply: ",reply)
        interface.sendText(reply)

def onConnection(): # called when we (re)connect to the radio
    # defaults to broadcast, specify a destination ID if you wish
    interface.sendText("hello mesh")

pub.subscribe(onReceive, "meshtastic.receive")
pub.subscribe(onConnection, "meshtastic.connection.established")
interface = meshtastic.StreamInterface()

When I then went out into the kayak and sent off messages using an Android phone + another Heltec Meshtastic widget, the above script contributed to a ‘dialogue’ like this:

How fun is that?! Was very easy to do using out-of-the-box Meshtastic-Python functionality, with the demo scripts provided kindly provided the repo.

Question (no rush, just posting it in case someone happens to know :slight_smile: ): is “number of hops this message took to reach me” is something one can access via the Meshtastic-python API?

7 Likes

I was looking at the python library just last night to do this same thing.

Thanks!

3 Likes

Re: how many hops did it need to reach me.
The hoplimit will be decremented for each node it passes through. So from that you can know how many hops it needed.

1 Like

I just did my very first Pull Request in GitHub!

I updated main.py to integrate donblair’s code to auto reply to incoming messages with some stats.

I’ll create a ticket in your python api GitHub for the request.

Please be gentle, it’s my first time.

2 Likes