From my earlier work to use the NXP Kinetis with openHAB (see “Controlling NXP Freedom Board RGB LED with openHAB and Raspberry Pi“) it was only a small step to control a 20x20x20 cm light cube with 256 Adafruit WS2812 NeoPixels:
To drive the Adafruit WS2812 NeoPixel Matrix array, I’m using a custom shield for the NXP/Freescale FRDM-KL25Z (see “NeoShield: WS2812 RGB LED Shield with DMA and nRF24L01+“). It has a battery buffered RTC, a Nordic Semiconductor nRF24L01+ 2.4 GHz transceiver and a WS2812 Level shifter to drive up to 8 chains of LEDs with DMA:
The LED’s are placed on the cube ground plate. I’m using 4 8×8 NeoPixel matrix boards from Adafruit (https://www.adafruit.com/products/1487).
For testing purposes the FRDM board is placed underneath the LEDs:
The board drivers the LED’s. The power supply provides 5V and 10A.
The cube is built up from 5 pieces glued together:
The colors really look great! Only because the board could be 2 cm lower there is a not-so-bright area on the bottom, a problem I want to solve in the next iteration:
In openHAB on the Raspberry Pi I have added a new color picker widget for the LED cube and added it to the site map:
The following rule is sending the LED Cube RGB values to the FRDM-KL25Z board:
rule "Set RGB Cube" when Item FRDM_LED_CUBE changed then hsbValue = FRDM_LED_CUBE.state as HSBType // each int value is from 0 to 100 (%) var int redInt = hsbValue.red.intValue var int greenInt = hsbValue.green.intValue var int blueInt = hsbValue.blue.intValue // transform 0..100 to 0x0..0xff redInt = (redInt*0xff)/100 greenInt = (greenInt*0xff)/100 blueInt = (blueInt*0xff)/100 // Build RBG : 0xRRGGBB redInt = (redInt<<16)+(greenInt<<8)+blueInt // convert to string redValue = (redInt).toString sendCommand (FRDM_UART, "neo set all " + redValue + "\r") end
With this, I can connect to the openHAB server on the Raspy with my phone and tablet and change the color:
Video of changing colors with the smart phone:
For a proof of concept, it really looks great! Getting the cube into openHAB was a matter of minutes. The FRDM-KL25Z is driving the RGB LED’s with DMA very fast and efficiently. For now all the LED’s are using the same color, so I plan to extend the software to have them multi-colored. One problem I have faced is: running all LEDs with full brightness consumes a lot of current (around 30 mA per LED color!) and so the Pixel Boards get rather hot. The cube itself and the metal ground plate help cooling it, but I will see how it goes for a longer time. The other improvement point I have is the position of the LEDs: they are now too high, so I’m working on an alternative positioning. So always something to improve 😉
Happy Cubing 🙂
- Controlling NXP Freedom Board RGB LED with openHAB and Raspberry Pi
- NeoShield: WS2812 RGB LED Shield with DMA and nRF24L01+