0

I am trying to use a WS2812E LED-Strip with the raspberry pi.

I am using the HW131 Power Supply and a RaspberryPI 3B+. The LED strips GND is connected to both the HW131 and the RaspberryPI GND. The Strips +5V is connected only to the HW131, and the Data line is connected to the RaspberryPi at GPIO18. Although i have also tried GPIO12 and GPIO 10, which i have found in different tutorials.

Using a Multimeter i have checked that the Strip actually receives 5V. And using a logic analyser I can see the PWM Signal (however I do not know whether those are correct).

I have both tried this code (with basically all interfaces on but audio off)

import RPi.GPIO as GPIO
import time

Pin configuration

PWM_PIN = 18 # GPIO pin connected to your PWM device

GPIO setup

GPIO.setmode(GPIO.BCM) # Use BCM numbering GPIO.setup(PWM_PIN, GPIO.OUT)

Set up PWM on the pin with a frequency of 100 Hz

pwm = GPIO.PWM(PWM_PIN, 100) # 100 Hz frequency pwm.start(0) # Start with 0% duty cycle (off)

try: while True: # Gradually increase the duty cycle from 0% to 100% for duty_cycle in range(0, 101, 5): pwm.ChangeDutyCycle(duty_cycle) print(f"Duty Cycle: {duty_cycle}%") time.sleep(0.1)

    # Gradually decrease the duty cycle from 100% to 0%
    for duty_cycle in range(100, -1, -5):
        pwm.ChangeDutyCycle(duty_cycle)
        print(f"Duty Cycle: {duty_cycle}%")
        time.sleep(0.1)

except KeyboardInterrupt: print("Exiting...")

finally: pwm.stop() # Stop PWM GPIO.cleanup() # Clean up GPIO settings

And this code:

import time
import board
import neopixel

pixels = neopixel.NeoPixel(pin=board.D10, n=1, bpp=3, brightness=1.0, auto_writ>

Cycle through colors

while True: pixels.fill((255, 0, 0)) # Red pixels.show() time.sleep(1) pixels.fill((255, 255, 0)) # Green time.sleep(1) pixels.fill((255, 255, 255)) # Blue time.sleep(1)

(Pins are just set to where i tried last but i checked each time that its the actual pins)

There is nothing happening for the one LED of the strip i connected.

As i am a beginner with all of this I have no idea what else could be wrong or what I could check to find the problem. Any advice would be greatly apprechiated

Os versions:

cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
Max
  • 3
  • 3

1 Answers1

0

Bad news. I can't answer your question (I do not believe it is possible in Bookworm).
You have picked a particularly difficult first project.

WS2812 requires (microsecond) precision timing, but the methods previously used are no longer supported in Bookworm (unless you are using the latest Pi5 RP1 additions which use a different technique - similar to Pico PIO).

You first code sample (which I doubt ever worked), and certainly the methods did NOT use PWM (although they used the same GPIO as PWM).

The second (which appears to be Adafruit Circuit Python) might possibly work, but from what I have seen Adafruit don't seem to have a python11 solution. Their earlier code (6-7 years ago) used a c helper and did kind of work, but I have been unable to get anything working on recent OS.

The good news is that it is simple using Pico PIO (and much cheaper). (It is also possible on Arduino.)


I did at one stage write some code using SPI @ 8MHz (which would result in a stable signal) encoding each colour bit as 10 bits (thus 800kHz). This kind of worked; it produced colours but I couldn't get reliable results so when I found the Pico PIO code I abandoned the project.

Milliways
  • 62,573
  • 32
  • 113
  • 225