diff --git a/docs/software/other/mqtt.mdx b/docs/software/other/mqtt.mdx index e1a0e868..1f7468d7 100644 --- a/docs/software/other/mqtt.mdx +++ b/docs/software/other/mqtt.mdx @@ -380,3 +380,34 @@ if __name__ == '__main__': while client.loop() == 0: pass ``` +### Tutorial on using MQTT with version 1.3.46+ + +Version 1.3.46+ is the first 1.3 release with MQTT and JSON fully functional on supported devices. Heltec JSON over MQTT is unlikely to work reliably. + +One of the major changes is that the TOPICs are different from prior versions. +`msh/1/c/ChannelName/!12345678` and +`msh/1/json/ChannelName/!12345678` + +are now +`msh/2/c/ChannelName/!12345678` and +`msh/2/json/ChannelName/!12345678` +Please see the documentation at the top of this topic for that. + +Node-RED is a free cross-platform programming tool for wiring together hardware, APIs, and online services developed originally by IBM for IOT. It is widely used for home automation by many non-professional programmers and runs well on Pi's. Node-red has many plug-in modules written by the community. I will use this platform as a practical example on how to interface with the MQTT features of Meshtastic. Everything can be done from GUI's without using command line. + +Step one: use http://client.meshtastic.org/ to connect to your device via usb and adjust these settings using the web GUI. +Enable and enter network ssid/psk. Settings-->Device Config-->Network; Save. +Set MQTT server address. Settings-->Module Config -->MQTT config; Verify Encryption Enabled is OFF. Turn JSON Output Enabled ON. Save. +Go to Channel Editor and set uplink and downling enabled to True. Save. + +Step two: if you don't want to depend on JSON decoding on the device, you can decode the proto messages off-device. To do that you will need to get the .proto files from https://github.com/meshtastic/Meshtastic-protobufs. They function as a schema and are required for decoding in Node-RED. Save the files where the node-RED application can access them and note the file path of the "mqtt.proto" file. + +Step three: install Node-RED plug-ins to your node-RED application for an embedded mqqt server and a protobuf decoder. +https://flows.nodered.org/node/node-red-contrib-aedes +https://flows.nodered.org/node/node-red-contrib-protobuf + +Drag, drop, and wire the nodes like this. For this example, I ran node-RED on a Windows machine. Note that file paths might be specified differently on different platforms. MQTT server wild cards are usually the same. A "+" is a single level wildcard for a specific topic level. A "#" is a multiple level wildcard that can be used at the end of a topic filter. The debug messages shown are what happens when the inject button sends a json message with a topic designed to be picked up by the specified Meshtastic device and then having it resend the message by both radio and MQTT. + +[](/documents/mqtt/NodeRedTwo.jpg) +[](/documents/mqtt/NodeRedThree.jpg) +[](/documents/mqtt/NR_nodes.jpg) diff --git a/static/documents/mqtt/NR_nodes.jpg b/static/documents/mqtt/NR_nodes.jpg new file mode 100644 index 00000000..f9f16601 Binary files /dev/null and b/static/documents/mqtt/NR_nodes.jpg differ diff --git a/static/documents/mqtt/NodeRedThree.jpg b/static/documents/mqtt/NodeRedThree.jpg new file mode 100644 index 00000000..68e5e3d9 Binary files /dev/null and b/static/documents/mqtt/NodeRedThree.jpg differ diff --git a/static/documents/mqtt/NodeRedTwo.jpg b/static/documents/mqtt/NodeRedTwo.jpg new file mode 100644 index 00000000..c11c1663 Binary files /dev/null and b/static/documents/mqtt/NodeRedTwo.jpg differ