How to build a WS2812B LED strip with ESP8266 NodeMCU?

All the more reason NOT to connect the 3.3V line (red)! You can keep green (Signal) and white (Gnd) connected if you want to keep the NodeMCU powered off the USB port, but if you connect the 12v line to your 3.3v regulator, bad things will happen (you’ll let the smoke out!).

1 Like

Part 2 (Software load) of the how-to now up!

I’ll be working on part 3 (incorporating the controllers into OH) next!

That is so cool! I just got a notification of delivery for some new NodeMCU V1.0 I ordered last week. I’ll follow your instructions and see where it leads me.
Thanks again for all the work you put in…
JD

I just ordered 10 WEMOS mini instead of the nodemcu, slightly cheaper : 2.6USD per piece and they are smaller. Then I ordered 4-12v to 3.3v regulator boards, so that the Wemos can be powered of the led power supply. A shield to wire them together is on my todo list… If anyone knows where I can order PCB mounted version of the jst connector let me know…

@bartus Here is my suggestion that a breakout board should contain:

It seems like the 3.3V its not enough to drive ws2811,so we need level converters.

So the breakout board should have :

  1. JST connector for led strip(PCB mount would be nice)
  2. Screw terminal for ± 5-12v Input
  3. Screw terminal for output ± equal input voltage
  4. Voltage regulator 4-12Vdcc to 3.3V to power wemos
  5. 1000uF diode on output screw terminal to protect first led
  6. Level converter for d4 output, to trigger off/on state
  7. screw terminal for external switch
  8. internal switch, to trigger off/on state(long press change scenes or sth…)
  9. Led indicator for MQTT, Power and WIFI (Wemos have 1 led built in, we could use solidlight all OK, fast blinking WIFI issues, slow blinking MQTT,

The breakoutboard should fit wemos and not nodemcu to make it smaller, or we could just design a board with the esp on it…

Any things I am missing?

1 Like

All, I’ve uploaded part 3 of the How-to, this time focusing on the openHAB configuration, here: Part 3

I’ve also started a separate topic with the OH config items, so I can easily link to it on other sites/forum posts: NodeMCU MQTT LED Strip Controller Build & Config How-To Videos

@skatun thanks again for the PCB redesign ideas - I think it warrants a separate project (i.e. I think trying to fit all that on the current PCB and keep it universal would probably not work). I do want to play with my Wemos boards and find out if I can minimize the LED controller even more, so that’s definitely on the to-do list!

Thanks for that last part. Now I have to put all of that together! I just realized that the only easy part about home automation with Openhab, is the actual installation of the Openhab server. The rest is kind of tricky. Thanks again for all the help!

JD

Haha, I think we’ve all realized that at some point or another - sometimes this feels more like a second job when I get home and less like a hobby :wink:

Don’t worry though - you will get the hang of it. My suggestion would be to start with the Demo configuration - there’s enough there to start with. Just comment out the stuff you don’t need yet, and change the sitemaps/rules and items to match your setup as time goes on. Also, definitely install the tail log viewer (from openhabian) so you can have the log open and scrolling live as you experiment (you’ll start seeing how the different pieces in OH interact, and also catch any errors that might be preventing your stuff from working).

Lastly, this forum is full of helpful people who won’t hesitate to answer any question (and won’t make you feel like a noob at that).

True! I just don’t know where to start. I got 2 Sonoffs relay thingy, 30 feet of RGB ws2812b led strip and many NodeMCU and 1 TPLink smart light switch on the way from amazon. I would love to be able to hook up all of that and make it work. I’m going to go through all the tutorials and beginners link I can find.

thank again

JD

Hey Bartus, firstly thank you for your guides, videos, designs and overall excellent hard work on this. I have ordered 5 of the recommended NodeMCU from Aliexpress, 10 of your riser from PCBWay and 1 BTF 5m 30 LED strip from Amazon (Will expand up to 10 of everything once I have one working).

It’ll take about a month for everything to get to me in the UK but I have 2 questions whilst I’m waiting if you could assist?

For the DC adapter connector, is it this type? MALAYAS 5.5x2.1mm DC Power Connector Male Female 12V that I’m looking for?

And secondly for your 3D printed enclosure, do you know if there is a UK based printing company I could use or will I have to have them printed in the US and shipped here? I’ve only bought 1 3D printed thing and that was from etsy, so not too up on how it works.

Thanks!

Daryl.

Thank you for the kind words!! I love sharing my work and seeing others using it! :slight_smile:

You’ve got the correct connector (DC plug) - don’t forget to tin the wires, as they seem to sit more snug in the terminal block rather than pull out.

As for getting the enclosure 3d printed, you have several options. The best/cheapest would be to find a local “maker” or “hacker” space, download the STL files from my Thingiverse page and have them print it for you. They should only charge you for the price of the plastic (for reference, a 1Kg roll costs ~$20 and could print at least 20 of these) and maybe for printer time, depending on the place. Option 2 would be to find someone local on 3dhubs.com or makexyz.com (but don’t let them charge you more than ~$10, this is a very easy print).

If you have problems getting it printed locally, let me know - I can do it for you for the cost of shipping and an adult beverage! :slight_smile:

Enjoy and let me know how you make out with this, looking forward to seeing some photos of pretty LEDs!

-B.K.

Fantastic thank you, I’ll take a look around and see what I can find. The waiting on the shipping will be the hardest part for now… if only we had teleporters haha.

@bartus Awesome work!

Can anyone here help with a problem I have with an ESP32 instead of an ESP8266? I am using bartuses code, and it works fine on a ESP8266 that I have (just some of the effects don’t seem to work). I have now tried porting the code to an ESP32, because I have a few of them lying around, and the devices crashes in a loop. I haven’t changed much on the code side, just the imports for Wifi and mDNS:

ESP8266:

#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include "FastLED.h"
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

ESP32:

#include <ArduinoJson.h>
#include <WiFi.h>
#include <PubSubClient.h>
#include "FastLED.h"
#include <ESPmDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

The program of course compiles just fine.

I then see the following in the console over and over and over again:

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:956
load:0x40078000,len:0
load:0x40078000,len:13076
entry 0x40078a58

Connecting to pwlan
.......
WiFi connected
IP address: 
192.168.2.123
Ready
IP Address: 192.168.2.123
Attempting MQTT connection...connected
Setting LEDs:
r: 0, g: 0, b: 0
Guru Meditation Error: Core  0 panic'ed (Interrupt wdt timeout on CPU0)
Register dump:
PC      : 0x40085b7b  PS      : 0x00060034  A0      : 0x80086545  A1      : 0x3ffc0510  
A2      : 0x3ffc1128  A3      : 0x3ffc0588  A4      : 0x00000008  A5      : 0x3ffd4bc4  
A6      : 0x00000017  A7      : 0x00000000  A8      : 0x0000abab  A9      : 0x0000cdcd  
A10     : 0xb33fffff  A11     : 0x0000abab  A12     : 0x00000000  A13     : 0x00000001  
A14     : 0x00060023  A15     : 0x00000000  SAR     : 0x0000001e  EXCCAUSE: 0x00000005  
EXCVADDR: 0x00000000  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0xffffffff  

Backtrace: 0x40085b7b:0x3ffc0510 0x40086542:0x3ffc0530 0x400850c1:0x3ffc0550 0x40084482:0x3ffc0570 0x400843cd:0x3ffc05c0 0x400849ae:0x3ffc05e0 0x40081625:0x3ffc0610 0x400e310b:0x00000000

Does anyone have any idea?

It looks like you’re hitting the watchdog timer (wdt) and the ESP32 is resetting…I wonder if the libraries you’re using may have different behavior on the ESP32 (I do have one, but haven’t tried it out on this code myself, yet)…let me look at what mine does and get back to you.

Hey @bartus - Thanks for your write up on this topic, despite a few setbacks I have now my first LEDs set up on my shelving controlled through OH :laughing:

One thing I am unsure about though is the status of the items in OH - For example when you change the effect, it does not update on the UI, same with the intensity and the speed. Being very new to OH I am still trying to feel my way around, but is it possible to publish the status of the LEDS to the MQTT server each time a button is pressed so it updates? Is it a just a case of adding the subscribe topic to the item line?

For the FX for example, I tried this:

Number tvledright_fx "TV LEDs Right Fx" {mqtt=">[broker:home/leds/tvright/set:command:*:MAP(leds.map)],<[broker:home/leds/tvright/fx:state:default:*:MAP(leds.map)]" }

Where state topic is “home/leds/tvright” and set topic is “home/leds/tvright/set”, but it doesn’t seem to work, does the mapping function work with both pub and sub?

Any pointers would be appreciated!

The map should work both ways, but the status string doesn’t contain the effect (it’s only sent out), You can pull out brightness/speed from the MQTT message, but need to update the item MQTT path, to access just that value. Try:

Number tvledright_brightness "TV LEDs Right Brightness" {mqtt="<[broker:home/leds/tvright:state:JSONPATH($.brightness)]" }

Since the MQTT status topic is a multi-line set of status items, and we need to pull out only the current brightness, the JSONPATH will pull that out.

That said, I never did this for my items - they seem to update whenever I make a change in my GUI/app. Are you making changes to the items via rules or something? Sending a “postUpdate” at the end of the rule should modify the status item…

Thanks for the reply, having a play around in the items/sitemap files and can get the number to appear as you described, but that also doesn’t update in the GUI, tried 3 separate devices and does the same on each of them - No changes to items or rules except from what is in your examples!

Ah, just the text shows? I think I know what the problem is there, you just need to format it into the item. So, for example:

Number tvledright_brightness "TV LEDs Right Brightness [%d]" {mqtt="<[broker:home/leds/tvright:state:JSONPATH($.brightness)]" }

That should format it as a number, and adjust the item state with it.

If that doesn’t work, I’d say the next thing to do would be to write a handler rule, based on the MQTT input string updating, and explicitly set the state for each item as you parse it out of the JSON string…

Did you get it working?

No, I didn’t. Easiest way was to just use an ESP8266 instead. There probably is a way to make it work with an ESP32, but I don’t really see the point for me. The 8266 is cheaper, and I don’t need the extra “horse power” and bluetooth for my LED controller.