Node-RED with WS2812B Addressable RGB LED Strip

Addressable RGB LED strips are just awesome! You can control each individual pixel of the strip, allowing you to produce beautiful effects. However, controlling these kind of strips it’s not always easy. So, in this project we’re going to show you how to build a web application with Node-RED and Raspberry Pi to control an addressable RGB LED strip to make your life simple.

Watch the video demonstration


If you like home automation and you want to learn more about Node-RED, Raspberry Pi, ESP8266 and Arduino. I recommend that you download my course: Build a Home Automation System with Node-RED, ESP8266 and Arduino.

Project overview

Here’s some important aspects about the Node-RED application built in this project:

  • The addressable RGB LED strip will be controlled using the neopixel node that you need to install;
  • In the application, you can select individual LEDs and set its color using a color picker;
  • You can select the strip color either by using the color picker or a drop-down menu with preset colors;
  • The application also allows you to display a moving rainbow effect on the strip;
  • Finally, you’ll have a “Clear” button to unlit all the LEDs on the strip.

Parts required

In this project we’ll be controlling the WS2812B addressable RGB LED strip. For that you’ll need the following parts:

You can use the preceding links or go directly to to find all the parts for your projects at the best price!

Wiring the WS2812B RGB LED Strip

With your Pi shutdown, follow the next schematic diagram to wire the WS2812B RGB LED strip to your Pi. The WS2812B data pin should be controlled by the Pi’s GPIO18, because that’s the GPIO used by the neopixel node.

Learn Raspberry Pi, ESP8266, Arduino and Node-RED. This is a a step-by-step course to get you building a real world home automation system using open-source tools DOWNLOAD »

Learn Raspberry Pi, ESP8266, Arduino and Node-RED. This is a a step-by-step course to get you building a real world home automation system using open-source tools DOWNLOAD »

The pin used to control the strip may conflict with audio playback, so the pixels can go crazy and not work properly. If this happens, you need to add two lines to the config.txt file. In the Terminal enter the following:

pi@raspberrypi:~ $ sudo nano /boot/config.txt

In the file that opens, add the following two lines (anywhere should be fine):

hdmi_force_hotplug = 1
hdmi_force_edid_audio = 1

Press ctrl-X to save the file and then, when prompted, type Y and press enter. Reboot your Pi for the changes to take effect, and then proceed with the instructions.

Installing the neopixel Node-RED node

To control the WS2812B addressable RGB LED strip with Node-RED, you need to install node-red-pi-neopixel. First, you need to install the Neopixel python driver. So, in the Terminal window type the following (this may take a few minutes):

pi@raspberry:~ $ curl -sS | bash

Then, install the node to control the LED strip:

pi@raspberry:~ $ node-red-stop
pi@raspberry:~ $ cd ~/.node-red
pi@raspberry:~/.node-red $ npm install node-red-node-pi-neopixel

Starting Node-RED

To start Node-RED, enter the following in the Terminal window:

pi@raspberry:~ $ node-red-start

To access Node-RED, open a tab in any browser on the local network and type the following:


You should replace Your_RPi_IP_address with your Raspberry Pi IP address. If you don’t know your Raspberry Pi IP address, in the Terminal enter:

pi@raspberry:~ $ hostname -I

Creating the Node-RED Flow

Before creating the flow, make sure you have the rpi neopixels node, as show in the figure below. If you don’t have the node, check that you’ve followed the instructions above in the Installing the neopixel Node-RED node section.

Download our Free eBooks and Resources

Here’s the flow to control the WS2812B RGB LED strip.

As this flow is a bit complex, we recommend importing the flow we provide instead of building it from scratch. Then, you can make modifications to the flow, if necessary.

Importing the Node-RED flow

To import the Node-RED flow provided, go to the GitHub repository or click the figure below to see the raw file, and copy the code provided.

Next, in the Node-RED window, at the top right corner, select the menu, and go to Import Clipboard.

Then, paste the code provided and click Import.

Select the Number of LEDs

This flow was built for a strip with 14 LEDs. You’ll be probably using a different number of LEDs. So, you’ll need to make some changes to the flow.


Double click the WS2812B LED STRIP node, and change the number of LEDs in the first field.

Select LED Slider Node

You also should edit the Select LED Slider Node, so that you are able to select all the pixels on your strip with the slider.

Select LED Numeric Node

You need to edit the Select LED numeric node to match the number of LEDs on your strip.

Rainbow Effect Function Node

Edit the number of LEDs on the Rainbow Effect function node, as highlighted in the figure below. You need to do this, so that the rainbow effect spreads across the number of LEDs on your strip.

Adding More Preset Colors

This Node-RED application has a drop-down menu that allows to chose a color for the entire strip. We’ve added some preset colors, but you can add more colors if you like. For that, double-click on the Select Strip Color drop-down node and add more options. You should set the color in RGB.


After making all the necessary changes, click the Deploy button to save all the changes.

Now, you Node-RED application is ready. To access Node-RED UI and see how your application looks, access any browser in your local networks and type:


Your application should look as in the following figure.

Wrapping up

In this project we’ve made a Node-RED application to control the WS2812B RGB LED strip using the neopixel node. We hope you’ve liked this project, and have fun controlling your LED strip.

If you like this project, you may also like:

Thanks for reading.

Learn how to program and build projects with the ESP32 and ESP8266 using MicroPython firmware DOWNLOAD »

Learn how to program and build projects with the ESP32 and ESP8266 using MicroPython firmware DOWNLOAD »

Enjoyed this project? Stay updated by subscribing our weekly newsletter!

26 thoughts on “Node-RED with WS2812B Addressable RGB LED Strip”

  1. Your article tells me to connect my pixels data line to GPIO 17, “because that’s the GPIO used by the neopixel node.” The neopixels are controlled by a fancy hijacking of a PWM pin and in every bit of Python code I’ve seen (or written myself), they are connected to GPIO 18, which is a PWM pin. The Python library code says pin 18. The Pimoroni “schematic” for the Unicorn hat says pin 18 too So I have to conclude you’ve got a typo.
    Also: when using this on a Pi Zero, you really do need to disable audio. The Pimoroni install script enables it and maybe it works if you route audio to HDMI, but I’m not. You need to edit /boot/config.txt:
    # Enable audio (loads snd_bcm2835)
    # disabled for neopixel use on pwm gpio 18
    Without this it absolutely does not work (I know, I just changed it and now it does work).
    Thanks for the bootstrap!

    • Hi Jeff.
      You are right! It was a typo. I’ve already fixed it.
      We also added how to edit the config.txt file.
      Thanks for noticing and letting us know. 🙂

    • Hi Ethan.
      This project uses Node-RED to control the RGB LED strip.
      What do you mean with using msg.brightness to control the brightness? What are you using to control the LED strip?

      • Hi ! Sara.
        THX for replying my question. Im using the Node-Red to control the RGB LED just like the tutorial, but im not using the strip, instread im using the Neopixel 8×8 Matrix. The Node-Red-Neopixel’s detail says it can use msg.brightness to control the led brightness dynamically, but i just can’t make it work…………Can you help me with that?
        THX AGAIN!!!

    • You need to remove the 5v wire that is powering the RGB LED strip. Then, you use an external power supply that is connected to that 5V pin and the GND to GND. (The GND pins from the 2 different power sources need to be connected).

  2. Hi,

    Hope you can hep.

    I have followed all the instructions but the WS2812B node says not available and is greyed out instead of green and ok. Everything is in the flow space and on the UI as per the instructions.

    If i pull in another rpi gpio node and set the gpio pin it says ok and is green.

    Any idea what could be happening as im stuck!


      • Hi.
        I also don’t know why that’s happening and how to fix it.
        If you find any solution to that problem, please share with us.
        Sara 🙂

        • I had the same issue, I added a sudo to the “curl -sS | bash” and everything loaded and worked fine.

          For the newbies like me cut and paste this (remove the quotes””)
          “sudo curl -sS | bash”
          then something will happen!

    • Hi.
      We have other readers complaining about the same issue.
      I have no idea why that’s happening.
      I also tried searching online for a reason and I can’t find anything about that.
      If anyone knows why that is happening and how to fix it, please share!
      Sara 🙂

  3. Glad its not just me as Ive tried multiple times and re-read through the instructions and steps! Its driving me crazy as Im new to Node red and coding in general.

    I can confirm that my GPIO Pin 18 works fine. And if i run the unicornhat examples such as through terminal it all works with the neopixel lights. Just cant get the rpi neopixel node to connect

    • Hi Michael.
      I’m sorry that is happening to you and to other of our readers.
      Maybe it is something wrong with the node itself.
      We have to try it out ourselves and understand what is going on.
      Sara 🙂

  4. Hi,

    Nice tutorial, thanks!

    But i was wondering why you connect both 5v and 3.3v cables on the PI, and then change the 3.3v to 5v with the low level converter.

    Why not directly connect 5V to the led strip?

    PS. i have never used a breadboard before

    • Hi. You can power the strip with 5V directly on the +5V pin.
      In this example, we’re connecting 3.3V and 5V to the level shifter because we want to convert the 3.3V signal to 5V.
      Powering the strip by connecting the +5V to the breadboard, in this case, is the same as connecting directly to the Pi 5V pin.
      I hope this is clear.

  5. Possible solution Michael Duckett. I had the same issue but with the dashboard nodes. Nothing seemed to help it always looked the same where node-red didn’t recognize the nodes. I even created a new img for the raspberry pi and node red didn’t change so I opened up node red from an incognito window and it fixed it. Try emptying your browser cache and hopefully that will work.

Leave a Comment

Download our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.