Neopixels/RGB LED example

Matthew,

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

Thanks!

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:

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.

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.

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!

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!

https://drive.google.com/file/d/0B02x81-uvEZLRFBubVF2MU9VRlE/view?usp=sharing

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}]"}
1 Like

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.

Thanks

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

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

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

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…

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

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")) {
        client.set_callback(callback);
        client.subscribe(topic);
      }
    }
  }

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:
{mqtt=">[mosquitto:OpenHab/RGB/scene:command:ON:1]"}
{mqtt=">[mosquitto:OpenHab/RGB/scene:command:ON:2]"}
{mqtt=">[mosquitto:OpenHab/RGB/scene:command:ON:3]"}

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)

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.

  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

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.

2 Likes

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

1 Like

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:
https://nl.aliexpress.com/item/ESP8266-ESP-01-ESP-01S-RGB-LED-Controller-Module-voor-Arduino-IDE-WS2812-Licht-Ring-Smart/32843735937.html

neopixbord
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.
https://www.aliexpress.com/item/ESP8266-ESP-01-ESP-01S-RGB-LED-Controller-Module-for-Arduino-IDE-WS2812-Light-Ring-Smart/32843735937.html?spm=a2g0s.9042311.0.0.73194c4dWFwS18

1 Like

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
    https://www.banggood.com/ARILUX-AL-LC12-2048-Pixel-WIFI-Smart-Alexa-Controller-For-WS2811-LED-Strip-Light-DC12-24V-p-1299803.html?gmcCountry=NO&currency=NOK&utm_source=googleshopping&utm_medium=cpc_ods&utm_content=heath&utm_campaign=usc-ods-no&gclid=Cj0KCQjwv-DaBRCcARIsAI9sba--Z19oHnCUqn9kOqdGAJqOl3aTRkN3XxElWCTwRC8JboOzNfUPmlEaAoTFEALw_wcB&cur_warehouse=CN

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

  5. I ordered a pogo pin shield:
    https://mandrillapp.com/track/click/30145078/www.tindie.com?p=eyJzIjoiR1RJd2JHMU9fVWw0M1hZQkQ5MUJ6alBGTGtJIiwidiI6MSwicCI6IntcInVcIjozMDE0NTA3OCxcInZcIjoxLFwidXJsXCI6XCJodHRwczpcXFwvXFxcL3d3dy50aW5kaWUuY29tXFxcL3Byb2R1Y3RzXFxcL3BldGxcXFwvZXNwMTItcHJvZ3JhbW1lci1ib2FyZC13aXRoLXBvZ28tcGluc1xcXC9cIixcImlkXCI6XCJkNmQwMDU3MGRlMjE0Y2Y2YTE4MzI4OWQzZmE3ODhhNFwiLFwidXJsX2lkc1wiOltcImM5MTU5YThmNTg2NWZiNzNjYjg0MjVhNWMzNjhmMWNlZGY5YzgwZTVcIl19In0

  6. I read through this article:
    https://github.com/arendst/Sonoff-Tasmota/wiki/MagicHome-LED-strip-controller

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.
image
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?

1 Like

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

1 Like