Controlling WS281X LEDs from Renegade?

Hello!

I’ve been working on a new LED-based project recently. This is my first time working with controllable LEDs, and for the most part I haven’t run into any major issues. The example project I’m working off of is using an RPi, but the only Pi I have at the moment is a very old Model B. That’s been fine for learning the LED stuff, but it’s not powerful enough for the actual project.

I picked up a ROC-RK3328-CC with the hopes it would mostly be a drop in replacement. The Adafruit Blinka library seemed to support a wide range of SBCs, not just Pis, including some Libre models which I thought was promising. I was able to patch Blinka and another library to better support the ROC-RK3328-CC. But it turns out that the WS281X (Neopixel) support in Blinka is highly specific to Pis, even though other GPIO aspects would work.

I’ve done a lot of searching, and I’ve hit a dead end, so here’s my question: is it at all feasible to control WS281X LEDs from a ROC-RK3328-CC? Nearly all resources I find related to the WS281X protocol and small boards say something like, “WS281X uses very specific timings, and must be controlled from a real-time chip like an Arduino. Things like RPis aren’t precise enough.” But then I have a Pi that is controlling them just fine, and clearly that’s very common.

I mostly write software and only occasionally dip into hardware projects, so this is definitely hitting my knowledge limit. Is there something specific about Raspberry Pis that make them better suited for working with WS281X than other SBCs? Or is it more like: Pis can do it, but aren’t ideal, and other boards also could do it in a less-than-ideal way?

I’m probably just searching wrong, but I have found zero examples online of someone controlling WS281X from a Linux-based board that isn’t a Raspberry Pi. My instincts tell me that if I have a computer and it’s got some GPIO pins, it should be possible. But if literally no one else is doing it, then maybe I’m wrong, or maybe it’s just so much work it’s not worth it.

Should I continue down this path? I’m happy to spend some time in C or Rust if necessary to do the low-level work, I just want some confirmation that there isn’t some fundamental blocker with boards like ROC-RK3328-CC that make it impossible.

Thanks so much for any help!

1 Like

I did spend a bit of time looking at this because I have a Pi using the Neopixel Library and the Neopixel routine calls on the driver below which is specifically for BCM283x based devices such as the pi.

“BCM283x NeoPixel Driver Class”
import _rpi_ws281x as ws

jgarff/rpi_ws281x: Userspace Raspberry Pi PWM library for WS281X LEDs (github.com)

I’m thinking a better approach might be try to adapt the LUMA Matrix Library ???

rm-hull/luma.led_matrix: Python module to drive LED Matrices & 7-segment displays (MAX7219) and RGB NeoPixels (WS2812 / APA102) (github.com)

I have this working for the 7219 on the Le Potato but that just relies on the SPI interface.

As an alternative there also seems to be some SPI based drivers out there but my plan was to look at the Luma software.

Did you create a Pull Request for the Blinka Library ??? - it would be good to capture your learnings and they were pretty good at creating Libre specific code when I suggested some changes !

1 Like

This is an interesting site, as it gives some explanation of why Pin 18 on the Pi is used for driving Neopixels.

Pulse Width Modulation for Dummies-Raspberry Pi GPIO Programming and Software Development (youngkin.github.io)

1 Like

I’m interested in this too. I use sk6812 RGBW neopixels with my microcontrollers, and when trying to figure out how to use them with Le Potato I came across this:

I know it’s an old post, but the following exchange made me loose a little hope for the Blinka method:

ladyada commented on Feb 25, 2019
not surprising, i dont know we ever got neopixels working on beaglebone via Blinka! right now only Raspberry Pi linux computers have support

@CharlieBouyaka

Author

CharlieBouyaka commented on Feb 25, 2019

That’s a bad news… I like my beaglebone…
I’m trying to use a neopixel led strip with…
Have you planned to come to beaglebone ?

@ladyada

Member

ladyada commented on Feb 25, 2019

nope no plans!

I understand that beaglebones are more popular than Libre Computers products, so I doubt they’re going to be getting around to it any time soon.

I’ll have to give luma a try. I’m thinking if that’s a no-go (or too complicated for my skill-level) then I’ll just use a RPi Pico W or a nRF52840 ItsyBitsy if I need neopixels. I’ve already had good luck controlling the latter with my phone. Thankfully, in my case, I have no particular project I need this for, it was just a curiosity.

I forget where, but I remember reading that dotstars were recommended for SBC’s over neopixels. I have a dotstar featherwing somewhere; I’ll dig it out and give that a try.

1 Like

You can drive it using SPI bus for individual addressability or PWM for identical signal to all LEDs. Might need a shift register in front.

1 Like

Yeah, I opened two PRs for the work I was doing before I hit the Neopixel roadblock:

1 Like

I saw that in a number of places, but couldn’t find any good examples of doing that. But I will dig into it more now knowing that It’s possible.

1 Like

That was a great resource, thanks for sharing!

Thanks for all your efforts with the Blinka library which at least gives a vehicle to attempt to interface with common electronics - just a shame about the Neopixels.

Definitely an interesting challenge for the NeoPixels but when you can just Flash an ESP32 or ESP8266 with WLED and be up and running in a couple of minutes it is difficult to muster the enthusiasm !!

1 Like

Does it count if I send JSON commands to WLED from the Le Potato ??

(89) WLED driven Color Matrix Frame - YouTube

1 Like

Adafruit just released an I2C Neopixel driver, I think I’m going to stick to my original plan of using a micro-controller maybe with BLE, so the animations are saved on the controller, and all I have to do from the potato is tell it which one to display. Slightly more complicated, but I think it will yield better performance displaying animations.