Neopixels/RGB LED example

Tags: #<Tag:0x00007f01533a9a48> #<Tag:0x00007f01533a9430>

(Rich P) #42


Do you have your openHAB config files for the RGB/Fastled posted anywhere?


(Matthew L Adams) #43

Sorry, been meaning to get back to you on this! I don’t at the moment but I can certainly post that for you. I’ll have a chance to get that posted this weekend so if you don’t mind just giving me a day or two I’ll get those up there for you! :slight_smile:

(Rich P) #44

I wound up with this in my items file:

Color LedLights "LED Lights" { mqtt=">[mosquitto:openhab/lights/LEDLightsColor:command:*:default],>[mosquitto:openhab/lights/LEDLightsColor:state:*:default],<[mosquitto:openhab/lights/LEDLightsColor:state:*:default]" }
Switch LEDRainbow "LED Rainbow" ["Switchable"] { mqtt=">[mosquitto:openhab/lights/LEDLightsPatternSwitch:command:*:default]"}

Works ok, need to add more patterns though besides Rainbow.

(Matthew L Adams) #45

I know, I keep wanting to add more patterns but I’ve been so involved with other parts of my system that I just haven’t had the time. If you want to see any of my code just let me know and I’ll upload it. It’s still a little disorganized and I plan to fix that but it works pretty well.

(Rich P) #46

I love to see your code. I noticed on mine when I switch Rainbow off, it doesn’t switch the lights off completely and I need to fix that.

I have it under my son’s bed and working with Google Home so he’s pretty happy about that!

(Matthew L Adams) #47

Here’s the link to the ESP8266 code. It’s written in the Arduino environment using the FastLED library. It’s not perfect and could use some cleanup but it works. Let me know your thoughts and if you want me to explain anything!

Here are my items:

Color       CounterLights               "Counter Lights"                                (Kitchen, Lights)           ["Lighting"]    {mqtt=">[HABroker:myhouse/kitchen/CounterLightsColor:command:*:${command}]"}
Switch	    UCPatternSwitch		"Counter Lights Pattern Switch"			<switch>						            ["Switchable"]	{mqtt=">[HABroker:myhouse/kitchen/CounterLightsPatternSwitch:command:*:${command}]"}

(Bob C.) #48

Need some help with the Arduino code for the Neopixels/RGB LED example by Kees_van_Gelder.

I am programming a NodeMCU and I do not see a place to enter the port# for mqtt server or user name and password.

I’ve set the rules, items, and sitemap in OH. That part works, I see the mqtt messages in MQTT.FX begin posted when changes are done in the basicUI.
A little help in pointing me in the right direction would be greatly appreciated.


(Kees Van Gelder) #49

Apologies for my late reply, but I have not been much on line lately.
With regard to the MQTT port, I might have been a bit lazy, as the Imroy library uses port 1883 as default. hence when you do not define any port, it defaults to port 1883.
You can however overrule the default in your program by the standard ipnr,port combination

(Bob C.) #50

Thank you for your reply. I will see if I can get this to light up:smile:

(Kees Van Gelder) #51

good luck. Don’t hesitate to ask again if you encounter problems

(Bob C.) #52

Thanks Kees, for taking your time to make these instructions and to respond everyone’s questions. I’m very new to Openhab and Arduino and after discovering it I am totally fascinated by home automation.

Where am at I’ve uploaded the Arduino Sketch to my NodeMCU it is working sorta…

Let me give some details:
Board - LoLin NodeMCU V3
IDE software - Arduino 1.8.5 (With the libraries that you said to install)
LED strip - Generic ws2811 from China. 300 led count
Openhab2, and with mosquitto running on a raspberry PI 3 B+

What Works : ON / OFF switch, Color picker, sliders, solid color pickers “with the exception that blue and green are mixed up”

The problems that I’m having.

  1. Blue and Green are reversed . { I tried both NEO_RGB and NEO_GRB } Maybe it could be rewired or change some code around to flip the colors on the openhab side.

  2. MQTT. I still don’t see where the user name and password go for connection to the broker. I’ve set my broker to : allow_anonymous true. For testing purposes.

  3. Basic-UI - All the NEO_ switches do not work. Throwing an error openhab2 log viewer like below.

[rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/NEO_REDBLUE' for the unknown item 'NEO_REDBLUE'.

Im guessing that I have to add these items to my item file and throw the right mqtt command for it to work. I have no idea where to even start there.

Thanks again…

(Kees Van Gelder) #53

ad1. NEO_RGB and NEO_GRB only change Red and Green, but there are some more setupspossible:

2 I actually never use a password log in for my own MQTT broker,but here is what you do:
Where you declare your variables, add:
const char* mqttUser = "YOUR-MQTT-USERNAME";
const char* mqttPassword = "YOUR-MQTT-PASSWORD";
then look for this piece of code:

 if (WiFi.status() == WL_CONNECTED) {
    if (!client.connected()) {
      if (client.connect("arduinoClient")) {

Then change the ‘arduinoClient’ line into
if (client.connect("arduinoClient", mqttUser, mqttPassword ))

3 it seems you have a missing item though the HTTPpost surprises me a little
You have to add those items to your conf/itemsfile the way you add every other item

I was under the impression that I had added the proper items in the file download, but apparently I did not, whileI did add them to the sitemap.So you would have to add those in your itemsfile with the following channels:

I think somewhere aong the line those were lost from the uploaded itemsfile. Will have to add them again when I have some time (that file was on a crashed computer)

(Bob C.) #54

1.I tried to change the NEO_*** to different configurations in the Arduino Sketch. It will only compile with NEO_RGB , NEO_GRB . The library might not support those other configurations. Any how, I will live with it :smile:

2.As for the MQTT Authentication, I’m just fine leaving it without a password. From what I read it really not necessary on your private network. Unless you suggest that I enable it, Then I will proceed forward.

3.Yes, indeed those are correct, I entered them and they are working, but with a problem.
It appears that my NodeMCU while a scene is running, it will no longer respond to MQTT commands. The only way to get it to response is to do a hard reset by pressing the reset button on the nodemcu. Ive verified that Openhab is still sending the correct Mqtt commands by using MQTT.FX client and subscribing to OpenHab/# . I’ve ordered a new NodeMCU, it comes tomorrow. More Testing …

Thank you.

(Kees Van Gelder) #55
  1. the various NEO settings in fact came from the Library so I would expect it to compile.
    Not sure where you got your WS2811, but if from china, sometimes they are rejects coz of production failures. you could have an odd batch.
    Check line 54-59

  2. true

  3. I have had that similar problem with some more extensive patterns, so I am not sure if it is a nodemcu problem. make sure you have a decentcapacitor over the power lines of yr neopixels

(Kim Skatun) #56

I just ordered 3 of these:

They can be flashed with the Tasmota software or @Kees_van_Gelder software believe:

I will let you folks now when I get them.

(S.F) #57

How did you get on with the ARILUX® AL-LC12 2048 Pixel WIFI Smart Alexa Controller For WS2811 LED Strip Light DC12-24V?

(Kees Van Gelder) #58

The program I presented in the O.P. ofcourse doesn’t need much pins and should be fine with an ESP8266-01.
I came across these little adapters that seem to have all the necessary additional hardware.Ordered one and will test it out:

(Kees Van Gelder) #59

As my eyes are too old to still really enjoy soldering, I was pleasantly struck by a little module that has practically all the components needed to control neopixels from an ESP8266-01.
It costs less than a dollar at aliexpress.
Using an ESP8266-01 for neopixels makes sense as it only has a few pins and one pin is enough.
Make sure you get the new ESP8266-01S as that one already has the necessary pull-up and down resistors.

(Kim Skatun) #60

Hi guys, sorry for the delay. I just moved outside for the summer and now when winter is back I am back to doing Openhab stuff again.

  1. So I did fiddle around with the wifi led binding a little bit, however these does not work neopixel as far as i know.

  2. I got the tasmota code to work on a generic wemos board. I also asked Theo to make a new device in Tasmota because ws2811 is rbg and rgb as ws2812, which means that the colors are swapped, however this can easily be fixed when compiling the arduino library, the disadvantage is that if you wanna upgrade your tasmota, you need to download the latest tasmota and reflash it yoursself instead of using tasmotaadmin. You can of course just swap the colors in openhab rules, but then some of the hundreds of fun preprgrammed rules might not work as desired.

  3. I ordered and received the

  4. I 3d printed a holder for the esp chip

  5. I ordered a pogo pin shield:

  6. I read through this article:

So that should be : pin 8 -GND pin 6 -GPIO 0 pin 3 -RX Pin 2 TX on the SV 3 in schematic below

Close up of the ARILUX:

6.I got an ftdi adapter and put it in 3.3v mode.
7. Now i need you help, how to connect the POGO shield to the ftdi adapter correctly and should i press a switch while flashing it?

(Kees Van Gelder) #61

I looked at the Pogoshield you ordered but that does not help me much further in understanding how that should be connected to the FTDI adapter.
I Would figure that there is a standard male/female pin connected to each POGO pin and that is where you connect your FTDI adapter to.

I am not sure if it is suitable for programming the Arilux. I get the impression the pogo shiled just presss all of its pins against an ESP8266. If so and you can approach the ESP chip on your Arilux, that is where you would hold down the pins.and yes you still need to put it in flash mode by pulling GPIO low before startup