Telemetry data to JSON?

I have one T-Beam on MQTT-role and other Heltech 2.1 + BMP280 as telemetry data provider and both are running 1.3.48 version. Telemetry data is shown on Heltec display and on Meshtastic android client as should. Documentation says that data will be provided to mesh. Does this mean that data is also presented on JSON format? When device is reset, it will provide one telemetry message once.

{“channel”: 0, “from”: -2069944272, “id”: 536602483, “payload”: {“air_util_tx”: 0, “battery_level”: 0, “channel_utilization”: 0, “voltage”: 0}, “sender”: “!8487d440”, “timestamp”: 0, “to”: -1, “type”: “telemetry”}

That one looks like deviceMetrics; the BMP280 data is sent as environmentMetrics. Have you enabled environmentMeasurementEnabled ?

Should be. Config is “telemetry”: { “deviceUpdateInterval”: 30, “environmentUpdateInterval”: 15, “environmentMeasurementEnabled”: true, “environmentScreenEnabled”: true }

My experience is that you have to enable on primary channel upload as well

Would you elaborate?

Is there a method for getting the environmentMetrics data from the CLI? Or HTTP?
I would also like this feature.

The telemetry can be viewed on the web client – see pic below.
The data can also be gotten when using the --debug switch, but that is clunky and not meant for ingestion by another program due to data density.

1 Like

MQTT upload channel is active, and channel will send data to broker. Earlier JSON example {“channel”: 0, “from”: -2069944272, “id”: 536602483, “payload”: {“air_util_tx”: 0, “battery_level”: 0, “channel_utilization”: 0, “voltage”: 0}, “sender”: “!8487d440”, “timestamp”: 0, “to”: -1, “type”: “telemetry”} was received by broker and collected from there.

If you mean Enabled the Uplink on Primary channel, I think that is the default behavior.
And to confirm my unit has Uplink enabled see screenshot below

Yes, I meant that one. What is the subscription you use, if you give msh/2/c/+/+ do you receive at least those non-JSON messages. I have meanwhile set up on node-red parsing of c-messages based on protobufs and I do not need to have JSON any longer.

I do receive the ‘c’ messages, but not JSON.
image

Off topic - Is there a guide for this? Inside or outside of Node-red instruction would be helpful.
I see the protobuf docs but I doubt many people will implement custom parsing. Also requiring the packets to be gotten via MQTT requires network connection, which may not be available. Via USB is fine for me, and I think other people know you can see Telemetry from the mobile App.

1 Like

meshtastic --set mqtt.json_enabled true ?

this one was useful - Here is a newb MQTT tutorial for 1.3
I can also export my implementation as it is somewhat simpler and meant for 2.0

1 Like

[{“id”:“4eabc24f.e1fd8c”,“type”:“mqtt in”,“z”:“9f36c810.144438”,“name”:“”,“topic”:“msh/2/c/+/+”,“qos”:“2”,“datatype”:“buffer”,“broker”:“78b410cc.fef46”,“x”:120,“y”:60,“wires”:[[“99ef2653.b39b18”]]},{“id”:“99ef2653.b39b18”,“type”:“decode”,“z”:“9f36c810.144438”,“name”:“MQTT”,“protofile”:“e0e20190.3e87e”,“protoType”:“ServiceEnvelope”,“x”:90,“y”:160,“wires”:[[“ac8c3007.3c802”,“9ecb664a.723928”]]},{“id”:“ac8c3007.3c802”,“type”:“function”,“z”:“9f36c810.144438”,“name”:“Sub_payload”,“func”:“msg.topic = msg.payload.packet.decoded.portnum\nmsg.metainfo = {src: msg.payload.packet.from.toString(16).toUpperCase(), gatewayId: msg.payload.gatewayId};\nmsg.payload = msg.payload.packet.decoded.payload;\nlet bufferObj = Buffer.from(msg.payload, "base64");\nmsg.payload = bufferObj;\nmsg.protobufType = ""\n// msg.parts = {key: "protobuf", id: msg._msgid, index: 2, count: 2, type: "object"};\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:250,“y”:280,“wires”:[[“3aaa8c8e.b52244”]]},{“id”:“7003383d.9ae788”,“type”:“decode”,“z”:“9f36c810.144438”,“name”:“Telemetry”,“protofile”:“96655893.aa88b8”,“protoType”:“Telemetry”,“x”:660,“y”:260,“wires”:[[“ffb421ab.43a8d”,“367afd93.854762”,“847fa303.5e725”]]},{“id”:“3aaa8c8e.b52244”,“type”:“switch”,“z”:“9f36c810.144438”,“name”:“split_payloads”,“property”:“topic”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“TELEMETRY_APP”,“vt”:“str”},{“t”:“eq”,“v”:“POSITION_APP”,“vt”:“str”},{“t”:“eq”,“v”:“NODEINFO_APP”,“vt”:“str”},{“t”:“else”}],“checkall”:“false”,“repair”:false,“outputs”:4,“x”:460,“y”:280,“wires”:[[“7003383d.9ae788”],[“cddb9c6a.7c95f”],[“ae933675.94a638”],[“e304e73a.850dd8”]]},{“id”:“cddb9c6a.7c95f”,“type”:“decode”,“z”:“9f36c810.144438”,“name”:“Position”,“protofile”:“ad72e392.5b5b5”,“protoType”:“Position”,“x”:660,“y”:320,“wires”:[[“847fa303.5e725”]]},{“id”:“ae933675.94a638”,“type”:“decode”,“z”:“9f36c810.144438”,“name”:“User”,“protofile”:“ad72e392.5b5b5”,“protoType”:“User”,“x”:650,“y”:380,“wires”:[[“847fa303.5e725”]]},{“id”:“e304e73a.850dd8”,“type”:“debug”,“z”:“9f36c810.144438”,“name”:“”,“active”:false,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“true”,“targetType”:“full”,“x”:1050,“y”:420,“wires”:},{“id”:“9ecb664a.723928”,“type”:“debug”,“z”:“9f36c810.144438”,“name”:“”,“active”:false,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“true”,“targetType”:“full”,“x”:1030,“y”:160,“wires”:},{“id”:“ffb421ab.43a8d”,“type”:“function”,“z”:“9f36c810.144438”,“name”:“Battery”,“func”:“if (typeof msg.payload.deviceMetrics != "undefined") {\n msg.payload = msg.payload.deviceMetrics.batteryLevel\n msg.topic = msg.metainfo.src\n} \nreturn msg;”,“outputs”:1,“noerr”:0,“x”:840,“y”:260,“wires”:[[“b8606984.4836b8”]]},{“id”:“cd84d18e.b277f”,“type”:“debug”,“z”:“9f36c810.144438”,“name”:“”,“active”:false,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“payload”,“targetType”:“msg”,“x”:1050,“y”:300,“wires”:},{“id”:“b8606984.4836b8”,“type”:“ui_chart”,“z”:“9f36c810.144438”,“name”:“”,“group”:“7113178f.e74c68”,“order”:1,“width”:0,“height”:0,“label”:“Battery”,“chartType”:“line”,“legend”:“true”,“xformat”:“HH:mm:ss”,“interpolate”:“linear”,“nodata”:“”,“dot”:false,“ymin”:“0”,“ymax”:“100”,“removeOlder”:“5”,“removeOlderPoints”:“”,“removeOlderUnit”:“86400”,“cutout”:0,“useOneColor”:false,“colors”:[“#1f77b4”,“#aec7e8”,“#ff7f0e”,“#2ca02c”,“#98df8a”,“#d62728”,“#ff9896”,“#9467bd”,“#c5b0d5”],“useOldStyle”:false,“outputs”:1,“x”:1040,“y”:260,“wires”:[]},{“id”:“367afd93.854762”,“type”:“function”,“z”:“9f36c810.144438”,“name”:“Split_telemetry”,“func”:“if (typeof msg.payload.deviceMetrics != "undefined") {\n msg.payload = msg.payload.deviceMetrics\n msg.topic = msg.metainfo.src\n return [msg, null];\n} \nif (typeof msg.payload.environmentMetrics != "undefined") {\n msg.topic = msg.metainfo.src\n msg.payload = msg.payload.environmentMetrics;\n return [null, msg];\n}\nreturn [null,null];”,“outputs”:2,“noerr”:0,“x”:860,“y”:300,“wires”:[[“cd84d18e.b277f”],[“4943efdc.fdc71”]],“outputLabels”:[“device”,“environment”]},{“id”:“4943efdc.fdc71”,“type”:“debug”,“z”:“9f36c810.144438”,“name”:“”,“active”:true,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“payload”,“targetType”:“msg”,“x”:1050,“y”:340,“wires”:},{“id”:“ca0f888d.7a8c98”,“type”:“debug”,“z”:“9f36c810.144438”,“name”:“”,“active”:false,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“payload”,“targetType”:“msg”,“x”:1050,“y”:380,“wires”:},{“id”:“847fa303.5e725”,“type”:“function”,“z”:“9f36c810.144438”,“name”:“Add_metainfo”,“func”:“msg.topic = msg.metainfo.src\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:860,“y”:380,“wires”:[[“ca0f888d.7a8c98”]],“outputLabels”:[“device”,“environment”]},{“id”:“78b410cc.fef46”,“type”:“mqtt-broker”,“z”:“”,“name”:“”,“broker”:“rsa65”,“port”:“1883”,“clientid”:“”,“usetls”:false,“compatmode”:true,“keepalive”:“60”,“cleansession”:true,“birthTopic”:“”,“birthQos”:“0”,“birthPayload”:“”,“closeTopic”:“”,“closeQos”:“0”,“closePayload”:“”,“willTopic”:“”,“willQos”:“0”,“willPayload”:“”},{“id”:“e0e20190.3e87e”,“type”:“protobuf-file”,“z”:“”,“protopath”:“/root/protobufs/mqtt.proto”,“watchFile”:true,“keepCase”:false},{“id”:“96655893.aa88b8”,“type”:“protobuf-file”,“z”:“”,“protopath”:“/root/protobufs/telemetry.proto”,“watchFile”:true,“keepCase”:false},{“id”:“ad72e392.5b5b5”,“type”:“protobuf-file”,“z”:“”,“protopath”:“/root/protobufs/mesh.proto”,“watchFile”:true,“keepCase”:false},{“id”:“7113178f.e74c68”,“type”:“ui_group”,“z”:“”,“name”:“Battery”,“tab”:“993217ff.2d9ee8”,“order”:1,“disp”:true,“width”:“25”,“collapse”:false},{“id”:“993217ff.2d9ee8”,“type”:“ui_tab”,“z”:“”,“name”:“Meshtastic”,“icon”:“dashboard”,“order”:6,“disabled”:false,“hidden”:false}]

It is turned on, yes. Still no sight of JSON packets on MQTT
image

Thanks for the info and what I think is your .proto. for it. I don’t personally use Node Red but it should help someone else.

Off topic – I am able to see environment metrics on the mesh, using the Python API.
Below is a screenshot of the terminal output while running examples/pub_sub_example2.py
This is good enough for me, for now.
I will post a feature request to get Telemetry data from the meshtastic CLI.
image

I tried changing brokers, instead of the public broker at mqtt://mqtt.meshtastic.org.
Now I can see JSON packets. Strange?

Screenshot:

image