Digital Twinning: Stand Up an MQTT Broker

Digital Twin
Digital Twin

An MQTT Broker is any message broker that supports the Oasis MQTT specification. A broker is required to use MQTT. MQTT is a lightweight IoT publish-subscribe system – the broker is the central server listening for, queueing and dispatching messages which come from and are sent to connected devices. It is one of the most long-standing and popular messaging protocols, and it can be used over TCP with WebSockets to maintain a continuous stream of data, which is why I decided to use it.

LF Edge Logo

There are many IoT platforms that support MQTT, including over a dozen that are free open source. I wanted to set up a large-scale system that could provide some potentially relevant experience for future Iot development work. For this reason I chose LF EdgeX Foundry, which is a micro-service based system used in many large-scale implementations. Otherwise I recommend using a free cloud broker service and skipping the installation – HiveMQ has a small-scale free service that is easy to get up and running with.

Docker Logo

LF Edge recommends installing Foundry via Docker. Each microservice is configured in it’s own image and it simply works out of the box.

Docker running LF Edge Foundry

There is an option to install a virtual device with Foundry – this was very helpful in multiple ways:

  • I was able to confirm that I was getting messages from my service by switching the virtual device service on and off.
  • I could examine the format of the messages and use that to create my own
  • I could rely on a steady, but not overwhelming, stream of messages.
  • I could immediately see the effect of assigning different topics for the purpose of segregating and filtering streams.

I used the recommended MQTT Websocket page from HiveMQ to verify my service was up and running. Entering the address, port and topic name was enough to confirm that I could publish and receive messages via my broker service: both virtual devices and messages I created and published from the page.

The Hive MQ Websocket Client

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Captcha loading...

This site uses Akismet to reduce spam. Learn how your comment data is processed.