{"id":10763,"date":"2019-05-25T12:47:13","date_gmt":"2019-05-25T16:47:13","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=10763"},"modified":"2019-05-25T12:47:13","modified_gmt":"2019-05-25T16:47:13","slug":"thingspeak-functionality-ships-with-r2019a","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2019\/05\/25\/thingspeak-functionality-ships-with-r2019a\/","title":{"rendered":"ThingSpeak functionality ships with R2019a"},"content":{"rendered":"<div class=\"content\"><p><a href=\"http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/869871\">Jiro<\/a>&#8216;s Pick this week is <a href=\"https:\/\/jp.mathworks.com\/matlabcentral\/fileexchange\/52244\">ThingSpeak Support Toolbox<\/a> by <a href=\"https:\/\/jp.mathworks.com\/matlabcentral\/profile\/authors\/5382736\">MathWorks Internet of Things Team<\/a>.<\/p><p><a href=\"https:\/\/thingspeak.com\/\">ThingSpeak<\/a> is MathWorks&#8217; IoT platform. You can use ThingSpeak for free for non-commercial small projects, but you can also purchase a <a href=\"https:\/\/thingspeak.com\/prices\">license<\/a> with enhanced capabilities, such as the ability to send\/receive more messages at a higher frequency.<\/p><p>This Toolbox allows you to connect to ThingSpeak directly from your MATLAB to send and receive data. The Toolbox has been around for several years, and you can download this from the <a href=\"https:\/\/jp.mathworks.com\/matlabcentral\/fileexchange\">File Exchange<\/a> or from the <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/matlab_env\/get-add-ons.html\">Add-on Explorer<\/a>.<\/p><p>Great news to those who have R2019a or newer. Now, this functionality comes built in with your MATLAB! You can start interacting with ThingSpeak right away.<\/p><p>Here&#8217;s an example of reading the last 3 days&#8217; worth of data from the MathWorks Weather Station, located in Natick, MA in U.S.A. Below, the fields 2, 3, and 4 are wind speed, humidity, and temperature, respectively.<\/p><pre class=\"codeinput\">data = thingSpeakRead(12397,<span class=\"string\">'Fields'<\/span>,2:4,<span class=\"string\">'NumDays'<\/span>,3,<span class=\"string\">'OutputFormat'<\/span>,<span class=\"string\">'TimeTable'<\/span>);\r\nnumDataPoints = height(data)\r\n<\/pre><pre class=\"codeoutput\">numDataPoints =\r\n        4218\r\n<\/pre><p>Now, we&#8217;ll use <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/stackedplot.html\"><tt>stackedplot<\/tt><\/a> to visualize the 3 data sets.<\/p><pre class=\"codeinput\">stackedplot(data);\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_thingspeaktoolbox\/potw_thingspeaktoolbox_01.png\" alt=\"\"> <p><b>Comments<\/b><\/p><p>Give it a try and let us know what you think <a href=\"http:\/\/blogs.mathworks.com\/pick\/?p=10763#respond\">here<\/a> or leave a <a href=\"https:\/\/jp.mathworks.com\/matlabcentral\/fileexchange\/52244#comment\">comment<\/a>.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_3c51578959aa447dbe1d3583175c0e3c() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='3c51578959aa447dbe1d3583175c0e3c ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 3c51578959aa447dbe1d3583175c0e3c';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2019 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_3c51578959aa447dbe1d3583175c0e3c()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2019a<br><\/p><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; R2019a<br><\/p><\/div><!--\r\n3c51578959aa447dbe1d3583175c0e3c ##### SOURCE BEGIN #####\r\n%%\r\n% <http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/869871 Jiro>'s\r\n% Pick this week is\r\n% <https:\/\/jp.mathworks.com\/matlabcentral\/fileexchange\/52244 ThingSpeak\r\n% Support Toolbox> by\r\n% <https:\/\/jp.mathworks.com\/matlabcentral\/profile\/authors\/5382736 MathWorks\r\n% Internet of Things Team>.\r\n%\r\n% <https:\/\/thingspeak.com\/ ThingSpeak> is MathWorks' IoT platform. You can\r\n% use ThingSpeak for free for non-commercial small projects, but you can\r\n% also purchase a <https:\/\/thingspeak.com\/prices license> with enhanced\r\n% capabilities, such as the ability to send\/receive more messages at a\r\n% higher frequency.\r\n%\r\n% This Toolbox allows you to connect to ThingSpeak directly from your\r\n% MATLAB to send and receive data. The Toolbox has been around for several\r\n% years, and you can download this from the\r\n% <https:\/\/jp.mathworks.com\/matlabcentral\/fileexchange File Exchange> or\r\n% from the\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/matlab_env\/get-add-ons.html Add-on\r\n% Explorer>.\r\n%\r\n% Great news to those who have R2019a or newer. Now, this functionality\r\n% comes built in with your MATLAB! You can start interacting with\r\n% ThingSpeak right away.\r\n%\r\n% Here's an example of reading the last 3 days' worth of data from the\r\n% MathWorks Weather Station, located in Natick, MA in U.S.A. Below, the\r\n% fields 2, 3, and 4 are wind speed, humidity, and temperature,\r\n% respectively.\r\n\r\ndata = thingSpeakRead(12397,'Fields',2:4,'NumDays',3,'OutputFormat','TimeTable');\r\nnumDataPoints = height(data)\r\n\r\n%%\r\n% Now, we'll use\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/stackedplot.html\r\n% |stackedplot|> to visualize the 3 data sets.\r\n\r\nstackedplot(data);\r\n\r\n%%\r\n% *Comments*\r\n%\r\n% Give it a try and let us know what you think\r\n% <http:\/\/blogs.mathworks.com\/pick\/?p=10763#respond here> or leave a\r\n% <https:\/\/jp.mathworks.com\/matlabcentral\/fileexchange\/52244#comment\r\n% comment>.\r\n\r\n##### SOURCE END ##### 3c51578959aa447dbe1d3583175c0e3c\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_thingspeaktoolbox\/potw_thingspeaktoolbox_01.png\" onError=\"this.style.display ='none';\" \/><\/div><p>Jiro&#8216;s Pick this week is ThingSpeak Support Toolbox by MathWorks Internet of Things Team.ThingSpeak is MathWorks&#8217; IoT platform. You can use ThingSpeak for free for non-commercial small&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2019\/05\/25\/thingspeak-functionality-ships-with-r2019a\/\">read more >><\/a><\/p>","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10763"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=10763"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10763\/revisions"}],"predecessor-version":[{"id":10767,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10763\/revisions\/10767"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=10763"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=10763"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=10763"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}