{"id":2567,"date":"2018-12-19T00:00:35","date_gmt":"2018-12-18T23:00:35","guid":{"rendered":"https:\/\/iot.fkainka.de\/?p=2567"},"modified":"2018-11-21T16:38:09","modified_gmt":"2018-11-21T15:38:09","slug":"day19-2018","status":"publish","type":"post","link":"https:\/\/iot.fkainka.de\/en\/day19-2018","title":{"rendered":"Day 19: CheerLights"},"content":{"rendered":"<p>Today we have a very special LED waiting behind the door. It is an RGB LED with integrated controller (type PL9823, equivalent to WS2812) and with it you can now connect several LEDs in series and control them individually by means of a protocol. Today we will start by controlling one LED only. Here, an experiment that is almost customary in my Advent calendars fits in handy: the CheerLights project by Hans Schaaler. For all those who do not yet know the project: these are globally linked colourful lights which can be controlled simultaneously via Twitter commands. And here Node-RED fits in very well. The experiment today requires the following setup besides the program of today.<\/p>\n<div id=\"attachment_2568\" style=\"width: 526px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/iot.fkainka.de\/wp-content\/uploads\/2018\/11\/Day19_WS2812_Steckplatine.png\"><img aria-describedby=\"caption-attachment-2568\" decoding=\"async\" loading=\"lazy\" class=\" wp-image-2568\" src=\"https:\/\/iot.fkainka.de\/wp-content\/uploads\/2018\/11\/Day19_WS2812_Steckplatine-827x1024.png\" alt=\"So wird die PL9823 richtig angeschlossen (lange Beinchen rechts).\" width=\"516\" height=\"638\" data-id=\"2568\" srcset=\"https:\/\/iot.fkainka.de\/wp-content\/uploads\/2018\/11\/Day19_WS2812_Steckplatine-827x1024.png 827w, https:\/\/iot.fkainka.de\/wp-content\/uploads\/2018\/11\/Day19_WS2812_Steckplatine-242x300.png 242w, https:\/\/iot.fkainka.de\/wp-content\/uploads\/2018\/11\/Day19_WS2812_Steckplatine-768x951.png 768w, https:\/\/iot.fkainka.de\/wp-content\/uploads\/2018\/11\/Day19_WS2812_Steckplatine.png 879w\" sizes=\"(max-width: 516px) 100vw, 516px\" \/><\/a><p id=\"caption-attachment-2568\" class=\"wp-caption-text\">A proper connected PL9823 (long legs right)<\/p><\/div>\n<p>The LED is controlled by a set of commands. It is activated by the term <strong>Pixel<\/strong>. But first and foremost, we will learn today how we control all LEDs of the same colour as we are dealing with only one LED. In one of the coming experiments we will explain all the commands that can be used for\u00a0assigning individual colours to the LEDs.<\/p>\n<table width=\"404\">\n<tbody>\n<tr>\n<td width=\"214\"><strong>Command in topic<\/strong><\/td>\n<td width=\"190\"><strong>Settings<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"214\">{&#8220;cmd&#8221;:&#8221;set_pixel_hex&#8221;,&#8221;value&#8221;:&#8221;#FFFFFF&#8221;}<\/td>\n<td width=\"190\">Sets all LEDs to the HEX colour value.<\/td>\n<\/tr>\n<tr>\n<td width=\"214\">{&#8220;cmd&#8221;:&#8221;set_pixel_rgb&#8221;,&#8221;value&#8221;:&#8221;rgb(255,255,255)&#8221;}<\/td>\n<td width=\"190\">Sets all LEDs to the RGB colour value.<\/td>\n<\/tr>\n<tr>\n<td width=\"214\">{&#8220;cmd&#8221;:&#8221;set_pixel_hsv&#8221;,&#8221;value&#8221;:&#8221;hsv(120, 100%,100%)&#8221;}<\/td>\n<td width=\"190\">Sets all LEDs to the HSV colour value.<\/td>\n<\/tr>\n<tr>\n<td width=\"214\">{&#8220;cmd&#8221;:&#8221;get_pixel_hex&#8221;}<\/td>\n<td rowspan=\"3\" width=\"190\">Displays current colour in the appropriate format, returns automatically when a colour is set.<\/td>\n<\/tr>\n<tr>\n<td width=\"214\">{&#8220;cmd&#8221;:&#8221;get_pixel_rgb&#8221;}<\/td>\n<\/tr>\n<tr>\n<td width=\"214\">{&#8220;cmd&#8221;:&#8221;get_pixel_hsv&#8221;}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The CheerLights project has a website (<strong><a href=\"https:\/\/cheerlights.com\/\">https:\/\/cheerlights.com\/<\/a><\/strong>) where you can get some information about the project. Moreover, one of the subpages, <strong>Cheerlights API<\/strong>, has a bunch of options of how to obtain the actual colour value. We are using here the interface <strong><a href=\"http:\/\/api.thingspeak.com\/channels\/1417\/field\/2\/last.json\">http:\/\/api.thingspeak.com\/channels\/1417\/field\/2\/last.json <\/a><\/strong>which offers the current value as JSON value and in HEX format.<\/p>\n<div id=\"attachment_2569\" style=\"width: 631px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/iot.fkainka.de\/wp-content\/uploads\/2018\/11\/T19Flow.png\"><img aria-describedby=\"caption-attachment-2569\" decoding=\"async\" loading=\"lazy\" class=\" wp-image-2569\" src=\"https:\/\/iot.fkainka.de\/wp-content\/uploads\/2018\/11\/T19Flow.png\" alt=\"Der heutige Flow\" width=\"621\" height=\"171\" data-id=\"2569\" srcset=\"https:\/\/iot.fkainka.de\/wp-content\/uploads\/2018\/11\/T19Flow.png 830w, https:\/\/iot.fkainka.de\/wp-content\/uploads\/2018\/11\/T19Flow-300x82.png 300w, https:\/\/iot.fkainka.de\/wp-content\/uploads\/2018\/11\/T19Flow-768x211.png 768w\" sizes=\"(max-width: 621px) 100vw, 621px\" \/><\/a><p id=\"caption-attachment-2569\" class=\"wp-caption-text\">Today&#8217;s Flow<\/p><\/div>\n<p><iframe style=\"border: none; width: 100%;\" src=\"https:\/\/pastebin.com\/embed_iframe\/4kkx6Zs2\"><\/iframe>In terms of today\u2019s flow, we just need to refresh this page every few seconds and extract the current value. It checks, if the value has changed. If so, the new colour is sent to the board. You can also configure the Twitter node with your Twitter data, if you have a Twitter account. The node will search for tweets with cheerlights text and reads the message to the GUI, where it is displayed.<\/p>\n<p>But how can you change the colour?\u00a0 That is simple. Publish a Twitter message and by that change your colour and the colour of all other Cheerlights users. Basically, the message must contain <strong>#Cheerlights, @ Cheerlights<\/strong> or just the keyword <strong>Cheerlights<\/strong> followed by one of the predefined colours. The predefined colours include:<\/p>\n<p><strong>red, green, blue, cyan, white, warm white, purple, magenta, yellow, orange, pink<\/strong><\/p>\n<p>A tweet could look like this:<\/p>\n<p><strong>Testing my #cheerlights project on my #NodeESP with the colour blue. <\/strong><\/p>\n<p>And by that you have just given yourself and the world a new colour.<\/p>","protected":false},"excerpt":{"rendered":"<p>Today we have a very special LED waiting behind the door. It is an RGB LED with integrated controller (type PL9823, equivalent to WS2812) and with it you can now connect several LEDs in series and control them individually by&#8230;<br \/><a class=\"read-more-button\" href=\"https:\/\/iot.fkainka.de\/en\/day19-2018\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":2568,"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":[315,312,313],"tags":[],"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 19: 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\/day19-2018\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Day 19: CheerLights - Internet of Things with the NanoESP\" \/>\n<meta property=\"og:description\" content=\"Today we have a very special LED waiting behind the door. It is an RGB LED with integrated controller (type PL9823, equivalent to WS2812) and with it you can now connect several LEDs in series and control them individually by...Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/iot.fkainka.de\/day19-2018\" \/>\n<meta property=\"og:site_name\" content=\"Internet of Things with the NanoESP\" \/>\n<meta property=\"article:published_time\" content=\"2018-12-18T23:00:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-11-21T15:38:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/iot.fkainka.de\/wp-content\/uploads\/2018\/11\/Day19_WS2812_Steckplatine.png\" \/>\n\t<meta property=\"og:image:width\" content=\"879\" \/>\n\t<meta property=\"og:image:height\" content=\"1089\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/iot.fkainka.de\/day19-2018\",\"url\":\"https:\/\/iot.fkainka.de\/day19-2018\",\"name\":\"Day 19: CheerLights - Internet of Things with the NanoESP\",\"isPartOf\":{\"@id\":\"https:\/\/iot.fkainka.de\/#website\"},\"datePublished\":\"2018-12-18T23:00:35+00:00\",\"dateModified\":\"2018-11-21T15:38:09+00:00\",\"author\":{\"@id\":\"https:\/\/iot.fkainka.de\/#\/schema\/person\/d3205fdf2649027fc35e240d4f8b285a\"},\"breadcrumb\":{\"@id\":\"https:\/\/iot.fkainka.de\/day19-2018#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/iot.fkainka.de\/day19-2018\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/iot.fkainka.de\/day19-2018#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/iot.fkainka.de\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tag 19: 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 19: 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\/day19-2018","og_locale":"en_US","og_type":"article","og_title":"Day 19: CheerLights - Internet of Things with the NanoESP","og_description":"Today we have a very special LED waiting behind the door. It is an RGB LED with integrated controller (type PL9823, equivalent to WS2812) and with it you can now connect several LEDs in series and control them individually by...Read more","og_url":"https:\/\/iot.fkainka.de\/day19-2018","og_site_name":"Internet of Things with the NanoESP","article_published_time":"2018-12-18T23:00:35+00:00","article_modified_time":"2018-11-21T15:38:09+00:00","og_image":[{"width":879,"height":1089,"url":"https:\/\/iot.fkainka.de\/wp-content\/uploads\/2018\/11\/Day19_WS2812_Steckplatine.png","type":"image\/png"}],"author":"fk","twitter_card":"summary_large_image","twitter_misc":{"Written by":"fk","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/iot.fkainka.de\/day19-2018","url":"https:\/\/iot.fkainka.de\/day19-2018","name":"Day 19: CheerLights - Internet of Things with the NanoESP","isPartOf":{"@id":"https:\/\/iot.fkainka.de\/#website"},"datePublished":"2018-12-18T23:00:35+00:00","dateModified":"2018-11-21T15:38:09+00:00","author":{"@id":"https:\/\/iot.fkainka.de\/#\/schema\/person\/d3205fdf2649027fc35e240d4f8b285a"},"breadcrumb":{"@id":"https:\/\/iot.fkainka.de\/day19-2018#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/iot.fkainka.de\/day19-2018"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/iot.fkainka.de\/day19-2018#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/iot.fkainka.de\/"},{"@type":"ListItem","position":2,"name":"Tag 19: 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\/2018\/11\/Day19_WS2812_Steckplatine.png","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6McI0-Fp","_links":{"self":[{"href":"https:\/\/iot.fkainka.de\/en\/wp-json\/wp\/v2\/posts\/2567"}],"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=2567"}],"version-history":[{"count":3,"href":"https:\/\/iot.fkainka.de\/en\/wp-json\/wp\/v2\/posts\/2567\/revisions"}],"predecessor-version":[{"id":2572,"href":"https:\/\/iot.fkainka.de\/en\/wp-json\/wp\/v2\/posts\/2567\/revisions\/2572"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/iot.fkainka.de\/en\/wp-json\/wp\/v2\/media\/2568"}],"wp:attachment":[{"href":"https:\/\/iot.fkainka.de\/en\/wp-json\/wp\/v2\/media?parent=2567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iot.fkainka.de\/en\/wp-json\/wp\/v2\/categories?post=2567"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iot.fkainka.de\/en\/wp-json\/wp\/v2\/tags?post=2567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}