How to build a WS2812B LED strip with ESP8266 NodeMCU?

@skatun and @jdenommee - I’ve got a quick overview of the breakout board (https://youtu.be/cJbiTxJr2iA) and part 1 (hardware build) of the LED controller how-to (https://youtu.be/WNp4G49tkrQ) done - would appreciate any comments (bad ones, too!) as this is my first try at making proper Youtube videos and editing.

I already have part 2 (Arduino software load) done, but haven’t gotten through editing yet…

Thanks!

Nice breakout board! Can I order some? The only thing i would like to modify is to have a voltage regulator built into the shield for us who uses 12v ledstrip, and screw terminals would maybe make it easier to connect the 5 wires(12V+,12V-,Signal,5V+,GND)

I will see if I can get one up running tonight…

Can’t wait!!! As a non-programmer and total newbie to home automation, it’s great to have that type of resources online and a community like this one. I went with Openhab because I had in mind that I wanted to create my own smart devices. It’s not has easy with all the different protocols and device types.

Also, it’s easier to justify to my wife all the equipment and micro-controllers I buy if it’s on a project like this one that will make her life easier.

thank for the good work.

JD

Thanks a lot for everything you’ve posted. I’ve gotten my led strips installed and working perfectly with openhab using your code and instructions. My question now is if I have several of these how do I setup the group option in your code? again thanks a lot for everything

excuse me for not reading every post in this thread, but i figured i’d chime in with 1 more option.
espeasy is a neat little software set for the esp that allows you to do all sorts of things once installed. it has a rules setup you can use to run your RGB LEDs. Here’s an example of a rule I have that sets my lights to valentine’s day colors
3 strips of 3 LEDs:

on valentine do
SendToHTTP 192.168.3.71,80,/control?cmd=event,valentine
neopixelline,1,3,255,0,0
neopixelline,4,6,148,0,211
neopixelline,7,9,255,105,180
endon

the second line sends the same command to another esp on the other side of the kitchen to do the same.

sending commands to it is as easy as: http://IP/control?cmd=event,valentine which can be done from OH super easy.

that’s it.

@skatun, yes, you can order it! I’ve shared it on PCBWay (https://goo.gl/U2fY7y) - they’re much cheaper than OSHPark (I got them for about $1/board delivered), but do take about 3 weeks to arrive…the quality is top-notch, though! I get a 10% commission on any orders, full disclosure :slight_smile:

Great idea on the 12v regulator, I think I could add a 7805 and some terminals - if the regulator was on the board, you could still just use the 3 wire JST cable (bring in 12V and Gnd from the strip/PS, and send out 5V on the signal line). Let me see if I can squeeze all that into the current board (it’s getting crowded and I’m trying to keep it universal enough for all my applications :slight_smile:) or make a separate rev. For the time being, I hook up my 12V strips via this: http://amzn.to/2GCtpLk (12V to 5V DC/DC converter, 12V comes from the LED strip power supply, 5V goes to the NodeMCU 5V/Gnd pins). Not ideal and another point in the connection, but it works just fine.

@jdenommee so true! I started out in HA only a few years ago and went through a couple other “open-____” projects out there, but once I found openHAB and the thriving community on this forum, I was set!

Make sure you get your wife a working HVAC controller - that seems to be the thing that sold home automation to my wife (she loves being able to nudge the temp up/down a few degrees while sitting on the couch watching TV) :smiley:

Thank you for the kind words, I’m glad I’m able to contribute something of my own to the open source community!

-BK

1 Like

@erickk Awesome!! I’m glad my instructions and code worked for you!

For the group, just treat it as another set of items/sitemap/rules and a separate MQTT topic (i.e. ONE command to MANY strips). All of the strips that subscribe to that group’s MQTT topic will act on whatever command you send to it.

So, say you have ledstrip1 and ledstrip2, and you want to group them together (e.g. “group_kitchen”). You’d create two sets of the items/sitemap/rules entries above for the individual strips, PLUS a third set, for the group topic:

.items file:

String LEDStrip_Group1 "Group 1 LED Strips String" {mqtt=">[broker:home/group_kitchen/set:state:*:default]"}
Switch LEDStrip_Group1_Power "Group 1 LED Strips Power" (Status){mqtt=">[broker:home/group_kitchen/set:command:*:MAP(LEDStripEffectJSON.map)]"}
Number LEDStrip_Group1_FX "Group 1 LED Strips Fx" (Status){mqtt=">[broker:home/group_kitchen/set:command:*:MAP(LEDStripEffectJSON.map)]"}
Color LEDStrip_Group1_Color "Group 1 LED Strips Color"	<rgb>	(Status)
Number LEDStrip_Group1_Speed "Group 1 LED Strips Speed [%.0f]"		(Status)
Number LEDStrip_Group1_Intensity "Group 1 LED Strips Intensity [%d]" (Status)

.sitemap:

				Switch item=LEDStrip_Group1_Power
				Selection item=LEDStrip_Group1_FX mappings=[1="BPM",2="Noise",3="Fire",4="Rainbow",5="Twinkle",6="Glitter",7="Solid",8="Sinelon",9="Juggle",10="Confetti",11="Dots",12="Lightning",13="Candy Cane",14="Cyclon Rainbow",15="Ripple",16="Christmas Alternate",17="Police All",18="Police One",19="Random Stars",20="Sine Hue"]
				Colorpicker item=LEDStrip_Group1_Color
				Setpoint item=LEDStrip_Group1_Speed minValue=5 maxValue=240 step=5
				Setpoint item=LEDStrip_Group1_Intensity minValue=0 maxValue=255 step=16

.rules:

rule "LED Strip Group 1 (Kitchen) JSON Color"
when Item LEDStrip_Group1_Color received update
then LEDStrip_Group1.sendCommand("{\"color\": {" + 
		"\"r\": " + (LEDStrip_Group1_Color.state as HSBType).red + "," +
		"\"g\": " + (LEDStrip_Group1_Color.state as HSBType).green + "," +
		"\"b\": " + (LEDStrip_Group1_Color.state as HSBType).blue + "}}") end

rule "LED Strip Group 1 (Kitchen) JSON Speed"
when Item LEDStrip_Group1_Speed received update
then LEDStrip_Group1.sendCommand("{\"transition\": \"" + LEDStrip_Group1_Speed.state + "\"}") end

rule "LED Strip Group 1 (Kitchen) JSON Intensity"
when Item LEDStrip_Group1_Intensity received update
then LEDStrip_Group1.sendCommand("{\"brightness\":" + LEDStrip_Group1_Intensity.state + "}") end

If you don’t need to set single strips individually, you can get away with just the group topic/items/sitemap/rules.

The benefit of using a group topic to send commands is that the MQTT broker sets the topic once, and all strips immediately get the update, as opposed to individual updates, where the broker will set each strip’s topic one-by-one and there will be a delay before each strip gets an update. I was also noticing dropouts where some of my 10+ strips were not getting an update at all, leaving half the strips on one effect and the rest on another…).

Let me know if you have any issues getting this set up - I may do a special how-to video just on the group setup.

-BK

Ok got it! Thanks a lot!

I am working on a generic group light tutorial, its almost done. Just some more testing. Unfortunately I will be away for the next 2 weeks.

Just a quick photo of how i wired it up:

Careful with that setup @skatun - looks like you’re wired up to the 3v3/Gnd output for the red/white wire. There’s two problems with that:

  1. If you’re expecting to power the LED strip with that connector, you won’t have enough juice for the 5V strips.

  2. If you’re using an external 5V power supply, you’ll be feeding back 5V into the 3v3 regulator output. Best case, it won’t work. Worst case, it’ll fry the NodeMCU board.

I do recommend using an external power supply (an old 1 or 2A 5v phone charger will do), wired directly to the LED strip’s 5V/Gnd rails. If you solder the red/white wires to the bottom left 5V/Gnd pins on the NodeMCU, you can also use that to power the NodeMCU itself. The benefit of that is less wires (no USB cable needed), but also the USB 500mA (and the 5V regulator on the NodeMCU) can’t handle too many LEDs (I wouldn’t put more than 10 on it).

Check out my video for the best wiring setup:

NodeMCU LED Controller How-to Video

I use external 12v supply for my ws 2811, I just didnt have the picture of the external powersupply :slight_smile:

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