Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » IoT RGB LED Strip Control with Raspberry Pi Pico W & Adafruit IO
Raspberry Pi Raspberry Pi Pico W Projects

IoT RGB LED Strip Control with Raspberry Pi Pico W & Adafruit IO

Mamtaz AlamBy Mamtaz AlamUpdated:January 12, 20238 Comments7 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
IoT RGB LED Strip Control with Raspberry Pi Pico W & Adafruit IO
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview

In this IoT project, we will control a NeoPixel RGB LED Strip using Raspberry Pi Pico W & Adafruit IO. MicroPython has a built-in library for controlling NeoPixels. Together with the WiFi-capable Raspberry Pi Pico W, we can control NeoPixel RGB LED Strip over the Internet.

The WS2812 RGB LED Strip also called NeoPixels can show beautiful light colors. The Neopixel RGB LED has 3 LEDs inside which when mixed in some proportions can produce any color. Moreover, NeoPixels are also addressable which means if we chain multiple NeoPixels together, we are able to control individual NeoPixels by using their own addresses.

In this tutorial, we will use a popular IoT platform called Adafruit IO. Adafruit IO is a platform designed to display, respond, and interact with IoT project data. The dashboards allow users to visualize data and control Adafruit IO connected projects from any modern web browser using widgets such as charts, sliders, and buttons.

This tutorial covers:

  • MicroPython usage to control NeoPixel RGB LED Strio
  • How to get data from Adafruit IO via its REST APIs
  • How to use the data from Adafruit IO to control NeoPixel RGB LED




Components Required

We need the following components for this project. You can purchase all these components from SunFounder Amazon link which consists of the necessary sensors & modules along with 200+ components.

  1. Raspberry Pi Pico W – 1
  2. RGB LED Strip with – 1
  3. Jumper Wires – 10
  4. Breadboard – 1
  5. Micro-USB Cable – 1

Circuit & Hardware Setup

Let us set up the hardware for controlling Neopixel RGB LED Strip with Raspberry Pi Pico W & Adafruit IO. The connection is very simple. The NeoPixel LED Strip is addressable, we only need one digital pin to control the entire chain of LEDs.

Neopixel RGB LED Strip Raspberry Pi Pico W Adafruit IO

Connect the 5V, GND, and Output pin of NeoPixel RGB LED Strip to VSYS, GND & GP0 Pin of Raspberry Pi Pico W respectively. The total number of RGB LED used in this guide is 8.

If you need to use more than a few NeoPixels, you should use an external power rather than the power pin of the microcontroller. This is because NeoPixels actually draw quite a lot of power.

Neopixel RGB LED Raspberry Pi Pico W



Setting up Adarfuit IO Feeds & Dashboard

Before working on the project, you need an Adafruit account first. Visit io.adafruit.com and follow the instructions to create a free account.

Now we need to create 3 feeds. To do that click on Feeds tab.

Click on “+New Feed” & give the feed name as Red and click on create.

Create 3 different feeds with name like Red, Green & Blue.

Now we need to set up the Dashboards. To do that click on the Dashboards tab.

Give the name to the Dashboard as NeoPixel and click on Create.

Finally a dashboard called NeoPixel is created.

Click on the NeoPixel, so that the Dashboard will open.

Click on the Setting sign of the dashboard. Here you will see multiple options like edit layout, create new layout along with Mode, and Block Borders setup.

Click on ‘Create a New Block’ & from the list select a ‘Slider’.

Connect to a feed called ‘Blue’ and then click on ‘Next step’.

In the block setting the slider minimum and the maximum value is set to 0 and 255 respectively. Similarly, the slider step size is 1 and the decimal point is 0. Then click on Create block.

Similarly create the two remaining blocks in the same way and with the same settings. Finally, your slider dashboard for R, G & B is ready.

You can now manipulate the data with the sliders. The values of the three feeds will be updated accordingly.

Click on the Key symbol on the top right of the dashboard and from here you need to copy the ‘username’ and ‘Adafruit IO Key’.

Finally the software setup is complete and we need to move to the programming part.



MicroPython Code

Now let us see the MicroPython Code to Control WS2812 NeoPixel RGB LED Strip with Raspberry Pi Pico & Adafruit IO. It is very easy to use REST APIs with Raspberry Pi Pico W and MicroPython to get data from the Adafruit IO.

Open your Thonny IDE and open a New Tab. Then you can paste the code below. You need to make some changes to the following lines of the code before running it.

1
2
3
4
wlan.connect("SSID","Password")
 
aio_key = "Adafruit IO Key"
username = "Adafruit IO Username"

Replace the WiFi SSID and Password with your WiFi SSID Name and Password. Similarly change the Adafruit IO Key and also the username.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from machine import Pin
from neopixel import NeoPixel
from time import sleep
import network
import urequests as requests
import ujson
 
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect("SSID","Password")
 
# Adafruit IO authentication
aio_key = "Adafruit IO Key"
username = "Adafruit IO Username"
headers = {'X-AIO-Key': aio_key, 'Content-Type': 'application/json'}
 
# Don't forget the NeoPixels!
np = NeoPixel(Pin(0), 8)
feed_names = ['red', 'green', 'blue']
rgb_values = {'red': 0, 'green': 0, 'blue': 0}
 
# connect the network      
wait = 10
while wait > 0:
    if wlan.status() < 0 or wlan.status() >= 3:
        break
    wait -= 1
    print('waiting for connection...')
    time.sleep(1)
 
# Handle connection error
if wlan.status() != 3:
    raise RuntimeError('wifi connection failed')
else:
    print('connected')
    ip=wlan.ifconfig()[0]
    print('IP: ', ip)
    
def create_URL(feedname):
    url = "https://io.adafruit.com/api/v2/" + username + "/feeds/" + feedname + "/data/last"
    return url
 
try:
    while True:
        for color in feed_names:
            response = requests.get(create_URL(color), headers=headers)
            parsed = ujson.loads(response.text)
            value = int(parsed['value'])
            rgb_values[color] = value
            print(value)
        for i in range(8):
            np[i] = (rgb_values['red'], rgb_values['green'], rgb_values['blue'])
            np.write()
except KeyboardInterrupt:
    for i in range(8):
        np[i] = (0, 0, 0)
        np.write()
        time.sleep(0.5)

Save the file to file to Raspberry Pi Pico W and name it as Main.py. You can now run the code.


Code Explanation

First we import the necessary library required to control RGB LED Strip with Raspberry Pi Pico W library.

1
2
3
4
5
6
from machine import Pin
from neopixel import NeoPixel
from time import sleep
import network
import urequests as requests
import ujson

The following lines contains the information to connect the Raspberry Pi Pico W to WiFi Network using SSID & Password.

1
2
3
4
5
6
7
wlan.active(True)
wlan.connect("SSID","Password")
 
# Adafruit IO authentication
aio_key = "2e0cc5a*************a0ab70"
username = "*****************"
headers = {'X-AIO-Key': aio_key, 'Content-Type': 'application/json'}

Using the Adafruit IO username and Rest API key, the Raspberry Pi Pico W will establish the connection with Adafruit IO Dashboard.

The we define the Neopixel digital pin as 0 and total number of LED strip as 8.

1
2
3
np = NeoPixel(Pin(0), 8)
feed_names = ['red', 'green', 'blue']
rgb_values = {'red': 0, 'green': 0, 'blue': 0}

The array feed_names contains the names of the feeds that we have created in Adafruit IO, and the dictionary rgb_values is used for storing the values downloaded from Adafruit IO.

The Raspberry Pi Pico will connect to the WiFi Network & print the IP Address.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# connect the network      
wait = 10
while wait > 0:
    if wlan.status() < 0 or wlan.status() >= 3:
        break
    wait -= 1
    print('waiting for connection...')
    time.sleep(1)
 
# Handle connection error
if wlan.status() != 3:
    raise RuntimeError('wifi connection failed')
else:
    print('connected')
    ip=wlan.ifconfig()[0]
    print('IP: ', ip)

Since we need to get the values of three feeds, and each feed has its own URL. Therefore we create a function for making the required URL.

1
url = "https://io.adafruit.com/api/v2/" + username + "/feeds/" + feedname + "/data/last"

In the main loop, for each of the feeds ‘red’, ‘green’ and ‘blue’, we send an HTTP GET request to Adafruit IO with the URL made by the create_URL function and the headers dictionary.

1
response = requests.get(create_URL(color), headers=headers)

Then, we use the loads function in the ujson library to convert the JSON text received from Adafruit IO into a Python dictionary. This conversion is known as parsing.

1
parsed = ujson.loads(response.text)

From the Python dictionary parsed, we get the latest value of the feed (which is a string) and convert it into an integer.

1
value = int(parsed['value'])

After saving all the RGB values to the dictionary rgb_values, we can set the color of the NeoPixels accordingly.




Controlling RGB LED Strip with Raspberry Pi Pico W & Adafruit IO

After running the code, the Raspberry Pi Pico W will connect to the WiFi Network using the WiFi SSID & Password. Then it establishes the connection with Adafruit IO using the API Key.

Now you can send commands from Adafruit IO Dashboard with sliding different slides. This will control the color intensity and brightness.

The range of the color is from 0 to 255 for all red, green, and blue. You can slide all three slides to control the RGB Color.

You may generate red color by sliding Red Slider only.

NeoPixel LED Strip Raspberry Pi Pico W

As an example, you may adjust red, green & blue color slider to generate purple color.

RGB LED Strip Pi Pico W

The green color brightness intensity can be increased or decreased by adjusting the slider between 0 to 255 and keeping red and blue as 0.

Neopixels Raspberry Pi Pico W

Keeping the red, green & blue color to 255 can produce a pure white color.

You can only turn on the Blue Color LED by sliding the Blue slider.

RGB LED Strip Raspberry Pi Pico W

This is how you can control any NeoPixel RGB LED Strip with Raspberry Pi Pico W & MicroPython Code using Adafruit IO Dashboard.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleIoT Based Solar Power Monitoring System with ESP32
Next Article Interface MS5611 Barometer & Altimeter Sensor with Arduino

Related Posts

ADXL375 Accelerometer with Raspberry Pi Pico & MicroPython

ADXL375 Accelerometer with Raspberry Pi Pico & MicroPython

Updated:July 24, 2025
Interface BMI160 with Raspberry Pi Pico & MicroPython

Interface BMI160 with Raspberry Pi Pico & MicroPython

Updated:February 2, 20253K
Shift Register 74HC595 with Raspberry Pi Pico & MicroPython

Shift Register 74HC595 with Raspberry Pi Pico & MicroPython

Updated:February 2, 202513K
Interfacing XBee Module with Raspberry Pi Pico & MicroPython

Interfacing XBee Module with Raspberry Pi Pico & MicroPython

Updated:February 2, 20253K
Modbus RTU with Raspberry Pi Pico & Micropython

Modbus RTU with Raspberry Pi Pico & MicroPython

Updated:February 2, 20258K
Fever Detector with MLX90640 & OpenCV Raspberry Pi

Thermal Fever Detector with MLX90640 & OpenCV Raspberry Pi

Updated:February 2, 20256K
View 8 Comments

8 Comments

  1. Deepak on January 20, 2023 6:41 PM

    Getting error in the code …
    Keyerror : value

    Reply
  2. Deepak on January 20, 2023 6:42 PM

    Getting error in the code …
    Keyerror : value

    Reply
  3. Andrew on January 29, 2023 5:56 PM

    I too am getting the KeyError: value. Feed data from Adafruit not coming through?

    Reply
  4. Andrew on January 30, 2023 1:45 AM

    For whatever reason, deleting the dashboard (but not the feeds themselves) at adafruit seemed to fix the problem KeyError problem but then I ran into the problem of VSYS (5V) not working, so I switched to 3V3 and voila! It worked. But wondering why not with my 5V setup?

    Reply
  5. Igor on February 11, 2023 9:32 AM

    I have also met the Keyerror: value problem.
    Has somebody found a solution?

    Reply
  6. MiketheYeti on March 12, 2023 11:35 AM

    Has anyone solved the Keyerror: value problem issue ?.

    Reply
  7. Sam on April 13, 2023 7:31 PM

    If you are getting a Keyerror: value error make sure that your username and Adafruit key are in the right lines and not switched.

    Reply
  8. NikkiD on May 7, 2023 7:56 AM

    Worked GREAT! Thank you for the easy to follow tutorial! Now working on how to make it wireless and start up at power.

    Reply

CommentsCancel reply

Latest Posts
ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 16, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • IoT Based PM & Air Quality Monitoring System using ESP32
    IoT Based PM & Air Quality Monitoring System using ESP32
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
    ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
  • ESP32 Fingerprint Attendance System with Live Web Dashboard
    ESP32 Fingerprint Attendance System with Live Web Dashboard
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.