Particle Photon/Spark Core RGB WS2812B

dth_misc
photon

(Justin Wurth) #1

The title says it all. I have created a device type to interact with the Particle Photon/Core. I have also created a Photon/Core firmware that will interact with this and use the Neopixel.h library.

Firmware and device type can be found here:

This creates an extremely cheap set of RGB lights that can interact with Smartthings.
What you will need:
Photon/Core $20


WS2812B rgb light strip
These worked great for me http://www.amazon.com/Addressable-Strip-WS2812B-meters-meter/dp/B00JSJSBZK/ref=lp_9219252011_1_1?srs=9219252011&ie=UTF8&qid=1443029994&sr=8-1
Bread board or soldering iron

Notes:
The WS2812B is a great rgb for dev boards as it runs at 5v and in the case of the photon can run directly off of vin if you are supplying usb power or you can split an outside power supply to support both the strip and photon.

To setup wiring

  1. Run ground wire on strip to ground on photon
  2. Run data line on strip to D2 on photon
  3. Run +5v on strip to VIN on Photon

It is good to note that depending on your wall wart or power supply you will need to do some caclulations based on the amperage of your ps. Typically the WS2812B 30 led/m strips use around .6 amp per meter. So if you have a 2amp wall wart you should be able to comfortably run about 3 meters off of the VIN without an additional power supply. 9 feet of light is a good amount in my opinion and puts out a lot of light, so I feel this is very acceptable.

I have setup “ON” to display a color wash and then set to a slightly off white (Feel free to change the firmware code as you see fit) Additionaly there are pick colors that you can modify to your hearts content.

This is a first version of this code I would actually like to make this a little more variable with an RGB color wheel, but my home theater desperately needs some accent lighting and it told me I needed to have something up and running. I am always welcome to changes so feel free to pull and request merges based on improvement to code. (I’m not the best coder out there and I know it! :wink:

Credits:
I have taken tidbits of code from @dome, @juano2310 and Phil Burgess for the neopixel.h and neopixel.cpp.

Oh and I am really excited about this. As I can now do interactive under cabinet lighting and home theater lighting for under $30 per strip.

Please let me know any feedback or thoughts. I am always open to that. (now that my basement(home theater) is done I should have some more free-time (oh wait we are having a baby in 3 weeks so maybe a little free-time).


Automated Window Blinds - Spark Core
Announcing the "ST_Anything" Arduino/ThingShield Project
Automated Window Blinds - Spark Core
Smart Sprinkler System
Communication Protocol Boards / Controls for custom design work?
Working Mailbox Sensor for Apartments/HOAs/FAR away mailboxes!
(Benji) #2

Those strips are EXPENSIVE! Hell I think even Adafruit’s strips are cheaper but yes otherwise this is awesome!


(Justin Wurth) #3

It’s 5 meters of strip. 15 feet of light. That is about the cheapest you will find for WS2812B. And adafruit while I do try to support them have only 1m strips for around $16 I believe.

Luckily for me that is enough to supply about 4 -5 photon/core setups. Which when you break it down is about $30 per setup. Which is way less than even the z-wave or fibaro RGB controllers which are still way less in price than Phillips Hue.


(Benji) #4

Yep they’re about $17/m but that being said with the Fibaro/Dresden setup you can get strips with twice the density of LEDs for a lot cheaper, i.e. 60leds/m and 5M for about $15

That being said if I was shopping for WS2812B or APA102 strips it’s the one time I’d shop on Ebay or more likely AliExpress. If you shop smart you can get 5m WS2812B/APA102 strips for MUCH less.


(Justin Wurth) #5

Updated some code. I cleaned up the spark firmware as well as I believe the while statements were causing a memory leak that was causing an error on Spark.

I am really happy with this solution. It works extremely well and I have tied the on/off function to a z-wave wall switch. I will put up some video later tonight (hopefully).

My next steps are to incorporate the kodi/xbmc callbacks scripts to send commands to dim these lights on play/resume and to set them to full brightness on pause/stop. The home theater is getting a fun automated upgrade with this.


(Justin Wurth) #6

Here is video. I set the lower to have a chase sequence and the uppers to just turn on.


Kodi/XBMC light control - a (relatively) simple how-to
(Dome) #7

@jjhtpc, nice work! Looks great. At some point I might play with addressable strips. Right now my priorities are elsewhere (like finishing my basement remodel). :smile: That, and trying to get a Photon working with incoming events.


(Justin Wurth) #8

I have updated the code for this and added the enerwave 7 button scene controller with a modified smart app to control the Particle Photon.

Here is a video of a terrible cinematographer capturing the button presses, basement kitchen waiting for countertops and the under-cabinet lighting powered by the photon:


ZWN-SC7 Enerwave 7 Button Scene Controller
(Brian) #9

@jjhtpc - Have you been successful with receiving data from the Photon? Using your code as an example, I’m now comfortable with sending commands from ST to the Photon. However, I’m not able to receive variable data that from devices the Photon is controlling like a sensor. It might be useful to report on something like a confirmation status letting me know if a pin is HIGH or LOW. Anyway, I’m interested to hear if you’ve made progress in this area. Oh, and the lighting looks great! Thanks again!


(Justin Wurth) #10

I have not worked on it mostly because from a use perspective I have used the particle rgb as home theater accent lighting. In these cases my usage calls for commands to be run and I am present and see the result. Also I call these commands through KODI cinemaexperience and I am not using the smartthings app to interact. I do see a usefulness in the status if you are using the app or using a dashing display to interact with them, but for my purposes thus far I have been only command driven. I am planning on adding three sets of these as undercabinet lighting in my main kitchen and while the basement kitchen has the enerwave 7 button to control it(again very command driven) but I could see using a combination of the echo and a dashing display to interact with the upstairs kitchen lights. So this may be something I take on in the next month or so.


(Albertus de Wet) #11

HI

I am at a lost to try this for my Photon.
Where do I start and what files do I flash?

Thanks


(Justin Wurth) #12

Did I not include the github for this?


(Albertus de Wet) #13

Hi Justin

No, you have. But I am getting compile errors trying to compile the code. There are many files in this Github.
Which ones should I use to compile with and to get all the LEDS to light up?
I do not care so much about the different colors (yes, that’ll be a bonus), but I just want white leds under my kitchen counters.
Sorry to bother you with this stupid question, but I really am lost.
Thanks for your help.
Bert


(Justin Wurth) #14

Sure let me see if I can help.

Fit the photon you will need the kitchen rgb firmware:

The neopixel.h:
https://github.com/jjhtpc/Photon-RGB/blob/master/photon%20neopixel.h

And the neopixel.cpp:

Those three files make up the photon firmware.
It is good to note you will need to change the number of pixels in the kitchen photon firmware to represent the number of pixels you are using.

Then the only other thing you need is the device type code for ST.


(Albertus de Wet) #15

Justin

This is GREAT ! Thank you - I REALLY appreciate your help with this.
I am currently in the office, but will try this out as soon as I get home this afternoon and report back.
One last question. you mention ‘…the device type code for ST’ - what is ST? The Strip?


(Justin Wurth) #16

No ST is SmartThings. The device type you setup as a device handler in the SmartThings ide.


(Albertus de Wet) #17

AH-ha, 'cause. (I knew that but was just a little overloaded with info). After I get the Photon flashed, I’ll define the ‘device type’ in ST from the device type file also in your github.
I’ll try later today and let you know. Thanks for your time


(Albertus de Wet) #18

OK.
I compiled the code and it compiled fine.
I flashed the code, the LED flashed a few times and then just went dead…no led - is that he proper behavior?
Even after I reset / power down , the led goes blank and stay off. it first flashed a few times green, then a couple of magenta flashed and then just dies.

I even unassigned the device and re-flash Tinker again…it works fine. I can access it from my phone, but when I flash your code again (sometimes it times out when its in flashing-yellow mode)

When I flash the code while its blinking blue, it flashes, but after it re-cycles, the led is dead again…

What am I missing here?

Thanks


(Justin Wurth) #19

Yes the LED on the front should turn off, I coded that so you didn’t have a cyan light blinking.


(Albertus de Wet) #20

OK. Thanks!!
So there is no other way for me to ‘test’ it accept through ST?

OK - so i get it setup as a device in ST…but how do I find it on my ST app?
I tried to put the device again into blinking blue led state and scan for it in my ST app - but it does not pick it up.
Did I miss anything in the defition?
Should I have enable OATH (or whatever that’s called - I know I did not do that.

Ideas?