Monday, 15 May 2017

Raspberry pi 3 + node js controlling ws2811 leds

I am trying to control a string of rgb leds via my raspberry pi. I had this working via an arduino but I would like to do it directly from the pi.

I am using nodejs to do this, and the rpio library. I have connected the leds to the physical pin 19 (SPI - MOSI) and the ground to physical pin 39. Very similar to the arduino set up I had - basically a data and a ground connection. The power goes directly to the lights to take the load off the pi.

My issue is I cannot get the lights to turn on. I've been playing in the node repl trying to get it to work so the code I'm using is very basic:

const rpio = require('rpio');
rpio.spiBegin();
rpio.spiWrite(lights, lights.length);

I suspect its likely due to the lights buffer that I'm sending. Truth is I'm not sure what to send, right now I just populate a list with 50 (thats how many leds i have) 24 bit colors and then just convert it to a buffer with new Buffer(...).

I'm also not sure if my hardware is wired correctly. So any advice on that front also welcome.

If anyone provide a simple code snippet - preferably in nodejs - just so that I can test my lights are connected correctly. That way I can at least narrow down the problem to the software. If anyone has had experience with SPI using rpio any advice would also be helpful.

Pi pinout reference: https://az835927.vo.msecnd.net/sites/iot/Resources/images/PinMappings/RP2_Pinout.png

The following is not my setup. I'm just using it to show I have 1 connection for 'data', a ground that is connected to pi and to the power supply. And then power straight to the lights (capacitor in that pic). Sorry this was the closest image I could find. https://i.imgur.com/VP9iB1o.jpg

Ideally im trying to get to something like this: https://www.youtube.com/watch?v=WLbLOEfoo8s

But I'd settle for 1 light turning on at this point ;) I'm going to try and get in contact with the uploader aswell.

Let me know if any more info is required.

Any help is appreciated!



via Shifty