{"id":1406,"date":"2016-12-22T00:01:31","date_gmt":"2016-12-21T23:01:31","guid":{"rendered":"http:\/\/iot.fkainka.de\/?p=1406"},"modified":"2018-10-24T16:05:10","modified_gmt":"2018-10-24T15:05:10","slug":"day22-2016","status":"publish","type":"post","link":"https:\/\/iot.fkainka.de\/en\/day22-2016","title":{"rendered":"Day 22: MQTT Cheerlights"},"content":{"rendered":"<p>Today&#8217;s trial is about MQTT and a global project that was presented last year: the Cheerlights Project by Hans Schaaler. For everyone who doesn&#8217;t know the project: It&#8217;s about globally networked coloured lights that can be simultaneously controlled through Twitter commands. Another version of this project was part of last year&#8217;s Advent calendar. This year we have the version with MQTT and expanded functions.<\/p>\n<p>Behind today&#8217;s door is a 1-kohm resistor. The layout consists of the RGB LED with series resistors and a button.<\/p>\n<div id=\"attachment_1407\" style=\"width: 626px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/iot.fkainka.de\/wp-content\/uploads\/2016\/09\/Day22_Steckplatine.jpg\"><img aria-describedby=\"caption-attachment-1407\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-1407 size-large\" src=\"http:\/\/iot.fkainka.de\/wp-content\/uploads\/2016\/09\/Day22_Steckplatine-1024x603.jpg\" alt=\"Aufbau der RGB-LED mit Button\" width=\"616\" height=\"363\" srcset=\"https:\/\/iot.fkainka.de\/wp-content\/uploads\/2016\/09\/Day22_Steckplatine-1024x603.jpg 1024w, https:\/\/iot.fkainka.de\/wp-content\/uploads\/2016\/09\/Day22_Steckplatine-300x177.jpg 300w, https:\/\/iot.fkainka.de\/wp-content\/uploads\/2016\/09\/Day22_Steckplatine-768x452.jpg 768w, https:\/\/iot.fkainka.de\/wp-content\/uploads\/2016\/09\/Day22_Steckplatine-972x572.jpg 972w, https:\/\/iot.fkainka.de\/wp-content\/uploads\/2016\/09\/Day22_Steckplatine.jpg 1107w\" sizes=\"(max-width: 616px) 100vw, 616px\" \/><\/a><p id=\"caption-attachment-1407\" class=\"wp-caption-text\">Todays layout<\/p><\/div>\n<p>Download today&#8217;s programme. Before you can transfer the programme to the NanoESP, you have to install a library. This is the Crossfade library by Radek Wierzbicki (source: <a href=\"https:\/\/github.com\/radekw\/Arduino\/tree\/5f24ce7c8db9dfbb5252b59824c3217d851b3a3c\">https:\/\/github.com\/radekw\/Arduino\/tree\/5f24ce7c8db9dfbb5252b59824c3217d851b3a3c<\/a>). For practical reasons, a copy of the library version used is contained as a ZIP file in the Sketch folder. You can easily add integrate this through the Library Manager in the Arduino IDE by selecting the ZIP directory in the Sketch folder <strong>Sketch &gt; Integrate library &gt; Integrate .ZIP library<\/strong>. Now the programme compiles, and you can upload it to the NanoESP<br \/>\n<iframe loading=\"lazy\" style=\"height: 400px; width: 100%; margin: 10px 0;\" src=\"https:\/\/create.arduino.cc\/editor\/FKainka\/b33c3b97-fee7-459f-965d-4372358fb2ff\/preview?embed\" width=\"300\" height=\"150\" frameborder=\"0\"><\/iframe><br \/>\nAfter uploading the programme, now go back to the site <a href=\"http:\/\/www.hivemq.com\/try-out\/\">www.hivemq.com\/try-out\/<\/a> and establish a connection to the <strong>broker.fkainka.de<\/strong> broker. There, with the topic<\/p>\n<p><strong>NanoESP\/MyMQTTiD\/rgb\/mode<\/strong><\/p>\n<p>you can switch the mode between Cheerlights and personal colours by publishing a 1 or a 0. It&#8217;s important that for all messages you activate the Retain check box before you send the message with the Publish button next to it on the right. Retain means something like Save because the broker stores the message. Now, as soon as a device subscribes to the topic, the saved message is sent in its entirety to the device. You can thus save states. Incidentally, the button on the breadboard likewise switches the mode using a message with Retain flag. So later on, you don&#8217;t always have to go to the Try Out site to switch the mode.<\/p>\n<p>In personal mode (mode 0), you can give the RGB LED a colour by publishing a message in the topic<\/p>\n<p><strong>NanoESP\/MyMQTTiD\/rgb\/color<\/strong><\/p>\n<p>in the form<\/p>\n<p><strong>rgb(X,X,X)<\/strong><\/p>\n<p>The X stands here respectively for a PWM value between 0 and 255. The sequence of colours is red, green, blue. So for a green colour with maximum brightness, you have to publish<\/p>\n<p><strong>rgb(0,255,0)<\/strong><\/p>\n<p>Don&#8217;t forget to check the Retain box.<\/p>\n<p>In Cheerlights mode (mode 1), the board subscribes to a topic to which the current Cheerlights colour is published. You can change this colour by composing a Twitter message and thereby changing your colour and also the colour of all other Cheerlights users. First, the message must contain #Cheerlights, @Cheerlights or simply the keyword Cheerlights; second, one of the predefined colours must come after the keyword. The predefined colours include:<\/p>\n<p>red, green, blue, cyan, white, warmwhite, purple, magenta, yellow, orange, pink<\/p>\n<p>A potential tweet thus looks like this:<\/p>\n<p><strong>Testing my #cheerlights #MQTT project on my #NanoESP with the color blue <\/strong><\/p>\n<p>You thereby give yourself and the whole world a new colour. But if you prefer your personal colours without someone else butting in, simply switch back to the personal mode, and now the LED changes back to your predefined colour.<\/p>","protected":false},"excerpt":{"rendered":"<p>Today&#8217;s trial is about MQTT and a global project that was presented last year: the Cheerlights Project by Hans Schaaler. For everyone who doesn&#8217;t know the project: It&#8217;s about globally networked coloured lights that can be simultaneously controlled through Twitter&#8230;<br \/><a class=\"read-more-button\" href=\"https:\/\/iot.fkainka.de\/en\/day22-2016\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":1407,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[123,124,311],"tags":[130,15],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Day 22: MQTT Cheerlights - Internet of Things with the NanoESP<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/iot.fkainka.de\/day22-2016\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Day 22: MQTT Cheerlights - Internet of Things with the NanoESP\" \/>\n<meta property=\"og:description\" content=\"Today&#8217;s trial is about MQTT and a global project that was presented last year: the Cheerlights Project by Hans Schaaler. For everyone who doesn&#8217;t know the project: It&#8217;s about globally networked coloured lights that can be simultaneously controlled through Twitter...Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/iot.fkainka.de\/day22-2016\" \/>\n<meta property=\"og:site_name\" content=\"Internet of Things with the NanoESP\" \/>\n<meta property=\"article:published_time\" content=\"2016-12-21T23:01:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-10-24T15:05:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/iot.fkainka.de\/wp-content\/uploads\/2016\/09\/Day22_Steckplatine.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1107\" \/>\n\t<meta property=\"og:image:height\" content=\"652\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"fk\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"fk\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/iot.fkainka.de\/day22-2016\",\"url\":\"https:\/\/iot.fkainka.de\/day22-2016\",\"name\":\"Day 22: MQTT Cheerlights - Internet of Things with the NanoESP\",\"isPartOf\":{\"@id\":\"https:\/\/iot.fkainka.de\/#website\"},\"datePublished\":\"2016-12-21T23:01:31+00:00\",\"dateModified\":\"2018-10-24T15:05:10+00:00\",\"author\":{\"@id\":\"https:\/\/iot.fkainka.de\/#\/schema\/person\/d3205fdf2649027fc35e240d4f8b285a\"},\"breadcrumb\":{\"@id\":\"https:\/\/iot.fkainka.de\/day22-2016#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/iot.fkainka.de\/day22-2016\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/iot.fkainka.de\/day22-2016#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/iot.fkainka.de\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tag 22: MQTT Cheerlights\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/iot.fkainka.de\/#website\",\"url\":\"https:\/\/iot.fkainka.de\/\",\"name\":\"Internet of Things with the NanoESP\",\"description\":\"The webpage for the Arduino compatible WiFi-Board\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/iot.fkainka.de\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/iot.fkainka.de\/#\/schema\/person\/d3205fdf2649027fc35e240d4f8b285a\",\"name\":\"fk\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/iot.fkainka.de\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/141cf958a831e66efabf9674e117e8d9?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/141cf958a831e66efabf9674e117e8d9?s=96&d=identicon&r=g\",\"caption\":\"fk\"},\"url\":\"https:\/\/iot.fkainka.de\/en\/author\/fk\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Day 22: MQTT Cheerlights - Internet of Things with the NanoESP","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/iot.fkainka.de\/day22-2016","og_locale":"en_US","og_type":"article","og_title":"Day 22: MQTT Cheerlights - Internet of Things with the NanoESP","og_description":"Today&#8217;s trial is about MQTT and a global project that was presented last year: the Cheerlights Project by Hans Schaaler. For everyone who doesn&#8217;t know the project: It&#8217;s about globally networked coloured lights that can be simultaneously controlled through Twitter...Read more","og_url":"https:\/\/iot.fkainka.de\/day22-2016","og_site_name":"Internet of Things with the NanoESP","article_published_time":"2016-12-21T23:01:31+00:00","article_modified_time":"2018-10-24T15:05:10+00:00","og_image":[{"width":1107,"height":652,"url":"https:\/\/iot.fkainka.de\/wp-content\/uploads\/2016\/09\/Day22_Steckplatine.jpg","type":"image\/jpeg"}],"author":"fk","twitter_card":"summary_large_image","twitter_misc":{"Written by":"fk","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/iot.fkainka.de\/day22-2016","url":"https:\/\/iot.fkainka.de\/day22-2016","name":"Day 22: MQTT Cheerlights - Internet of Things with the NanoESP","isPartOf":{"@id":"https:\/\/iot.fkainka.de\/#website"},"datePublished":"2016-12-21T23:01:31+00:00","dateModified":"2018-10-24T15:05:10+00:00","author":{"@id":"https:\/\/iot.fkainka.de\/#\/schema\/person\/d3205fdf2649027fc35e240d4f8b285a"},"breadcrumb":{"@id":"https:\/\/iot.fkainka.de\/day22-2016#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/iot.fkainka.de\/day22-2016"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/iot.fkainka.de\/day22-2016#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/iot.fkainka.de\/"},{"@type":"ListItem","position":2,"name":"Tag 22: MQTT Cheerlights"}]},{"@type":"WebSite","@id":"https:\/\/iot.fkainka.de\/#website","url":"https:\/\/iot.fkainka.de\/","name":"Internet of Things with the NanoESP","description":"The webpage for the Arduino compatible WiFi-Board","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/iot.fkainka.de\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/iot.fkainka.de\/#\/schema\/person\/d3205fdf2649027fc35e240d4f8b285a","name":"fk","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/iot.fkainka.de\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/141cf958a831e66efabf9674e117e8d9?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/141cf958a831e66efabf9674e117e8d9?s=96&d=identicon&r=g","caption":"fk"},"url":"https:\/\/iot.fkainka.de\/en\/author\/fk"}]}},"jetpack_featured_media_url":"https:\/\/iot.fkainka.de\/wp-content\/uploads\/2016\/09\/Day22_Steckplatine.jpg","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6McI0-mG","_links":{"self":[{"href":"https:\/\/iot.fkainka.de\/en\/wp-json\/wp\/v2\/posts\/1406"}],"collection":[{"href":"https:\/\/iot.fkainka.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iot.fkainka.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iot.fkainka.de\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/iot.fkainka.de\/en\/wp-json\/wp\/v2\/comments?post=1406"}],"version-history":[{"count":3,"href":"https:\/\/iot.fkainka.de\/en\/wp-json\/wp\/v2\/posts\/1406\/revisions"}],"predecessor-version":[{"id":1538,"href":"https:\/\/iot.fkainka.de\/en\/wp-json\/wp\/v2\/posts\/1406\/revisions\/1538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/iot.fkainka.de\/en\/wp-json\/wp\/v2\/media\/1407"}],"wp:attachment":[{"href":"https:\/\/iot.fkainka.de\/en\/wp-json\/wp\/v2\/media?parent=1406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iot.fkainka.de\/en\/wp-json\/wp\/v2\/categories?post=1406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iot.fkainka.de\/en\/wp-json\/wp\/v2\/tags?post=1406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}