Location data on a map. A little POC

If it is of any interest, here is a little POC i did to show node location history on a map.

I have a Linux VM connected to a T-Beam. This collects the location updates using Python and dumps it to a text file as JSON
Telegraf picks it up and pushes to InfluxDB
Grafana with the TrackMap visulisation then displays the map and location.

It broke when the time stamp i was using was dropped in 7.11

If my Python was better (existent) then it would write directly to influx without Telegraf.

If its of any use, here is the Python & Telegraf config

import meshtastic
import json
from pubsub import pub

def onReceive(packet):  # called when a packet arrives
    #print(f"Received: {packet}")
    file = open("/tmp/json.out","a")
    #print(f"Raw:  {packet}")
    j = json.dumps(packet)
    file.write(f"{j}\n")
    #print(f"JSON:  {j}")

#file.close()

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

telegraf.conf

[[inputs.tail]]
  files = ["/tmp/json.out"]
  from_beginning = false
  watch_method = "poll"
  pipe = false
  data_format = "json"
  json_strict = false
  json_query = ""
  tag_keys = [
    "fromId",
    "decoded.user.id"
  ]
  json_string_fields = ["id", "longName", "shortName", "macaddr", "fromId", "toId"]
  json_name_key = "meshMeasurement"
  json_time_key = "rxTime"  
  json_time_format = "unix"
  json_timezone = "UTC"
6 Likes

Thanks, this is helpful!
I actually used it for reference when updating my telegraf config file`# Configuration for telegraf agent
[agent]
interval = “10s”
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = “0s”
flush_interval = “10s”
flush_jitter = “0s”
precision = “”
log_with_timezone = “UTC”
omit_hostname = false

[[inputs.mqtt_consumer]]
servers = [“mqtt://mqtt.example.com:1883”] # Update with your MQTT broker information
topics = [“msh/#”] # Update with the MQTT topic you are subscribing to
client_id = “telegraf”
username = “meshtastic” # Update with your MQTT username, if required
password = “superdupersecret” # Update with your MQTT password, if required

data_format = “json”

json_string_fields = [“payload”] # Specify the field containing the JSON payload

[[inputs.mqtt_consumer.tags]]
channel = “channel”
from = “from”
id = “id”
rssi = “rssi”
sender = “sender”
snr = “snr”
timestamp = “timestamp”
to = “to”
type = “type”

[[outputs.influxdb_v2]]
urls = [“http://yourlocalip:8086”]
token = “supersecret”
organization = “meshtastic”
bucket = “coolbucketnameininflux”`