Playing with MQTT

details

mqtt1_small

MQTT: the Internet of Things standard protocol?

How does it work? From a high perspective it is a basic client/server messaging protocol that includes a Publish / Subscribe mechanism: a client publish a message on a specific queue (called ‘topic’) hosted by a message broker, and another client can receive it by subscribing to the topic. Each client is able to publish and receiving messages at the same time, and communications occurs between each client and the message broker(s). Two clients won’t be able to exchange messages without a broker in the middle.

 

mqtt3_small

 

The most relevant difference if compared with HTTP, which is the protocol usually behind REST implementations, is that MQTT establish a stateful connection, allowing this way near real time communication. If you’re interested, the complete MQTT V.3.1 specifications are available here within the IBM developerWorks network. The protocol specs are completely open, so everybody can build his very own MQTT application. The Eclipse Project, which currently leads the MQTT software related development (protocols implementations, the Mosqitto broker, Paho) has a specific section that hosts some Open Source implementation of servers and clients in several languages.

 

mqtt_wiring

 

The scketch running on Arduino is based on the mqtt library developed by Nick O’Leary and does two things:

  1. as a subscriber of the topic “[my domain]/stuff/Arduino/things/hearbeatclock”: receives commands in the form of MQTT messages and processes them. Currently it can only receive two messages, one to turn on the light and another one to turn it off;
  2. as a publisher on the same topic: get the uptime from the RTC and publish it .

 

Source: mmtn.borioli.net

 

mqtt1_small

MQTT: the Internet of Things standard protocol?

How does it work? From a high perspective it is a basic client/server messaging protocol that includes a Publish / Subscribe mechanism: a client publish a message on a specific queue (called ‘topic’) hosted by a message broker, and another client can receive it by subscribing to the topic. Each client is able to publish and receiving messages at the same time, and communications occurs between each client and the message broker(s). Two clients won’t be able to exchange messages without a broker in the middle.

 

mqtt3_small

 

The most relevant difference if compared with HTTP, which is the protocol usually behind REST implementations, is that MQTT establish a stateful connection, allowing this way near real time communication. If you’re interested, the complete MQTT V.3.1 specifications are available here within the IBM developerWorks network. The protocol specs are completely open, so everybody can build his very own MQTT application. The Eclipse Project, which currently leads the MQTT software related development (protocols implementations, the Mosqitto broker, Paho) has a specific section that hosts some Open Source implementation of servers and clients in several languages.

 

mqtt_wiring

 

The scketch running on Arduino is based on the mqtt library developed by Nick O’Leary and does two things:

  1. as a subscriber of the topic “[my domain]/stuff/Arduino/things/hearbeatclock”: receives commands in the form of MQTT messages and processes them. Currently it can only receive two messages, one to turn on the light and another one to turn it off;
  2. as a publisher on the same topic: get the uptime from the RTC and publish it .

 

Source: mmtn.borioli.net

 

COMMENTS

Please Login to comment
  Subscribe  
Notify of