Quick Distance Testing Using Python API and PiZero

To do some quick distance testing I’ve connected a raspberry pi zero (running DietPi) to a heltec Lora device and am using the Meshtastic Python API to send timed messages to a “home” node / entire mesh.

import meshtastic
import time
from datetime import datetime

interface = meshtastic.SerialInterface()

while True:
    now = datetime.now()
    current_time = now.strftime("%H:%M:%S")
    interface.sendText("Time: " + current_time)
    print("Message Sent")
    interface.sendPosition()
    print("GPS Position Sent")
    print("Sleep for 60 seconds")
    time.sleep(60)

interface.close()

Running the code via the raspberry Pi’s terminal using “python3 sendmessage.py”

There might be a better way to do this with send and receive confirmations from the base station.

5 Likes