Last updated: 8 June 2022
Now we've got our IoT MQTT broker and publishing client set up, we'll subscribe to them and receive messages on a mobile device running an open source MQTT app. This is a typical use of MQTT protocol for IoT communication.
In this example we'll install Routix MQTT dash on Android (which you can install securely and quickly from the Google Play Store). There are other apps for Android but MQTT Dash is by far the most intuitive and provides the most options for configuration. It really allows you to get an IoT project set up in literally minutes.
Once you've installed MQTT Dash, open the app and do the following (screenshots below):
Step | Field | Value |
---|---|---|
2 | Name | Some "sensible" name - can be anything you like |
3 | Address | the exact same URL that appears in your broker configuration |
4 | Port | 8883 |
5 | SSL/TLS encryption | enable |
6 | Self-signed certificates | enable |
7 | User name | The exact same user name you entered when you created your broker |
8 | User password | The exact same password you entered when you created your broker |
Text
from the
pop-up dialogue (because the payload of this topic will just be text).
mqtt pub -h {URL} -p 8883 -s -u {your user name} -pw {your password} -t 'my/test/topic2' -m "Hello!"
You should now see this pop up on your phone:
To send an image we just repeat the previous process except that this time we'll tell the MQTT Dash app on our mobile phone to expect an image, and instead of publishing text from the terminal window we'll send an image from our hard drive.
Image
from the
pop-up dialogue (because this time the payload will be image
data).
-m:file
flag:
mqtt pub -h {URL} -p 8883 -s -u {your user name} -pw {your password} -t 'my/test/images' -m:file "path/to/image.png"
You should now see something like this pop up on your phone (your image will be different, of course):
Now it's time to experiment publishing with sensors (instead of manually publishing from the terminal) and maybe coding a customised client subscriber :)