
- Bookmark
- Subscribe
- Email to a Friend
- Printer Friendly Page
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
MQTT
Originally published on Geo SCADA Knowledge Base by Anonymous user | June 10, 2021 04:14 AM
Testing with Mosquitto
Get a Broker
To test the MQTT driver you can use the mosquitto software.
Go to https://mosquitto.org/
Download (for Windows) the installer (follow the Binary ... Windows links or click https://mosquitto.org/files/ and click 'binary', 'win64' and the latest version.
Install this. There will be no Start menu addition, find the service in the Windows Services applet and start it.
If it fails to start, there is no log, so it's easier to run on the command line to find the problem.
- Open a CMD window as Administrator
- Set directory
cd C:\Program Files\mosquitto
- Start manually
mosquitto -v
- Review the output
You may need to edit the mosquitto.conf file, located in the
C:\Program Files\mosquitto
folder. Edit this using Administrator permissions.
You may also need to add a firewall rule to allow this port to be exposed beyond localhost.
Sending MQTT Messages - in JSON 'A' Format
Once the broker is running, you can use the mosquitto_pub utility to publish messages.
- Open a CMD window as Administrator
- Set directory
- Use commands like:
mosquitto_pub -h 127.0.0.1 -p 1883 -t "East/MyDevice1" -m "{""time"": 1597228825, ""Analog1"":12.7}"
- Note that the quote marks need to be escaped with ""
- Note that the / character in "East/MyDevice1" is a forward slash, used to separate parts of an MQTT topic
- You must supply a time value for the message to be processed, and this needs to be in range. You can get a timestamp for the current time by visiting this web site: https://www.epochconverter.com/
Author
Link copied. Please paste this link to share this article on your social media post.