{"id":2204,"date":"2017-11-10T17:33:24","date_gmt":"2017-11-10T22:33:24","guid":{"rendered":"https:\/\/blogs.mathworks.com\/iot\/?p=2204"},"modified":"2018-01-12T13:39:38","modified_gmt":"2018-01-12T18:39:38","slug":"subscribe-to-thingspeak-iot-data-using-mqtt","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/iot\/2017\/11\/10\/subscribe-to-thingspeak-iot-data-using-mqtt\/","title":{"rendered":"Subscribe to ThingSpeak IoT Data using MQTT"},"content":{"rendered":"<p>The\u00a0<a href=\"https:\/\/thingspeak.com\">ThingSpeak IoT<\/a>\u00a0service now supports MQTT subscriptions to receive\u00a0instant updates when a ThingSpeak channel gets updated. MQTT is a powerful standard for IoT systems. ThingSpeak enables clients to update and receive updates from channel feeds via the ThingSpeak MQTT broker.\u00a0MQTT is a publish\/subscribe communication protocol that uses TCP\/IP sockets or WebSockets. MQTT over WebSockets can be secured with SSL. A client device connects to the MQTT broker and can publish to a channel or subscribe to updates from that channel.<\/p>\n<p><a href=\"https:\/\/www.mathworks.com\/help\/thingspeak\/mqtt-api.html\"><img decoding=\"async\" loading=\"lazy\" width=\"552\" height=\"432\" class=\"aligncenter size-full wp-image-2205\" src=\"https:\/\/blogs.mathworks.com\/iot\/files\/2017\/11\/thingspeak_mqtt_subscribe.png\" alt=\"\" \/><\/a><\/p>\n<h3>MQTT in MATLAB<\/h3>\n<p>We also published a new File\u00a0Exchange submission that allows you to publish and subscribe\u00a0using MQTT within MATLAB. Download and install <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/64303-mqtt-in-matlab\">MQTT in MATLAB<\/a> to be able to connect to ThingSpeak&#8217;s MQTT server or connect to other standard\u00a0MQTT\u00a0brokers such as AWS IoT. Using this Add-On in MATLAB allows you to define custom functions to evaluate on receiving messages streaming over subscribed topics.<\/p>\n<h3>ThingSpeak MQTT Examples<\/h3>\n<ul>\n<li class=\"add_margin_0\"><strong><a class=\"a\" href=\"https:\/\/www.mathworks.com\/help\/thingspeak\/mqtt-basics.html\">MQTT Basics<\/a>\u00a0&#8211;\u00a0<\/strong>Learn about the publish\/subscribe architecture for connecting bandwidth and power-constrained devices over wireless networks.<\/li>\n<li class=\"add_margin_0\"><strong><a class=\"a\" href=\"https:\/\/www.mathworks.com\/help\/thingspeak\/choose-between-rest-and-mqtt.html\">Choose Between REST API and MQTT API<\/a>\u00a0&#8211;\u00a0<\/strong>Learn when to use REST and MQTT to update a channel.<\/li>\n<li class=\"add_margin_0\"><strong><a class=\"a\" href=\"https:\/\/www.mathworks.com\/help\/thingspeak\/use-desktop-mqtt-client-to-publish-to-a-channel.html\">Publish to a Channel Using Desktop MQTT Client<\/a>\u00a0&#8211;\u00a0<\/strong>Publish to a channel using desktop MQTT client such as MQTT.fx.<\/li>\n<li class=\"add_margin_0\"><strong><a class=\"a\" href=\"https:\/\/www.mathworks.com\/help\/thingspeak\/use-arduino-client-to-publish-to-a-channel.html\">Publish to a Channel Using Arduino Client<\/a>\u00a0&#8211;\u00a0<\/strong>Publish data to a ThingSpeak channel using an Arduino<sup>\u00ae<\/sup>\u00a0device.<\/li>\n<li class=\"add_margin_0\"><strong><a class=\"a\" href=\"https:\/\/www.mathworks.com\/help\/thingspeak\/use-photon-client-to-publish-to-a-channel.html\">Publish Using Particle Photon Client<\/a>\u00a0&#8211;\u00a0<\/strong>Publish data to a ThingSpeak channel using a Particle Photon device.<\/li>\n<li class=\"add_margin_0\"><strong><a class=\"a\" href=\"https:\/\/www.mathworks.com\/help\/thingspeak\/use-raspberry-pi-board-that-runs-python-websockets-to-publish-to-a-channel.html\">Publish Using WebSockets in Python on a Raspberry Pi<\/a>\u00a0&#8211;\u00a0<\/strong>Publish data using WebSockets to a ThingSpeak channel.<\/li>\n<li class=\"add_margin_0\"><strong><a class=\"a\" title=\"https:\/\/www.mathworks.com\/help\/thingspeak\/use-desktop-mqtt-client-to-subscribe-to-channel-updates.html (link no longer works)\">Subscribe to Channel Updates Using Desktop MQTT Client<\/a>\u00a0&#8211;\u00a0<\/strong>Subscribe to channel updates from a ThingSpeak channel using desktop MQTT.<\/li>\n<li class=\"add_margin_0\"><strong><a class=\"a\" href=\"https:\/\/www.mathworks.com\/help\/thingspeak\/use-particle-photon-client-to-subscribe-to-channel-updates.html\">Subscribe to Channel Updates Using Particle Photon Client<\/a>\u00a0&#8211;\u00a0<\/strong>Subscribe to a ThingSpeak channel using a Particle Photon device.<\/li>\n<\/ul>\n<p>View our <a href=\"https:\/\/www.mathworks.com\/help\/thingspeak\/mqtt-api.html\">ThingSpeak MQTT<\/a> documentation to learn more about MQTT support on ThingSpeak, and find examples for Arduino, Particle, and Raspberry Pi.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/iot\/files\/2017\/11\/thingspeak_mqtt_subscribe.png\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>The\u00a0ThingSpeak IoT\u00a0service now supports MQTT subscriptions to receive\u00a0instant updates when a ThingSpeak channel gets updated. MQTT is a powerful standard for IoT systems. ThingSpeak enables clients&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/iot\/2017\/11\/10\/subscribe-to-thingspeak-iot-data-using-mqtt\/\">read more >><\/a><\/p>\n","protected":false},"author":148,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[238],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts\/2204"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/users\/148"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/comments?post=2204"}],"version-history":[{"count":4,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts\/2204\/revisions"}],"predecessor-version":[{"id":2260,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts\/2204\/revisions\/2260"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/media?parent=2204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/categories?post=2204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/tags?post=2204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}