Skip to content
Jeremy Garff edited this page Aug 14, 2016 · 19 revisions

Project Information

The BCM2835 in the Raspberry Pi has a PWM module that is well suited to driving individually controllable WS281X LEDs. Using the DMA, PWM FIFO, and serial mode in the PWM controller, this library can be used to control almost any number of WS281X LEDs in a chain connected to the PWM output pin.

Please see the NeoPixels on Raspberry Pi documentation from Adafruit. Thanks to Tony DiCola for this great write-up. Please note that this write-up is out of date. Many of the listed limitations are no longer valid (RPi2/RPi3 is now supported for example).

FAQ

  • Does the library support WS2811s?
    Yes. Please make sure your LED signals are connected with a properly configured level shifter. Bad signalling causes almost all reported problems. Please double check your signalling before submitting issues.

  • What signal frequencies are supported?
    The default of 800kHz is the best frequency to use, but others have been known to work. The signal must be clean, so use a level shifter, a small resistor to limit signal ringing, and wires that are as short as possible. See the Adafruit write-up for more information.

  • How many strings of LEDs can be driven?
    Two. The BCM2835 has two PWM channels. One string can be driven from each channel.

  • How many LEDs can be driven per channel?
    Any number of LEDs can be driven, but the refresh rate goes down as the number of LEDs go up. Users have reported successfully driving several thousand LEDs per channel. A rough estimate can be calculated with:
    Frame Rate = 800000 / 24 / Number of LEDs

  • Which GPIOs can I use to connect the LEDs?
    Channel 0 - 12, 18
    Channel 1 - 13, 19 (only available on B+ and later)

    Note: You must make sure to configure the channel properly in software. Changing the pin number alone in the examples are not enough.

  • What boards does this library support? Only official Raspberry Pi boards running Linux which are based on Broadcom SOCs. This includes: Model A and A+, Model B and B+, Compute Modules, Pi Zeros, Pi 2s, and Pi 3s.

  • Can this library support other boards, such as the NanoPi? Probably not. It's possible that future official Raspberry Pis will be supported, but only if they use the same or compatible Broadcom SOCs. This library relies on specific PWM, DMA and VideoCore logic found only in these parts. Supporting other chipsets is outside the scope of this library.

  • The LEDs are flickering randomly. What could cause this? There are two major causes for this. First, this library conflicts with the Pis on-board audio. Unfortunately, there is no way around this as they both use the same PWM logic. You must disable the on-board audio by blacklisting the Broadcom audio kernel modules. USB audio devices can be used instead. Second, the PWM signal might not be making it to the LEDs reliably. This can be caused by bad power (add capacitors on the Pi's 5v and use a regulated strong 5v power supply), weak signal strength (use a level shifter, like the TXB0104), too long of signal wire (shorten it, and please don't use wire nuts), electronic interference (try to reduce it), or no common ground (connect the grounds, but be sure to avoid ground loops).

Links

Projects Using this Library

Please e-mail me if you would like your project included in this list.

Clone this wiki locally