MQTT Exercise

Objective: This exercise is intended to give you a brief understanding of MQTT (Message Queuing Telemetry Transport) and how to demonstrate it to potential users.

Requirements: This exercise requires a FLIR camera supporting MQTT, a computer acting as a broker (MQTT server) and a computer with administrator rights which will act as a MQTT client. These devices need to be connected with ethernet cables and an ethernet switch/router. It is of course possible to handle all the communication over wireless networks, which the image below shows.

Introduction

MQTT is a messaging protocol used in low bandwidth environments which is often a requirement in IIOT (Industrial Internet of Things) applications. MQTT is used for sending commands to a sensor and receiving the sensor data. In MQTT, there is always a server and clients. The server is called a broker. Clients can connect to the broker and subscribe to data from other clients which are connected to the same broker. In this exercise you will turn your computer into an MQTT client and connect to an existing broker and subscribe to data from a client (the camera). When talking about MQTT, common terminology to keep track of is broker, client, subscription and topics. The broker in this exercise is a computer hosting an MQTT server, the client is your computer and camera, and the topics are subscribed by the computer which will contain temperature data (spots for example).

Instructions

  1. Download an install the software MQTT.fx on your computer, available here. 
    Connect your computer to a network which also hosts a MQTT broker and a FLIR camera, according to the image below. The camera can either be connected over WiFi or with an ethernet cable.
    MQTT_Long 1.jpg
    On your computer, open a web browser and navigate to the FLIR camera IP address. If you do not know the camera IP address, use FLIR IP Config or a 3rd party network sniffer. When you have connected to the camera, go to Settings -> MQTT and click on the checkbox Enable MQTT. Enter the IP address of the MQTT broker. In this exercise there are three ethernet devices and therefor three IP addresses to keep track of; the camera, the computer and the broker. When you have entered the IP address of the broker, press save. The IP addresses of the devices on the network is often available in the web interface of the router. The MQTT settings of the camera are seen in the image below. In this example, the broker has the IP address 192.168.254.19. No user or password is needed in this example.
    MQTT_Long 2.jpg
    To the right of the MQTT settings, there is a list of topics that is available over MQTT. A topic is an identifier which is needed to configure a subscription. An example on a topic in an industrial environment could be electrical_engines/productionline/b/rpm which would provide the rpm of engine B in the production line for example. Copy the topic that you would like to subscribe to from the FLIR camera web interface. If you want to subscribe to the temperature in spot 1, copy that topic, which is in this format FLIR/ec501-03FF2D/spot1
    Start the MQTT.fx software, available from the Windows start menu. Press the cogwheel in the upper left menu. Enter the broker IP address (same as you entered in the camera web interface) and then press Apply. Then press Connect to the right of the cogwheel.
    Press the subscribe tab and in the textbox, enter the topic that you copied earlier, and press subscribe to the right of the textbox.
    If everything succeeded, you should see the messages from the camera in the right pane of the software and every time the temperature changes, a new message will show up. To see the temperature of each message, press the message and it will be seen in the lower right pane. Try adding an alarm instead of a spot value and see how that works!

MQTT_Long 3.jpg

Related Articles