{"id":6301,"date":"2020-06-09T08:59:18","date_gmt":"2020-06-09T14:59:18","guid":{"rendered":"http:\/\/gregsowell.com\/?p=6301"},"modified":"2020-06-09T08:59:18","modified_gmt":"2020-06-09T14:59:18","slug":"esp8266-wemos-to-control-ws2812-neopixels","status":"publish","type":"post","link":"https:\/\/gregsowell.com\/?p=6301","title":{"rendered":"ESP8266 Wemos To Control WS2812 Neopixels"},"content":{"rendered":"<p><a href=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/wemos.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/wemos.png\" alt=\"\" width=\"338\" height=\"210\" class=\"aligncenter size-full wp-image-6311\" srcset=\"https:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/wemos.png 338w, https:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/wemos-300x186.png 300w\" sizes=\"auto, (max-width: 338px) 100vw, 338px\" \/><\/a><br \/>\n<a href=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/20200609_095229.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/20200609_095229-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" class=\"aligncenter size-medium wp-image-6310\" srcset=\"https:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/20200609_095229-300x225.jpg 300w, https:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/20200609_095229-768x576.jpg 768w, https:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/20200609_095229-1024x768.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>First a big shout out to <a href=\"https:\/\/projects.digilentinc.com\/wirekraken\/esp8266-websockets-and-ws2812b-leds-c2dee8\">this link<\/a>, which provided me the tools to get started.<\/p>\n<p>The instructions there under requirements give you the first steps.  First you add the ESP8266 <a href=\"https:\/\/github.com\/esp8266\/arduino-esp8266fs-plugin?_ga=2.140224369.394769918.1591712710-207831958.1591712710\">file uploader plugin to the Arduino IDE<\/a>.  This allows you to add new files the webserver can utilize.<\/p>\n<p>Next you need to install the awesome WebSockets library.<br \/>\nType Ctl+shift+i.  This pulls up the library manager.  From here you type websockets and choose ArduinoWebsockets by Gil Maimon.<br \/>\n<a href=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/websockets.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/websockets-300x169.png\" alt=\"\" width=\"300\" height=\"169\" class=\"aligncenter size-medium wp-image-6302\" srcset=\"https:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/websockets-300x169.png 300w, https:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/websockets-768x433.png 768w, https:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/websockets.png 799w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Next you need to grab the FastLed library from the library manager just like above.<\/p>\n<p>Add the ESP8266 package from the library manager.<\/p>\n<p>Now grab the <a href=\"https:\/\/github.com\/wirekraken\/ESP8266-Websockets-LED?_ga=2.132287436.394769918.1591712710-207831958.1591712710\">code from here<\/a>.  This is a great set of webserver files that are uploaded with the ESP8266 uploader and the ardunio sketches to be modified and uploaded.<\/p>\n<p>Now open the ESP-8266.ino arduino IDE file found in the above github.  First issue I hit was that I needed to change the flash size of my esp8266 in the IDE.  So I choose generic ESP8266, then set the flash size as shown, and last clicked upload.  This will get the webserver files in place.<br \/>\n<a href=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/upload-wemos.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/upload-wemos-221x300.png\" alt=\"\" width=\"221\" height=\"300\" class=\"aligncenter size-medium wp-image-6303\" srcset=\"https:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/upload-wemos-221x300.png 221w, https:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/upload-wemos.png 498w\" sizes=\"auto, (max-width: 221px) 100vw, 221px\" \/><\/a><\/p>\n<p>Once the files are uploaded you should modify the IP address, wifi, pixel count, and pixel control pin info.<br \/>\n<a href=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/ide-info.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/ide-info-300x80.png\" alt=\"\" width=\"300\" height=\"80\" class=\"aligncenter size-medium wp-image-6305\" srcset=\"https:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/ide-info-300x80.png 300w, https:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/ide-info-768x204.png 768w, https:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/ide-info.png 879w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>If you are controlling more than 255 LEDs like me, you have to modify the code, otherwise it will crash on you.  In the led_effects.ino file, several variables are defined as uint8_t format which is an 8 bit number, which means it maxes out at 255.  I modified the following:<\/p>\n<pre class=\"gs-code\"><code class=\"language-plaintext\">\/\/these are all towards the top\r\n\/\/uint8_t idex = 0; \/\/\u0438\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f    \r\nuint16_t idex = 0; \/\/\u0438\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f    \r\n\/\/uint16_t TOP_INDEX = uint8_t(LED_COUNT \/ 2); \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0443 \u043b\u0435\u043d\u0442\u044b\r\nuint16_t TOP_INDEX = LED_COUNT \/ 2; \/\/ find the middle\r\n\r\n\/\/  for(uint8_t i = 0 ; i &lt; LED_COUNT; i++ ){\r\n  for(uint16_t i = 0 ; i &lt; LED_COUNT; i++ ){<\/code><\/pre>\n<p><a href=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/code-adjust.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/code-adjust-300x205.png\" alt=\"\" width=\"300\" height=\"205\" class=\"aligncenter size-medium wp-image-6307\" srcset=\"https:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/code-adjust-300x205.png 300w, https:\/\/gregsowell.com\/wp-content\/uploads\/2020\/06\/code-adjust.png 699w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nAs you can see I changed then from 8 bit to 16 bit numbers which allows for 65k pixels&#8230;way more than this little micro can reasonably control.<\/p>\n<p>Good luck and happy lighting.  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>First a big shout out to this link, which provided me the tools to get started. The instructions there under requirements give you the\u2026<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[45,28],"tags":[],"class_list":["post-6301","post","type-post","status-publish","format-standard","hentry","category-arduino","category-fun"],"_links":{"self":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/6301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6301"}],"version-history":[{"count":7,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/6301\/revisions"}],"predecessor-version":[{"id":6314,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/6301\/revisions\/6314"}],"wp:attachment":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}