Hi,
Was hoping someone might be able to help. For my project I am wanting to use two 12 led Neopixel RGBW rings and two 7 led RGBW NP rings driven with a Trinket M0. Nothing fancy, I just wanted the rings to do the spin effect and maybe fade on and off. So, I prepped the Trinket M0; I am using a Mac so I had to get rid of the hidden files so I had space to upload the code. Did that, then made sure I had the neopixel library file installed as well. Using the MU editor I've saved the code to the Trinket (I used code one of the moderators on Discord suggested I use). Loaded fine as far as I can tell, I get the occasional green led blink from the built in Neopixel. So, here's the problem; I cannot get the rings to light up at all. I've disconnected all but one of the rings. I've tried various output pins, I've powered everything via a benchtop power supply (5VDC), powered it with a 3.7v battery but I still get nothing from the rings. I've tried a different Trinket M0, tried all of the rings individually....and still nothing. Oh yeah, I've just about exhausted every example of NP ring code I could find here on the site, but I am getting nothing at all.
Any suggestions or info would be greatly appreciated!
James
Trinket M0 and RGBW Neopixel Rings not working
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- sincity337
- Posts: 21
- Joined: Fri Apr 10, 2020 12:26 am
- dastels
- Posts: 15659
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Trinket M0 and RGBW Neopixel Rings not working
Try powering the Neopixels from the 3v output of the Trinket.
Start by testing them from the REPL.
Dave
Start by testing them from the REPL.
Dave
- sincity337
- Posts: 21
- Joined: Fri Apr 10, 2020 12:26 am
Re: Trinket M0 and RGBW Neopixel Rings not working
Hi,
Got the ring connected to the 3v out. Turned on REPL and this is what I get:
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 7.2.5 on 2022-04-06; Adafruit Trinket M0 with samd21e18
>>>
I am currently running each line through REPL and I've gotten stuck here:
>>> pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.3, auto_write=False,
... pixel_order=(1, 0, 2, 3))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'NeoPixel'
James
Got the ring connected to the 3v out. Turned on REPL and this is what I get:
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 7.2.5 on 2022-04-06; Adafruit Trinket M0 with samd21e18
>>>
I am currently running each line through REPL and I've gotten stuck here:
>>> pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.3, auto_write=False,
... pixel_order=(1, 0, 2, 3))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'NeoPixel'
James
- dastels
- Posts: 15659
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Trinket M0 and RGBW Neopixel Rings not working
Yes. It looks like you need to have neopixel.mpy in CIRCUITPY/lib and start by
Please post all the code you are entering at the REPL.
Dave
Code: Select all
import neopixel
Dave
- sincity337
- Posts: 21
- Joined: Fri Apr 10, 2020 12:26 am
Re: Trinket M0 and RGBW Neopixel Rings not working
OK,
So here is what I get back in the REPL.
So here is what I get back in the REPL.
Also, I did verify I had the Neopixel.mpy in the lib folder...I had to go through the hassle of using the console to manually copy the file to the folder because of the limited amount of space on the Trinket anytime I try and drag and drop anything to the Trinket, it adds metadata to the file...ughAdafruit CircuitPython 7.2.5 on 2022-04-06; Adafruit Trinket M0 with samd21e18
>>> import time
>>> import board
>>> import neopixel
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "neopixel.py", line 20, in <module>
ImportError: no module named 'adafruit_pixelbuf'
>>> pixel_pin = board.D0
>>> num_pixels = 7
>>> pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.3, auto_write=False,
... pixel_order=(1, 0, 2, 3))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'neopixel' is not defined
>>>
- dastels
- Posts: 15659
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Trinket M0 and RGBW Neopixel Rings not working
Code: Select all
ImportError: no module named 'adafruit_pixelbuf'
Import errors like that indicate a missing library/module.
It's been quite a while since the entire bundle could fit on a board.
Dave
- sincity337
- Posts: 21
- Joined: Fri Apr 10, 2020 12:26 am
Re: Trinket M0 and RGBW Neopixel Rings not working
Dave,
Ok. I will give it a try today….hopefully I can squeeze another file on there! It’s just frustrating that I’ve been following all the instructions I can find, and I still can’t just make the thing work. I didn’t think I was doing anything cosmic!
James
Ok. I will give it a try today….hopefully I can squeeze another file on there! It’s just frustrating that I’ve been following all the instructions I can find, and I still can’t just make the thing work. I didn’t think I was doing anything cosmic!
James
- sincity337
- Posts: 21
- Joined: Fri Apr 10, 2020 12:26 am
Re: Trinket M0 and RGBW Neopixel Rings not working
Hi again!
OK, managed to get that library copied over. I am putting the code in REPL section by section. When I get to the part of the code that defines the colors, I get the following message that continuously refreshes in the REPL:
"Memory Error: memory allocation failed, allocating 3825 bytes.
I also checked using the command line and this is what I have showing for space (I've cleaned off the hidden files):
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk2s1 47Ki 40Ki 7.5Ki 85% 512 0 100% /Volumes/CIRCUITPY
While I'm at it, can I get rid of the following files from the hid library folder?
keyboard..._us.mpy
keyboard.mpy
key code.mpy
mouse.mpy
OK, managed to get that library copied over. I am putting the code in REPL section by section. When I get to the part of the code that defines the colors, I get the following message that continuously refreshes in the REPL:
"Memory Error: memory allocation failed, allocating 3825 bytes.
I also checked using the command line and this is what I have showing for space (I've cleaned off the hidden files):
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk2s1 47Ki 40Ki 7.5Ki 85% 512 0 100% /Volumes/CIRCUITPY
While I'm at it, can I get rid of the following files from the hid library folder?
keyboard..._us.mpy
keyboard.mpy
key code.mpy
mouse.mpy
Code: Select all
import time
import board
import neopixel
pixel_pin = board.D0
num_pixels = 7
pixels = neopixel.NeoPixel(
pixel_pin, num_pixels, brightness=0.3, auto_write=False, pixel_order=(1, 0, 2, 3)
)
def colorwheel(pos):
# Input a value 0 to 255 to get a color value.
# The colours are a transition r - g - b - back to r.
if pos < 0 or pos > 255:
return (0, 0, 0, 0)
if pos < 85:
return (255 - pos * 3, pos * 3, 0, 0)
if pos < 170:
pos -= 85
return (0, 255 - pos * 3, pos * 3, 0)
pos -= 170
return (pos * 3, 0, 255 - pos * 3, 0)
def color_chase(color, wait):
for i in range(num_pixels):
pixels[i] = color
time.sleep(wait)
pixels.show()
time.sleep(0.5)
def rainbow_cycle(wait):
for j in range(255):
for i in range(num_pixels):
rc_index = (i * 256 // num_pixels) + j
pixels[i] = colorwheel(rc_index & 255)
pixels.show()
time.sleep(wait)
RED = (255, 0, 0, 0)
YELLOW = (255, 150, 0, 0)
GREEN = (0, 255, 0, 0)
CYAN = (0, 255, 255, 0)
BLUE = (0, 0, 255, 0)
PURPLE = (180, 0, 255, 0)
while True:
pixels.fill(RED)
pixels.show()
# Increase or decrease to change the speed of the solid color change.
time.sleep(1)
pixels.fill(GREEN)
pixels.show()
time.sleep(1)
pixels.fill(BLUE)
pixels.show()
time.sleep(1)
color_chase(RED, 0.1) # Increase the number to slow down the color chase
color_chase(YELLOW, 0.1)
color_chase(GREEN, 0.1)
color_chase(CYAN, 0.1)
color_chase(BLUE, 0.1)
color_chase(PURPLE, 0.1)
rainbow_cycle(0) # Increase the number to slow down the rainbow
- dastels
- Posts: 15659
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Trinket M0 and RGBW Neopixel Rings not working
IMO you have 3 options:
1. You can try using an older version of CircuitPython (and libraries) 6.x or 5.x. The memory use has changed over time so this might work with an older version.
2. You can get a bigger (on the inside) board. A QtPy perhaps (not the SAMD21/M0 version,,, you'll have the same problem with it). https://www.adafruit.com/product/5325 or https://www.adafruit.com/product/4900 will work nicely.
3. You can switch to writing in C++/Arduino.
As for those mpy files, you can delete them since you're not using them. But that won't help with a memory allocation error which is about RAM not Flash.
Dave
1. You can try using an older version of CircuitPython (and libraries) 6.x or 5.x. The memory use has changed over time so this might work with an older version.
2. You can get a bigger (on the inside) board. A QtPy perhaps (not the SAMD21/M0 version,,, you'll have the same problem with it). https://www.adafruit.com/product/5325 or https://www.adafruit.com/product/4900 will work nicely.
3. You can switch to writing in C++/Arduino.
As for those mpy files, you can delete them since you're not using them. But that won't help with a memory allocation error which is about RAM not Flash.
Dave
- sincity337
- Posts: 21
- Joined: Fri Apr 10, 2020 12:26 am
Re: Trinket M0 and RGBW Neopixel Rings not working
Dave,
Thanks so much for the reply. Those two boards you mentioned; do you think they'll be able to use fancyLED library? Since I'm changing hardware, It would be nice to have the option. If not, I really only need the thing to make the led rings do a spinning effect and MAYBE a fade effect...thats it.
James
Thanks so much for the reply. Those two boards you mentioned; do you think they'll be able to use fancyLED library? Since I'm changing hardware, It would be nice to have the option. If not, I really only need the thing to make the led rings do a spinning effect and MAYBE a fade effect...thats it.
James
- dastels
- Posts: 15659
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Trinket M0 and RGBW Neopixel Rings not working
I expect they will be fine running fancyLED; they have plenty of performance and memory for it.
If size isn't a constraint, there are many other options in the Feather line of boards.
Dave
If size isn't a constraint, there are many other options in the Feather line of boards.
Dave
- sincity337
- Posts: 21
- Joined: Fri Apr 10, 2020 12:26 am
Re: Trinket M0 and RGBW Neopixel Rings not working
Dave,
Thanks for the reply. I am still frustrated that I can't even get a Trinket M0 (I bought 5 of them) to even run a neopixel example, and I've tried just about every one of them. I successfully used a feather M4 (?) and it worked like a champ on another model that had room for it. I'm just not sure how I am approaching it wrong, but I've followed all of the examples and instructions to a T. Oh well, I did order a few of the boards you had mentioned, so hopefully they work for me!
Thanks for the reply. I am still frustrated that I can't even get a Trinket M0 (I bought 5 of them) to even run a neopixel example, and I've tried just about every one of them. I successfully used a feather M4 (?) and it worked like a champ on another model that had room for it. I'm just not sure how I am approaching it wrong, but I've followed all of the examples and instructions to a T. Oh well, I did order a few of the boards you had mentioned, so hopefully they work for me!
- dastels
- Posts: 15659
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Trinket M0 and RGBW Neopixel Rings not working
You don't seem to be doing anything wrong. The board just doesn't have enough memory left once CircuitPython 7 is running.
Dave
Dave
Please be positive and constructive with your questions and comments.