Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardware schematic to stack Rpi Hats #30

Open
phcuriel opened this issue Dec 6, 2022 · 2 comments
Open

Hardware schematic to stack Rpi Hats #30

phcuriel opened this issue Dec 6, 2022 · 2 comments

Comments

@phcuriel
Copy link

phcuriel commented Dec 6, 2022

More of a request: Is there a hardware schematic documented to what pins are being used and what LED location to what pin?. To determine if can stack another shield/hat. I wanted to see if i could stack another Pi hat "PiFace-Digital2" that has two relays. That hat uses hardware SPI and wanted to use one of the Relays to control another xmas decoration while using the RGB xmas tree.

@tommycusick
Copy link

I was curious about the same thing, and it turns out that you can see the traces on the board itself if you look closely. Here's what I see for the GPIO pinout:

  • Pin 2: 5V
  • Pin 6: GND
  • Pin 22 (GPIO 25): SPI MOSI
  • Pin 32 (GPIO 12): SPI clock

Those SPI pins are also referenced in tree.py's constructor for RGBXmasTree:

rgbxmastree/tree.py

Lines 38 to 40 in 24fe82e

class RGBXmasTree(SourceMixin, SPIDevice):
def __init__(self, pixels=25, brightness=0.5, mosi_pin=12, clock_pin=25, *args, **kwargs):
super(RGBXmasTree, self).__init__(mosi_pin=mosi_pin, clock_pin=clock_pin, *args, **kwargs)

Notably, I don't see a reference to a chip select pin for RGBXmasTree, so I'm not sure if it'll play nicely with other devices on the same bus. You may need to experiment further on that front, or else find a way for your other devices to use a different SPI bus.

@phcuriel
Copy link
Author

phcuriel commented Dec 12, 2022

Yeah, I had initially mistakenly assumed that the LEDS were controlled by different Rpi IO pins. Seems like the RGB LEDs have an embedded SPI chip and only use (Data, Clock, Power, Gnd). I remembered I had used a version of these before called Neopixel LEDs. Somehow they are still individually addressable but they don't use the full SPI implementation since they don't use the “select” or “miso” pin of SPI.

Looking at the GPIOZero library called in the initiation it said if pins are not defined they declare the default pin assignments. For MISO, SELECT this would conflict with the other piFace hat I wanted to stack that does have hardwired and make use of the “select” pin 8
https://gpiozero.readthedocs.io/en/stable/api_spi.html#

I replaced two lines of code on tree.py to declare MISO and SELECT to pins 23 and 24 even though it's not used by rgbxmastree just so it does not interfere with the other hat. So they are assigned but floating since not connected to anything.
def __init__(self, pixels=25, brightness=0.5, mosi_pin=12, clock_pin=25, miso_pin=23, select_pin=24, *args, **kwargs):
super(RGBXmasTree, self).__init__(mosi_pin=mosi_pin, clock_pin=clock_pin, miso_pin=miso_pin, select_pin=select_pin, *args, **kwargs)

After some trial and error I got the rgbxmastree and the piFace hat working . Reading GPIOZero documentation it seems that it can only run software or hardware implementation of SPI but not both at the same time. For my application it's not a big limitation. I'm running randomsparkles.py. and the other hat piFace drives another decoration with a chime that plays for 1 min every hour. While it's playing the rgbxmastree stops sparkling. After chime ends then rgbxmastree resumes sparkling.

The only thing I had to do on the piFace code was to make sure to de-initialize the SPI instance at the end of script so that when it ends randomandomsparkles.py continues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants