0

RPi Cricket Hat and NeoPixel Matrix Issues
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: RPi Cricket Hat and NeoPixel Matrix Issues

by TruckerGeek on Wed Jun 26, 2019 12:01 pm

Raspberry Pi 3B+ with the Pi HAT Crickit. Fresh install of Rasbian and everything update. Most recent seesaw firmware. Python3.5.3. Most recent install of blinka.

It is almost like the first byte of the unsigned integer for the number of byte (LEDs * bpp) is being ignored.

TruckerGeek
 
Posts: 25
Joined: Sun Dec 04, 2016 4:35 pm

Re: RPi Cricket Hat and NeoPixel Matrix Issues

by dsheeran on Sun Jun 30, 2019 11:54 am

New info that also seems to support Tucker's findings. I switched to the code you mentioned as an alternate. Here is my new version...

# Crickit library demo - NeoPixel terminal
# so this demo would not control the NeoPixel terminal.
# On the Crickit FeatherWing, the NeoPixel terminal is controlled by seesaw.

# pylint can't figure out "np" can be indexed.
# pylint: disable=unsupported-assignment-operation

import time
from adafruit_crickit import crickit

numPixels = 42

crickit.init_neopixel(numPixels)

crickit.neopixel.fill(0)

# Assign to a variable to get a short name and to save time.
np = crickit.neopixel

while True:
np.fill(0)
for i in range(numPixels):
time.sleep(.25)
np[i] = (0, 100, 0)
__________________________________________

Then up to numPixels = 41 it works like a charm. At 42 it gives me the following error....

_______________________________________________________

Traceback (most recent call last):
File "/home/pi/mu_code/altTestMatrix.py", line 21, in <module>
np.fill(0)
File "/home/pi/.local/lib/python3.5/site-packages/adafruit_seesaw/neopixel.py", line 134, in fill
self[i] = color
File "/home/pi/.local/lib/python3.5/site-packages/adafruit_seesaw/neopixel.py", line 122, in __setitem__
self._seesaw.write(_NEOPIXEL_BASE, _NEOPIXEL_BUF, cmd)
File "/home/pi/.local/lib/python3.5/site-packages/adafruit_seesaw/seesaw.py", line 408, in write
i2c.write(full_buffer)
File "/home/pi/.local/lib/python3.5/site-packages/adafruit_bus_device/i2c_device.py", line 112, in write
self.i2c.writeto(self.device_address, buf, **kwargs)
File "/home/pi/.local/lib/python3.5/site-packages/busio.py", line 65, in writeto
return self._i2c.writeto(address, buffer, stop=stop)
File "/home/pi/.local/lib/python3.5/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 38, in writeto
self._i2c_bus.write_bytes(address, buffer[start:end])
File "/home/pi/.local/lib/python3.5/site-packages/Adafruit_PureIO/smbus.py", line 244, in write_bytes
self._device.write(buf)
OSError: [Errno 5] Input/output error
>>>

_____________________________________________________________________

Please let me know what you think. Thanks!

dsheeran
 
Posts: 100
Joined: Wed Aug 02, 2017 1:20 pm

Re: RPi Cricket Hat and NeoPixel Matrix Issues

by dsheeran on Sun Jun 30, 2019 12:02 pm

PS - I'm using a RPi 3B + with my Cricket for Pi.

dsheeran
 
Posts: 100
Joined: Wed Aug 02, 2017 1:20 pm

Re: RPi Cricket Hat and NeoPixel Matrix Issues

by TruckerGeek on Sun Jun 30, 2019 1:57 pm

I have found the Errno 5 is an issue with writing to much data too fast over the I2C connection. I got around that ne by setting the transmission speed to 1mbps. To do this edit the config with sudo nano /boot/config.txt
and add to the end of the file
Code: Select all | TOGGLE FULL SIZE
dtparam=i2c_baudrate=1000000

https://learn.adafruit.com/adafruit-crickit-creative-robotic-interactive-construction-kit/hacks-upgrades

I also find it helpful to set autowrite = false and use .show(). This reduces the number of writes across the I2C bus. The entire buffer is sent each time a write is made. That being said, your sample code has enough delays assuming the bus speed is set high enough on the PI.

More info: i just rebuilt my Pi with Rasbian Buster, which includes python 3.7.3. I did not make the speed hack above and have not had the errno 5. However, i have written my code to avoid huge writes quickly.

TruckerGeek
 
Posts: 25
Joined: Sun Dec 04, 2016 4:35 pm

Re: RPi Cricket Hat and NeoPixel Matrix Issues

by dsheeran on Sun Jun 30, 2019 3:07 pm

Thanks for this. May I ask - how many NeoPixels are you driving?

dsheeran
 
Posts: 100
Joined: Wed Aug 02, 2017 1:20 pm

Re: RPi Cricket Hat and NeoPixel Matrix Issues

by dsheeran on Sun Jun 30, 2019 3:56 pm

OK, more info for Adafruit! With the baud rate set dtparam=i2c_baudrate=1000000 and using this code ...

import time
from adafruit_crickit import crickit

numPixels = 128

crickit.init_neopixel(numPixels)
np = crickit.neopixel

while True:

np.fill(0)
time.sleep(1)
np.fill((100, 0, 0)) # 43 light up red
time.sleep(1)
np.fill((0, 100, 0)) # 43 light up green
time.sleep(1)
np.fill((0, 0, 100)) # 42 light up blue
time.sleep(1)

_________________
Then if I set the numPixels to 256 I get only 1 lighting up for green but with 255 set I get 82 light for blue and green and 83 light up for red.

Something clearly isn't working correctly. Will you please take another look at this issue?

dsheeran
 
Posts: 100
Joined: Wed Aug 02, 2017 1:20 pm

Re: RPi Cricket Hat and NeoPixel Matrix Issues

by TruckerGeek on Sun Jun 30, 2019 6:26 pm

I am using 2 x 60 NeoPixel strips (PID 3636). I hooked them together and I can drive 85 (60 from the first strip, 25 from the second strip).

I went to order a SeeSaw and discovered I had already ordered one, so I am going to dig it up and see if I can control the NeoPixel strips with the SeeSaw outside of the Crickit.

Your most recent findings line up with mine. Either both bytes of the BUF_LENGTH registry are not being written out or internally the NeoPixel buffer is not being allocated properly (again, one byte vs. two).

Code: Select all | TOGGLE FULL SIZE
[b]BUF_LENGTH[/b] (0x03, 16bits, Write Only)
the number of bytes currently used for the pixel array. This is dependent on when the pixels you are using are RGB or RGBW.


https://learn.adafruit.com/adafruit-seesaw-atsamd09-breakout/neopixel

TruckerGeek
 
Posts: 25
Joined: Sun Dec 04, 2016 4:35 pm

Re: RPi Cricket Hat and NeoPixel Matrix Issues

by adafruit_support_carter on Tue Aug 20, 2019 1:42 pm

@dsheeran Sorry, I think we forgot to cycle back to this thread. The issue with NeoPixels was resolved here:
viewtopic.php?f=8&t=152524#p763288
Please try updating the Seesaw firmware on your Crickit HAT:
https://learn.adafruit.com/adafruit-cri ... ur-crickit

adafruit_support_carter
 
Posts: 12974
Joined: Tue Nov 29, 2016 2:45 pm

Re: RPi Cricket Hat and NeoPixel Matrix Issues

by dsheeran on Sat Aug 24, 2019 3:34 pm

Still doesn't work. I have pasted the code and the errors below. Thanks.

____________________________________________________________

# Drive NeoPixels on the NeoPixels Block on Crickit FeatherWing
import time
from adafruit_crickit import crickit
from adafruit_seesaw.neopixel import NeoPixel

num_pixels = 256 # Number of pixels driven from Crickit NeoPixel terminal

# The following line sets up a NeoPixel strip on Seesaw pin 20 for Feather
pixels = NeoPixel(crickit.seesaw, 20, num_pixels)

def wheel(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)
if pos < 85:
return (255 - pos * 3, pos * 3, 0)
if pos < 170:
pos -= 85
return (0, 255 - pos * 3, pos * 3)
pos -= 170
return (pos * 3, 0, 255 - pos * 3)

def color_chase(color, wait):
for i in range(num_pixels):
pixels[i] = color
pixels.show()
time.sleep(wait)
pixels[i] = BLACK
pixels.show()
time.sleep(wait)
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] = wheel(rc_index & 255)
pixels.show()
time.sleep(wait)

RED = (255, 0, 0)
YELLOW = (255, 150, 0)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)
BLACK = (0, 0, 0)

while True:
# print("fill")
# 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)

print("chase")
color_chase(RED, 0.2) # Increase the number to slow down the color chase
color_chase(YELLOW, 0.2)
color_chase(GREEN, 0.2)
color_chase(CYAN, 0.2)
color_chase(BLUE, 0.2)
color_chase(PURPLE, 0.2)

print("rainbow")
rainbow_cycle(0) # Increase the number to slow down the rainbow

_________________________________________________________________________

chase
Traceback (most recent call last):
File "/home/pi/mu_code/cricket_neopixels.py", line 64, in <module>
color_chase(RED, 0.2) # Increase the number to slow down the color chase
File "/home/pi/mu_code/cricket_neopixels.py", line 27, in color_chase
pixels.show()
File "/home/pi/.local/lib/python3.7/site-packages/adafruit_seesaw/neopixel.py", line 140, in show
self._seesaw.write(_NEOPIXEL_BASE, _NEOPIXEL_SHOW)
File "/home/pi/.local/lib/python3.7/site-packages/adafruit_seesaw/seesaw.py", line 408, in write
i2c.write(full_buffer)
File "/home/pi/.local/lib/python3.7/site-packages/adafruit_bus_device/i2c_device.py", line 112, in write
self.i2c.writeto(self.device_address, buf, **kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/busio.py", line 65, in writeto
return self._i2c.writeto(address, buffer, stop=stop)
File "/home/pi/.local/lib/python3.7/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 38, in writeto
self._i2c_bus.write_bytes(address, buffer[start:end])
File "/home/pi/.local/lib/python3.7/site-packages/Adafruit_PureIO/smbus.py", line 244, in write_bytes
self._device.write(buf)
OSError: [Errno 121] Remote I/O error

dsheeran
 
Posts: 100
Joined: Wed Aug 02, 2017 1:20 pm

Re: RPi Cricket Hat and NeoPixel Matrix Issues

by TruckerGeek on Sat Aug 24, 2019 8:26 pm

I do not import the Seesaw NeoPixel library, I use the straight up Crickit. I also set auto_write = False. This helps prevent overrunning the I2C channel/buffer. The critical ones are listed below, but I included the entire code below. I hope this helps.

from adafruit_crickit import cricket
num_pixels = 300

crickit.init_neopixel(num_pixels)
pixels = crickit.neopixel
pixels.brightness = 0.3
pixels.auto_write = False

The NeoPixel example on GitHub does not import Seesaw.
https://github.com/adafruit/Adafruit_CircuitPython_Crickit/blob/master/examples/crickit_neopixel_simpletest.py

The Crickit NeoPixel definition takes care of initializing the seesaw protocol.
Code: Select all | TOGGLE FULL SIZE
        from adafruit_seesaw.neopixel import NeoPixel
        self._neopixel = NeoPixel(self._seesaw, _NEOPIXEL, n, bpp=bpp,
                                  brightness=brightness, auto_write=auto_write,
                                  pixel_order=pixel_order)

Code: Select all | TOGGLE FULL SIZE
import time
from adafruit_crickit import crickit
# from adafruit_seesaw.neopixel import NeoPixel

num_pixels = 300  # Number of pixels driven from Crickit NeoPixel terminal

# The following line sets up a NeoPixel strip on Seesaw pin 20 for Feather
crickit.init_neopixel(num_pixels)
pixels = crickit.neopixel
pixels.brightness = 0.3
pixels.auto_write = False
pixels._pixel_order = (1,0,2)
time.sleep(1)

# pixels = NeoPixel(crickit.seesaw, 20, num_pixels, brightness=0.3, auto_write=False)

def wheel(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)
    if pos < 85:
        return (255 - pos * 3, pos * 3, 0)
    if pos < 170:
        pos -= 85
        return (0, 255 - pos * 3, pos * 3)
    pos -= 170
    return (pos * 3, 0, 255 - pos * 3)

def color_chase(color, wait):
    for i in range(num_pixels):
        pixels[i] = color
        pixels.show()
        time.sleep(wait)
        # time.sleep(0.002)
    time.sleep(0.5)

def rainbow_cycle(wait):
    for j in range(1023):
        for i in range(num_pixels):
            rc_index = (i * 256 // num_pixels) + j
            pixels[(i+j) % num_pixels] = wheel(rc_index & 255)
            # time.sleep(0.02)
        pixels.show()
        time.sleep(wait)

RED    = (127,   0,   0)
ORANGE = (127,  63,   0)
YELLOW = (127, 127,   0)
GREEN  = (0,   127,   0)
BLUE   = (0,     0, 127)
INDIGO = (37,    0,  65)
VIOLET = (119,  65, 119)
WHITE  = (255, 255, 255)

wait = 1

pixels.fill(WHITE)
pixels.show()
time.sleep(wait)

while True:
    print("fill")
    pixels.fill(RED)
    pixels.show()
    time.sleep(wait)
    pixels.fill(ORANGE)
    pixels.show()
    time.sleep(wait)
    pixels.fill(YELLOW)
    pixels.show()
    time.sleep(wait)
    pixels.fill(GREEN)
    pixels.show()
    time.sleep(wait)
    pixels.fill(BLUE)
    pixels.show()
    time.sleep(wait)
    pixels.fill(INDIGO)
    pixels.show()
    time.sleep(wait)
    pixels.fill(VIOLET)
    pixels.show()
    time.sleep(wait)

    print("chase")
    color_chase(RED, 0.1)  # Increase the number to slow down the color chase
    color_chase(ORANGE, 0.1)
    color_chase(YELLOW, 0.1)
    color_chase(GREEN, 0.1)
    color_chase(BLUE, 0.1)
    color_chase(INDIGO, 0.1)
    color_chase(VIOLET, 0.1)

    print("rainbow")
    rainbow_cycle(0.01)  # Increase the number to slow down the rainbow

TruckerGeek
 
Posts: 25
Joined: Sun Dec 04, 2016 4:35 pm

Re: RPi Cricket Hat and NeoPixel Matrix Issues

by adafruit2 on Sun Aug 25, 2019 1:32 pm

hiya please try updating the crickit firmware - does that help?
https://github.com/adafruit/seesaw/releases

adafruit2
Site Admin
 
Posts: 18660
Joined: Fri Mar 11, 2005 7:36 pm

Re: RPi Cricket Hat and NeoPixel Matrix Issues

by dsheeran on Sun Aug 25, 2019 1:45 pm

I updated the firmware yesterday. I've since discovered that if I don't use pixels.fill() everything seems to work unless I try to turn on the entire matrix - but I'm sure that's a power thing. So it looks to be working. Thanks!

dsheeran
 
Posts: 100
Joined: Wed Aug 02, 2017 1:20 pm

Re: RPi Cricket Hat and NeoPixel Matrix Issues

by TruckerGeek on Sun Aug 25, 2019 6:41 pm

You can also try using a lower brightness. For a 300 NeoPixel strip, you need about 90W or 18A @ 5V, which is a pretty good sized power supply. I have a 10A and I cannot drive the whole strip white at full brightness. However, I found that by using 30% brightness, which is what I have in my script, I can drive all of the lights. Doing the math, I could probably drive them higher (10A/18A = 55%).

With the pixel.fill(), do you get an error, or just the lights, especially near the end, produce the wrong color? For example, doing a pixel.fill((255,0,0)) would not cause a power problem as you are simply saying to turn on the RED pixels to full power, which should be about 6A (assuming you have a 10A power supply, you would be ok). If you get an error in python with a pixel.fill(), then I would still lean towards needing to set auto_write = False.

TruckerGeek
 
Posts: 25
Joined: Sun Dec 04, 2016 4:35 pm

Re: RPi Cricket Hat and NeoPixel Matrix Issues

by dsheeran on Mon Aug 26, 2019 6:57 am

It's a power thing. The Pi reboots over and over if I try the fill. I'll try your setup statement to control the brightness. Thanks!

dsheeran
 
Posts: 100
Joined: Wed Aug 02, 2017 1:20 pm

Re: RPi Cricket Hat and NeoPixel Matrix Issues

by TruckerGeek on Mon Aug 26, 2019 3:51 pm

I did have a separate 5V hooked up to the Pi, so that may have prevented the rebooting issue you had. Good luck!

TruckerGeek
 
Posts: 25
Joined: Sun Dec 04, 2016 4:35 pm

Please be positive and constructive with your questions and comments.