The Basics of MQTT

Message Queue Telemetry Transport (MQTT), is an open, lightweight publish/subscribe messaging protocol that was developed specifically for small, constrained devices over wireless networks. MQTT brings a simplicity and scalability not found in traditional Internet or industrial protocols. The speed and efficiency of the protocol make it a popular choice for applications ranging from measurement and detection to supervisory control.

The following information is designed to provide an introduction to the unique features and functionality of the MQTT protocol.

MQTT   MQTT

MQTT Publish and Subscribe

Unlike traditional request-reponse type protocols such as http or Modbus, MQTT is based on the simple principle of publishing messages and subscribing to topics. Multiple clients connect to a broker by subscribing and/or publishing to topics and accessing the information.

The broker and MQTT act as a common interface for everything else to connect to. This means that you if you have clients that post subscribed messages or text files to a database; it then becomes easy to add new things, such as sensors or data.

Broker and connected Clients
a. Broker receives subscription from clients on topics
b. Broker receives messages and forward them
c. Clients subscribe/publishes on topics

MQTT Topics and Subscriptions

Messages in MQTT are published on topics. Topics are treated as a hierarchy, using a slash (/) as a separator. This provides a logical structure of common themes to be created, much like any file system you have used. So, for example, multiple computers could publish their hard drive temperature information on the following single topic, by inserting their unique computer and hard drive name: sensors/COMPUTER_NAME/temperature/HARDDRIVE_NAME

Multiple clients could then receive messages by creating a subscription to this specific topic. However, there are two wildcards available + or #. The + character can be used as a wildcard for a single level of hierarchy. In the topic above it could be used as follows to get information on all computers and hard drives:

sensors/+/temperature/+

Another example, for a topic of “a/b/c/d”, the following example subscriptions will match:

a/b/c/d
+/b/c/d
a/+/c/d
a/+/+/d
+/+/+/+

However, these following subscriptions would not match:

a/b/c
b/+/c/d
+/+/+

The # character can be used as a wildcard for all remaining levels of hierarchy, which means that it must be the final character in a subscription in order to match. With a topic of “a/b/c/d”, the following example subscriptions will match:

a/b/c/d
#
a/#
a/b/#
a/b/c/#
+/b/c/#

Quality of Service

MQTT has defined three levels of Quality of Service (QoS). The QoS defines how hard the broker/client will work or attempt to ensure that a message is received. It’s much like sending an email to someone using normal settings versus sending it out using the read receipt feature to confirm that the email was received or opened. Messages can be sent at any QoS level, and clients may attempt to subscribe to topics at any QoS level, which means that the client chooses the maximum QoS level they will receive. For example, if a message is published at QoS 2 and a client is subscribed with QoS 0, the message will be delivered to that client with QoS 0. If a second client is also subscribed to the same topic, but with QoS 2, then it will receive the same message but with QoS 2.

Another example could be if a client is subscribed with QoS 2 and a message is published on QoS 0, the client will receive it on QoS 0. Higher levels of QoS are more reliable, but involve higher latency and have higher bandwidth requirements.

  • 0: The broker/client will deliver the message once, with no confirmation (fire and forget).
  • 1: The broker/client will deliver the message at least once, with confirmation required.
  • 2: The broker/client will deliver the message exactly once by using a four-step handshake.

Other MQTT Key Features

  • Keep-Alive message (PINGREQ, PINGRESP)
  • A broker can detect client disconnection even if it doesn’t send an explicit DISCONNECT message
  • “Last Will and Testament” message: specified in CONNECT message with topic, QoS and retain. On unexpected client disconnection, it the “Last Will and Testament” message is sent to to subscribed clients
  • “Retain” message: a PUBLISH message on a topic is kept on the broker which allows a new connected subscriber on the same topic to receive this message (last known good message)
  • “Durable” subscription: on client disconnection, all subscriptions are kept on the broker and recovered on client reconnection

For more complete information on MQTT, see http://mqtt.org/

Making Wireless Sensors as Accessible as Web Servers

The Internet of Things revolution is upon us, and by the year 2020, therewill be over 50 billion connected things in the world. With the world’s population increasing and resources...

Wzzard Network Planning and Installation Application Note

Planning, deploying and installing a Wzzard network does not require any special network expertise. But some simple guidelines should be followed. Let’s discuss some topics that are the keys to enabling a robust network installation. These include Planning a Deployment, Verification of Network Health and Troubleshooting common problems.

Getting Security Right in Wireless Sensor Networks

You may define rules in the router for switching between two APNs on one SIM card or between two SIM cards or network providers. The router can automatically switch between the network setups when the active PPP connection is lost, the data limit is exceeded, or the binary input on the front panel goes active.

Wzzard Security Platform

The Spectre Network Gateway places the SmartMesh IP network behind a firewall. If connecting via the cellular data networks, the Spectre Network Gateway lets users use VPN tunneling, which makes the cellular systems as secure as proprietary infrastructure.

A Second Warm Welcome to Wireless Mesh Networking

You may define rules in the router for switching between two APNs on one SIM card or between two SIM cards or network providers. The router can automatically switch between the network setups when the active PPP connection is lost, the data limit is exceeded, or the binary input on the front panel goes active.

Connect Any Sensor to the Internet of Things

You may define rules in the router for switching between two APNs on one SIM card or between two SIM cards or network providers. The router can automatically switch between the network setups when the active PPP connection is lost, the data limit is exceeded, or the binary input on the front panel goes active.

Spectre Router Configuration for Automatic Failover

You may define rules in the router for switching between two APNs on one SIM card or between two SIM cards or network providers. The router can automatically switch between the network setups when the active PPP connection is lost, the data limit is exceeded, or the binary input on the front panel goes active.

Sensor Networking Cost Model

Are the high costs of deploying cabling in your industrial environment preventing you from deploying a remote sensor monitoring solution?

Cellular and the Promise of SWARM Intelligence

The power of SWARM intelligence is visible in nature, where the collective efforts of very simple creatures like ants, bees and termites can produce highly sophisticated results.

SWARM Intelligence: Greater than the Sum of Its Parts

The power of SWARM intelligence is visible in nature, where the collective efforts of very simple creatures like ants, bees and termites can produce highly sophisticated results. Termites build enormous...

Solving Industrial Monitoring Challenges through Wireless I/O

Abstract Remote monitoring and control applications present a range of challenges. In recent years, new technologies and products have emerged to address some of these challenges, but in many cases...

SimpleWire Replacement with Zlinx® Radio Modems: Knowledge, Tips, Fixes

A problem free wireless network installation is more than a wish, it’s what most of our customers experience. But a little knowledge and planning up front makes succeeding on your...

Wireless Technology for Modern Health Care

Some medical devices become immensely more valuable if you can make them mobile. Moving a modern medical cart from room to room is far more efficient than moving the patients...

Smart Phones & M2M – Connecting Made Easy, Finally

by Bill Conley You could argue that wireless data communications began in 1782, when Claude Chappe used semaphore towers to send messages between Paris, France, and the city of Lille,...

USB: Adaptable for Industrial Applications

The Universal Serial Bus (USB) provides a high data rate and Hot Swap connection for PCs, providing an easy connection to a wide variety of multimedia and network USB devices....

Ruggedizing USB Connections for Tough Environments

USB is ubiquitous, it’s useful and it’s here to stay. But it isn’t inherently rugged or reliable. It’s up to you to make it that way. When technician John Baker...

The Ten Commandments of USB

Don’t forget that USB uses copper wire and can thus transfer power surges from lightning strikes or heavy machinery to places where they can do serious damage. You can prevent...

Data Line Isolation Theory

When it comes time to protect data lines from electrical transients, surge suppression is often the first thing that leaps to mind. The concept of surge suppression is intuitive and...

Optical Isolation: Your Best Investment for Reliability

In 1999 the Science department at NASA conducted a study on lightning, ground voltage, and structural impact. A building in North Carolina, located within 45 meters of a 42-meter water...

Make Your Tablets and Smart Phones Smarter – Add Serial Capability for Seriously Remote Data

by Andy Ross, Director or Wireless Applications To paraphrase Mark Twain, rumors about the demise of serial ports are greatly exaggerated. Serial ports are everywhere, in everything from industrial automation...

RS-485 Connections FAQ

How Do I Make RS-485 Connections? First check the pinout connections and specifications of the devices you want to connect in order to determine whether you need a “2-wire” RS-485...

RS-422 and RS-485 Applications eBook

A Practical Guide to Using RS-422 and RS-485 Serial Interfaces The purpose of this ebook is to describe the main elements of RS-422 and RS-485 data communications systems. The authors...

MTBF, MTTR, MTTF, FIT – Explanation of Terms

The intent of this White Paper is to provide an understanding of MTBF and other product reliability methods. Understanding the methods for the lifecycle prediction for a product enables the...

An Overview of Fiber Optic Technology

The use of fiber optics in telecommunications and wide area networking has been common for many years, but more recently fiber optics have become increasingly prevalent in industrial data communications...

Calculating Fiber Loss in Fiber Optic Networking

Fiber optic networking can be a daunting undertaking, but it really is not as difficult as it seems. Understanding factors such as fiber modes, fiber launch power, receive sensitivity, fiber...

Troubleshooting and Auto-Negotiation Features for Media Conversion Products

Media converters make the critical connection between different types of media, ensuring seamless integration of new equipmentin legacy networks. Media converters simply provide the electrical-to-optical conversion, and cost-effectively bridge the...

Introduction to Modbus

Modbus is one of the most popular protocols used in the industrial world. Supporting traditional serial protocols of RS232/422/485 and Ethernet protocols allow industrial devices such a PLCs, HMIs and...

Media Converters

Introduction to Media Converters Media converters play an important role in today’s multi-protocol, mixed media Local Area Networks. For example, LAN administrators can deploy media converters to integrate fiber optic cabling and active...

Port Powered Serial Converters FAQ

How do port powered serial converters derive their power? These converters steal their power from the connected RS-232 device’s output signals. As an example, a PC normally has outputs on the...

Managed Ethernet Switches

Key Features For a Powerful Industrial Network  Success for an industrial engineer has always had roots in the search for dependability and function at an affordable cost. Ethernet always held out the promise of high function...

Cellular Data Networking Goes Industrial

Refresh cycles for industrial data communications equipment have traditionally been measured in decades rather than years. That’s partly because of the enormous capital investments involved, partly because so many industrial...

What is SmartMesh IP™?

SmartMesh IP is defining the way to connect smart devices. With advanced network management and comprehensive security features, SmartMesh IP delivers reliable, scalable, energy efficient wireless sensor connectivity. Using up...

What Is The Internet of Things?

There’s a lot of hype surrounding the phrase “Internet of Things”, but what does it really mean for you? Mike Fahrion offers a pragmatic approach to realizing the potential for...