fbpx

Most orders for IN STOCK items placed by 12PM CST M-F ship SAME DAY. Orders for custom items and prints may take additional time to process.

Wiring WS2812b Addressable LEDs to the Raspbery Pi

I don’t know where I have been recently, but I stumbled across one of the greatest inventions of all time recently: Addressable LED strips.  Addressable LED strips, sometimes known as NeoPixels, or by various numbers such as WS2812b LED strips are LED lighting strips where each individual LED can be controlled via a specialized lighting controller -or- an Arduino or a Raspberry Pi! What’s interesting is that literally none of these strips seem to come with a wiring instructions for the latter. So in this article, we’ll walk through wiring the WS2812b LEDs to a Raspberry Pi!

Wiring the WS2812b to the Raspberry Pi

If you’re new to Raspberry Pi‘s or addressable LEDs, here’s a convenient parts list for this project:

First, before we get to the main topic, lets understand a few things and make some of these topics clear.

Addressable LEDs vs Regular LEDs

Regular LED lighting generally has only two states. Either all of the LEDs in the chain are on, or they are all off (although some LED lighting before WS28xx variants were dimmable). Addressable LEDs work by adding a small micro-controller to each LED. This micro-controller allows for each individual LED to be controlled separately for state (on/off) and brightness via PWM. When integrated into an RGB LED it also allows for the control of each LED’s color!

Raspberry Pi and Arduinos

Raspberry Pi computers and Arduino micro-controllers have GPIO pins.  These pins can be used to send commands and configurations to addressable WS2812b LEDs. This makes the control options for the LED strips almost infinite. With a little code (in Python, C, or many others) you’ll be able to make all kinds of lighting effects. It is of course possible to run addressable LED strips with a standard controller (many come with one in the box), those controllers are generally limited to the programs they include.

Options for Wiring the WS2812b to the Raspberry Pi

There are multiple options for wiring WS2812b to the Raspberry Pi, depending on your circumstances.  The biggest thing most will encounter is that the Raspberry Pi GPIO pins produce a 3.3v output and the WS28xx LED strips are generally looking for 5v.  Check your product’s specifications to be sure.  The most reliable way to do solve this is with a logic level converter. We’ll look at several different options below.

WS2812b Raspberry Pi Wiring Using a Level Shifting Chip

One simple way to connect the WS2812b to the Raspberry Pi safely is the use a level shifting chip.  These also come as little boards for simple projects.  This chip will switch the voltage from 3.3v to the 5v needed by the addressable LED strips without damaging the Raspberry Pi GPIO in the process.  The wiring is as follows:

  • Raspberry Pi GPIO pin 18 to 74AHCT125 LLC pin 1A
  • 74AHCT125 LLC pin 1Y to WS2812b Data In (DIN)
  • Power supply ground to 74AHCT125 LLC ground
  • Power supply ground to 74AHCT125 LLC pin 1OE
  • Power supply ground to Pi ground (GND)
  • Power supply ground to WS2812b ground (GND or -)
  • Power supply 5V to 74AHCT125 LCC VCC (or +)
  • Power supply 5V to WS2812b 5V (or +)

Raspberry Pi Wiring with Diode

Another option to isolate the PI and protect it is to use a diode.  This would be wired as follows:

  • Raspberry Pi GPIO pin 18 to WS2812b Data In (DIN)
  • 1N4001 diode cathode (side with the stripe) to WS2812b 5V (or +)
  • Power supply ground to Raspberry Pi ground (or 0)
  • Power supply ground to WS121812b ground (GND or -)
  • Power supply 5V to 1N4001 diode anode (side without the stripe; make sure to get the orientation of the diode correct, with the cathode (side with the stripe) otherwise you may damage the Pi)

Using External Power Source without Level Shifting on the Raspberry Pi

It is possible in a pinch to operate WS2812b LED strips without level shifting at all. I don’t recommend it, but in most cases if you’re careful you’ll be fine.  However, there are some WS21812b LED strips that simple will not work without a level shifter.  If you run into trouble you’ll need to add one. Without a logic level shifter it would be wired like so:

  • Raspberry Pi ground (GND) to WS2812b ground (GND or -)
  • Raspberry Pi GPIO pin 18 to WS2812b Data In (DIN)
  • Power supply ground to WS2812b ground (GND or -)
  • Power supply 5V to WS2812b 5V (or +)

Powering WS2812b directly from Raspberry Pi Without Level Shifting

The last option will only work with a small number if LEDs. Check the specifications on your addressable LED strips to make sure how much current is required and be sure not to exceed the number of LEDs that add up to the Raspberry Pi maximum current limit of 51 milliamps.  Wiring diagram is as follows:

  • Raspberry Pi 5V to WS2812b 5V (or +)
  • Raspberry Pi GND to WS2812b ground (GND or -)
  • Raspberry Pi GPIO pin 18 to WS2812b Data In (DIN)

Next Steps

Of course, wiring ws2812b to the Raspberry Pi is just the first step in getting your addressable LED strips working.  In fact, just wiring them to the Raspberry Pi alone does nothing.  Not even a single LED will illuminate until your program them by sending them some data.  Read our article on controlling WS2812b LEDs with a Raspberry Pi with Python for more information!


Upgrade to Premium

If you like our content maybe consider upgrading to Premium. You’ll get access to

  • Free access to all plans
  • Member only videos
  • Early access to content
  • Ad free Experience
  • Discounts on store merch
  • Direct hotline contact form

3 Responses

  1. “It is possible in a pinch to operate WS2812b LED strips without level shifting at all. I don’t recommend it, but in most cases if you’re careful you’ll be fine.”

    I am a total noob in electronics and am inclined to use this option, but now you scared me. Why don’t you recommend this way? What could go wrong here?

Leave a Reply