Adafruit_CircuitPython_NeoPixel: not support more than 30 LEDs bug

not support more than 30 LEDs bug

Why are many LEDs not lit?

image

environment

Raspberry Pi 3B, BCM GPIO 18 PIN

5V/2.5A unofficial power supply (⚠️ There may be a low voltage error)

Python 3.9.2

one WS2812B RGB LED strip of 1M long with 60 LEDs

packages

$ sudo pip3 install rpi_ws281x

$ sudo pip3 install adafruit-circuitpython-neopixel

$ sudo pip3 install --force-reinstall adafruit-blinka
# equal to
$ sudo python3 -m pip install --force-reinstall adafruit-blinka

codes

#!/usr/bin/env python3
# coding: utf8

import board
import neopixel
from time import sleep

# 60 LEDs
pixels = neopixel.NeoPixel(board.D18, 60)
while True:
  for x in range(0, 60):
    pixels[x] = (255, 0, 0)
    sleep(0.1)

"""
$ chmod +x ./led-strip.py
# ❌ Can't open /dev/mem: Permission denied
# $ ./led-strip.py

# ✅
$ sudo ./led-strip.py
"""

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 2
  • Comments: 18 (5 by maintainers)

Most upvoted comments

update 2023.06.01

60 LEDs with 255 brightness level need to add an external Power Supply.

5V/4A power.

image

image

But the test result is not expected

image

The test code is as follows, why doesn’t every LED light up red?

#!/usr/bin/env python3
# coding: utf8

import board
import neopixel
from time import sleep

# 60 LEDs
pixels = neopixel.NeoPixel(board.D18, 60)

def red_led_strip():
  for x in range(0, 60):
    pixels[x] = (255, 0, 0)
    sleep(0.1)
    print("pixels[x] =", x, pixels[x])

def clear_buffer():
  for x in range(0, 60):
    pixels[x] = (0, 0, 0)

try:
  red_led_strip()
except KeyboardInterrupt:
  print('Ctrl + C exit ✅')
except RuntimeError as error:
  print("error =", error, error.args[0])
  pass
except Exception as error:
  print("exception =", error)
  raise error
finally:
  print("after three seconds, auto clear buffer! 👻")
  sleep(3.0)
  # cleanup
  clear_buffer()
  print('clear 🚀')


"""
$ chmod +x ./led-strip.py
# ❌ Can't open /dev/mem: Permission denied
# $ ./led-strip.py

# ✅
$ sudo ./led-strip.py
"""

image

ok, at last the problem solved here for my RPI 3 b. I commented the line #dtparam=audio=on in /boot/config.txt file.

it gives throttled=0x50000. and works in undervoltage also. Posting it might help someone. check this link(Pi 3B user): https://tutorials-raspberrypi.com/connect-control-raspberry-pi-ws2812-rgb-led-strips/

2023.06.12 update

It’s not a bug of the neopixel.

#!/usr/bin/env python3
# coding: utf8

import board
import neopixel
from time import sleep

# 60 LEDs
pixels = neopixel.NeoPixel(board.D18, 60)

def red_led_strip():
  for x in range(0, 60):
    pixels[x] = (255, 0, 0)
    sleep(0.1)
    # print("pixels[x] =", x, pixels[x])
    print("pixels[{}] =".format(x), x, pixels[x])

def clear_buffer():
  for x in range(0, 60):
    pixels[x] = (0, 0, 0)

try:
  red_led_strip()
except KeyboardInterrupt:
  print('Ctrl + C exit ✅')
except RuntimeError as error:
  print("error =", error, error.args[0])
  pass
except Exception as error:
  print("exception =", error)
  raise error
finally:
  print("after three seconds, auto clear buffer! 👻")
  sleep(3.0)
  # cleanup
  clear_buffer()
  print('clear 🚀')


"""
$ chmod +x ./led-strip.py
# ❌ Can't open /dev/mem: Permission denied
# $ ./led-strip.py

# ✅
$ sudo ./led-strip.py
"""

image

The BTF-LIGHTING brand is a great product ✅

This is an excellent product 🚀, I recommend buying it!

image

https://item.taobao.com/item.htm?id=522197656009

Hardware change

Raspberry Pi 3B 1GB => Raspberry Pi 4B 8GB

Raspberry Pi 4B + 15W official power supply ✅

$ vcgencmd get_throttled
throttled=0x0

Raspberry Pi 3B + 5V/2.5A unofficial power supply ❌

$ vcgencmd get_throttled
throttled=0x50000

I meant that the way the wires are connected leaves them exposed so a person could accidentally touch them. Ideally that should be secured more so it’s not possible to accidentally touch the live wires.

What happens if you try like this:

pixels = neopixel.NeoPixel(board.D18, 60, order=neopixel.RGBW)
# ...

# then down inside of your loop:

    pixels[x] = (255, 0, 0, 0)  # <- add the fourth item in the tuple for the White in RGBW.

@FoamyGuy Thanks for your time!

AC to DC, 5V/2.5A Power Supply (Micro USB)

  1. just use the Raspberry Pi 3B 5V GPIO PIN
  2. I didn’t configure the brightness level for it. (the brightness level should be the default value)

I will try your suggestions later.

how to clear the WS2812B’s buffer data?

buffer cache error?

#!/usr/bin/env python3
# coding: utf8

import board
import neopixel
from time import sleep

# 60 LEDs
pixels = neopixel.NeoPixel(board.D18, 60)

def clear_buffer():
  for x in range(0, 60):
    pixels[x] = (0, 0, 0)