{"id":123,"date":"2017-05-04T03:04:48","date_gmt":"2017-05-04T03:04:48","guid":{"rendered":"http:\/\/www.cribbstechnologies.com\/?page_id=123"},"modified":"2017-05-04T03:04:48","modified_gmt":"2017-05-04T03:04:48","slug":"mqtt-lightweight-pubsub","status":"publish","type":"page","link":"https:\/\/www.cribbstechnologies.com\/index.php\/home-automation\/mqtt-lightweight-pubsub\/","title":{"rendered":"MQTT &#8211; Lightweight Pub\/Sub"},"content":{"rendered":"<p>[et_pb_section bb_built=&#8221;1&#8243; admin_label=&#8221;section&#8221;][et_pb_row admin_label=&#8221;row&#8221;][et_pb_column type=&#8221;4_4&#8243;][et_pb_text admin_label=&#8221;Text&#8221; background_layout=&#8221;light&#8221; text_orientation=&#8221;left&#8221; use_border_color=&#8221;off&#8221; border_color=&#8221;#ffffff&#8221; border_style=&#8221;solid&#8221;]<\/p>\n<p><a href=\"http:\/\/mqtt.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">MQTT<\/a> is a protocol designed to allow pieces of hardware to communicate with one another with a simple Pub\/Sub(publisher\/subscriber) model that consists of 3 basic parts.<\/p>\n<ul>\n<li>Broker<\/li>\n<li>Publisher(s)<\/li>\n<li>Subscriber(s)<\/li>\n<\/ul>\n<p>The broker is a piece of software that implements the MQTT protocol and runs on a server. This server handles authentication and authorization, management of topics, and QoS(Quality of Service); I use <a href=\"http:\/\/mosquitto.org\" target=\"_blank\" rel=\"noopener noreferrer\">Mosquitto<\/a>.<\/p>\n<p>The publishers are clients of one form or another that publish messages to one or more MQTT topics. These can be pieces of hardware such as an Arduino, ESP8266 or pieces of software like a command-line client, or a browser plugin. I&#8217;ve found <a href=\"https:\/\/chrome.google.com\/webstore\/detail\/mqttlens\/hemojaaeigabkbcookmlgmdigohjobjm?hl=en\" target=\"_blank\" rel=\"noopener noreferrer\">MQTTLens<\/a> to be very useful when testing development of my <a href=\"http:\/\/www.cribbstechnologies.com\/index.php\/home-automation\/horizontal-plantation-blind-automation\/\">Horizontal Plantation Blinds<\/a> system<\/p>\n<p>The subscribers are clients of one form or another that receive notifications when a publisher has added a message to a topic to which they are subscribed. They contact the broker and let it know they would like to receive updates on a topic and the broker fires events when messages are published to the topic.<\/p>\n<p>You can take a look at the code for the NodeMCU for my blinds <a href=\"http:\/\/www.cribbstechnologies.com\/index.php\/home-automation\/horizontal-plantation-blind-automation\/horizontal-blinds-hardware\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>\u00a0and see that it&#8217;s publishing to\u00a0one topic (livingRoom0\/status) and subscribing to two (livingRoom0\/tilt, livingRoom0\/raise). Part of the code that handles the subscription also provides a callback method that the MQTT client invokes whenever a message is published to that topic.<\/p>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[et_pb_section bb_built=&#8221;1&#8243; admin_label=&#8221;section&#8221;][et_pb_row admin_label=&#8221;row&#8221;][et_pb_column type=&#8221;4_4&#8243;][et_pb_text admin_label=&#8221;Text&#8221; background_layout=&#8221;light&#8221; text_orientation=&#8221;left&#8221; use_border_color=&#8221;off&#8221; border_color=&#8221;#ffffff&#8221; border_style=&#8221;solid&#8221;] MQTT is a protocol designed to allow pieces of hardware to communicate with one another with a simple Pub\/Sub(publisher\/subscriber) model that consists of 3 basic parts. Broker Publisher(s) Subscriber(s) The broker is a piece of software that implements the MQTT protocol and runs on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":39,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-123","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.cribbstechnologies.com\/index.php\/wp-json\/wp\/v2\/pages\/123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cribbstechnologies.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.cribbstechnologies.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.cribbstechnologies.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cribbstechnologies.com\/index.php\/wp-json\/wp\/v2\/comments?post=123"}],"version-history":[{"count":1,"href":"https:\/\/www.cribbstechnologies.com\/index.php\/wp-json\/wp\/v2\/pages\/123\/revisions"}],"predecessor-version":[{"id":129,"href":"https:\/\/www.cribbstechnologies.com\/index.php\/wp-json\/wp\/v2\/pages\/123\/revisions\/129"}],"up":[{"embeddable":true,"href":"https:\/\/www.cribbstechnologies.com\/index.php\/wp-json\/wp\/v2\/pages\/39"}],"wp:attachment":[{"href":"https:\/\/www.cribbstechnologies.com\/index.php\/wp-json\/wp\/v2\/media?parent=123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}