openHAB RGB LED Light Cube with WS2812B and NXP Kinetis

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:

Kinetis RGB Cube with openHAB

Kinetis RGB Cube with openHAB

Hardware

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:

NeoShield with FRDM-KL25Z

NeoShield with FRDM-KL25Z

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).

openHAB Color Picker for LED Cube

openHAB Color Picker for LED Cube

For testing purposes the FRDM board is placed underneath the LEDs:

Temporary Board Placement

Temporary Board Placement

The board drivers the LED’s. The power supply provides 5V and 10A.

Cube Inside Detail

Cube Inside Detail

The cube is built up from 5 pieces glued together:

Cube Inside Detail

Cube Inside Detail

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:

Yellow cube

Yellow cube

Green Cube

Green Cube

Blue Cube

Blue Cube

Violet cube

Violet cube

Red Cube

Red Cube

openHAB

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:

openHAB Color Picker for LED Cube

openHAB Color Picker for LED Cube

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:

Orange LED Cube

Orange LED Cube

Video of changing colors with the smart phone:

Summary

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 🙂

Links

Advertisements

One thought on “openHAB RGB LED Light Cube with WS2812B and NXP Kinetis

  1. Pingback: Kinetis Lava LED Light Cube | MCU on Eclipse

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.