# Pirate Audio: SPI puzzle: Multiple SPI devices possible on a Pi?

**URL:** <https://forums.pimoroni.com/t/pirate-audio-spi-puzzle-multiple-spi-devices-possible-on-a-pi/24722>\
**Category:** Support\
**Created:** [April 28, 2024, 1:54pm UTC](https://forums.pimoroni.com/t/pirate-audio-spi-puzzle-multiple-spi-devices-possible-on-a-pi/24722 "2024-04-28T13:54:03Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![owntheweb](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/owntheweb/32/10657_2.png) [@owntheweb](https://forums.pimoroni.com/u/owntheweb)\
**Post date:** [April 28, 2024, 1:54pm UTC](https://forums.pimoroni.com/t/pirate-audio-spi-puzzle-multiple-spi-devices-possible-on-a-pi/24722/1 "2024-04-28T13:54:04Z")

</div>

![boombox-in-progress](https://us1.discourse-cdn.com/flex016/uploads/pimoroni/original/2X/9/98d4983d7d9d7625846ec9b7af60f6ba32ea8614.jpeg)

Hello gurus,  
I’m building my little one a mini boombox with a Pirate Audio at the center of it. It’s still a heap of wires (and the case needs design updates as I learn), yet it’s moving along well. I’m able to successfully test all of the components of this project separately like playing audio (super fun as a Spotify device yet not project goal), draw to the screen with Python PIL, scan RFID “cartridges” that will be used to trigger sound and read a volume value from a potentiometer via a connected ADC. Super fun!

I could use an extra brain as I figure out SPI surrounding the Pirate Audio display and my RFID reader (RFID-RC522). They are trying to use the same pins and I’m not sure if they can co-exist in the way or not as I catch up on SPI. If I activate the display, my RFID reader no longer reads, so I know so far that they are conflicting. As an alternative to SPI, I learned that the RFID-RC522 can also use I2C, which would pair well with my volume readings, [yet enabling this is rather odd](https://forum.arduino.cc/t/rc522-rfid-rc522-switching-spi-to-uart-interface-or-i2c-possible/425741/11) (not ideal as I ponder a tutorial for others and future memory).

Would you have ideas on how to get these two devices to play nice with each other? Here’s the RFID library I’m using that has a few options for switching things around. I was able to remove one pin already to avoid conflicting with the Pirate Audio Y button (I’m just reading uids and was able to skip this) and move another pin to not conflict with the amp enable pin:  
[st7789-python/examples/shapes.py at master · pimoroni/st7789-python (github.com)](https://github.com/pimoroni/st7789-python/blob/master/examples/shapes.py)

Also because I’m a visual person, here’s a pretty chart that describes potential conflicts and where I’m connected now. This based on a Pirate Audio pinout chart I found [here](https://pinout.xyz/pinout/pirate_audio_headphone_amp):

 ![spi-puzzle2](https://us1.discourse-cdn.com/flex016/uploads/pimoroni/original/2X/a/a342340251a7d8a60322042098ab205e4298fbda.png)

Here are the settings I’m currently using when enabling the display:

```auto
self.st7789 = ST7789(
    rotation=self.rotation, # Display the right way up on Pirate Audio
    port=0, # SPI port
    cs=1, # SPI port Chip-select channel
    dc=9, # BCM pin used for data/command
    backlight=13,
    spi_speed_hz=self.spi_speed_mhz * 1000 * 1000
)

```

Here’s what enabling the RFID reader currently looks like (disable IRQ, BCM pin mode enabled in init as it’s enabled in main script, moved RST pin, see [README here](https://github.com/ondryaso/pi-rc522)):

```auto
rdr = RFID(pin_irq=None, pin_mode=GPIO.BCM, pin_rst=37)

```

Thanks a ton for helping me untangle my mind in advance. I truly appreciate the feedback. ❤️

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [April 28, 2024, 7:45pm UTC](https://forums.pimoroni.com/t/pirate-audio-spi-puzzle-multiple-spi-devices-possible-on-a-pi/24722/2 "2024-04-28T19:45:26Z")

</div>

You can have multiple devices on an SPI bus, as long as each device uses a different Chip Select Pin.  
[SPI at Raspberry Pi GPIO Pinout](https://pinout.xyz/pinout/spi)

This is my crib sheet for SPI on a Pi

SPI0  
GPIO 7, Pin 26, CE1  
GPIO 8, Pin 24, CE0  
GPIO 9, Pin 21, MISO  
GPIO 10, Pin 19, MOSI  
GPIO 11, Pin 23, SCLK

SPI1  
GPIO 16, Pin 36, CE2  
GPIO 17, Pin 11, CE1  
GPIO 18, Pin 12, CE0  
GPIO 19, Pin 35, MISO  
GPIO 20, Pin 38, MOSI  
GPIO 21, Pin 40, SCLK

/boot/config.txt

dtparam=spi=on

dtoverlay=spi1-1cs #1 chip select  
dtoverlay=spi1-2cs #2 chip select  
dtoverlay=spi1-3cs #3 chip select

SCLK - Serial ClocK  
CE - Chip Enable (often called Chip Select)  
MOSI - Master Out Slave In  
MISO - Master In Slave Out  
MOMI - Master Out Master In

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [April 28, 2024, 8:01pm UTC](https://forums.pimoroni.com/t/pirate-audio-spi-puzzle-multiple-spi-devices-possible-on-a-pi/24722/3 "2024-04-28T20:01:42Z")

</div>

I think you have the display config wrong, port=1 is SPI 1. I’m pretty sure it uses SPI 0.

```auto
import ST7789

SPI_SPEED_MHZ = 80

st7789 = ST7789(
    port=0,
    cs=1,
    dc=9,
    backlight=13,
    rotation=90,
    spi_speed_hz=SPI_SPEED_MHZ * 1000 * 1000
)

```

---

<div class="post-metadata">

**Author:** ![owntheweb](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/owntheweb/32/10657_2.png) [@owntheweb](https://forums.pimoroni.com/u/owntheweb)\
**Post date:** [April 28, 2024, 9:36pm UTC](https://forums.pimoroni.com/t/pirate-audio-spi-puzzle-multiple-spi-devices-possible-on-a-pi/24722/4 "2024-04-28T21:36:43Z")

</div>

You’re right @alphanumeric . That was some last-minute thrashing before I decided help was needed (will correct post).

---

<div class="post-metadata">

**Author:** ![owntheweb](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/owntheweb/32/10657_2.png) [@owntheweb](https://forums.pimoroni.com/u/owntheweb)\
**Post date:** [April 28, 2024, 9:38pm UTC](https://forums.pimoroni.com/t/pirate-audio-spi-puzzle-multiple-spi-devices-possible-on-a-pi/24722/5 "2024-04-28T21:38:52Z")

</div>

Nice! 🤩 Thanks for this feedback @alphanumeric . This helps a TON. I’ll give this a shot today and let you know how it goes!

---

<div class="post-metadata">

**Author:** ![owntheweb](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/owntheweb/32/10657_2.png) [@owntheweb](https://forums.pimoroni.com/u/owntheweb)\
**Post date:** [April 28, 2024, 10:13pm UTC](https://forums.pimoroni.com/t/pirate-audio-spi-puzzle-multiple-spi-devices-possible-on-a-pi/24722/6 "2024-04-28T22:13:16Z")

</div>

It seems like SP1 may interfere with Pirate Audio I2S audio signals. It’s good to know it’s an option though (brain grows)! I’ll dig a bit more and also look into RFID hardware alternatives (including that I2C conversion of RFID reader, also advertises UART). More updates soon.

update: one alternative I’m looking into:  
[gassajor000/pn532pi: Python interface for ndef communication using PN532 chip on raspberry pi (github.com)](https://github.com/gassajor000/pn532pi)

---

<div class="post-metadata">

**Author:** ![bablokb](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@bablokb](https://forums.pimoroni.com/u/bablokb)\
**Post date:** [April 29, 2024, 6:41am UTC](https://forums.pimoroni.com/t/pirate-audio-spi-puzzle-multiple-spi-devices-possible-on-a-pi/24722/7 "2024-04-29T06:41:43Z")

</div>

I think the core problem is that Pimoroni misuses the MISO-pin for LCD Data/Command. The RFID does data-transfer from device to host and needs this pin. The Pi has hardware-SPI and I think there is no way to move this pin to some other place.

I stumbled across this problem already a while ago when I tried to attach the Pirate-Audio hat to a Pico. The LCD and I2S work fine, but I could not add a SD-card to the SPI-bus for the same reason.

Usually the hardware from Pimoroni is of high quality, but here I just don’t understand why they used a reserved pin instead of choosing one of the many other free pins that the Pi has.

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [April 29, 2024, 8:56am UTC](https://forums.pimoroni.com/t/pirate-audio-spi-puzzle-multiple-spi-devices-possible-on-a-pi/24722/8 "2024-04-29T08:56:32Z")

</div>

> [@owntheweb](#):
>
> It seems like SP1 may interfere with Pirate Audio I2S audio signals.

Yeah, it’s GPIO 19, Pin 35, MISO. It’s also use by the Pirate Audio for i2s. Bummer. :(  
[Pirate Audio Line Out at Raspberry Pi GPIO Pinout](https://pinout.xyz/pinout/pirate_audio_line_out)

---

<div class="post-metadata">

**Author:** ![bablokb](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@bablokb](https://forums.pimoroni.com/u/bablokb)\
**Post date:** [April 29, 2024, 11:59am UTC](https://forums.pimoroni.com/t/pirate-audio-spi-puzzle-multiple-spi-devices-possible-on-a-pi/24722/9 "2024-04-29T11:59:49Z")

</div>

I2S is only possible on GPIO18/GPIO19. And that is multiplexed with SPI1. That is just how it is. I haven’t seen a HAT that actually uses SPI1. So you usually have it for yourself, well, unless you also need I2S.

---

<div class="post-metadata">

**Author:** ![owntheweb](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/owntheweb/32/10657_2.png) [@owntheweb](https://forums.pimoroni.com/u/owntheweb)\
**Post date:** [April 30, 2024, 3:54am UTC](https://forums.pimoroni.com/t/pirate-audio-spi-puzzle-multiple-spi-devices-possible-on-a-pi/24722/10 "2024-04-30T03:54:48Z")

</div>

Thanks for the feedback @alphanumeric and @bablokb . At the moment I’m playing with [this reader](https://github.com/gassajor000/pn532pi) (arrived much faster than expected!). It seems straight forward and I’m able to detect the I2C address so far. After running into errors when running the examples, I found this (may or may not be related):

> The Raspberry Pi 3.3v regulator does not provide enough current to drive the PN532 chip. If you try to run the PN532 off your Raspberry Pi it will reset randomly and may not respond to commands. Instead you will need another power source (3.3v) to power the PN532. Some people have been able to run the PN532 off of the 5V rail of the raspberry pi but this is not the recommended way of powering it.

Hmm… I wonder if I’ll need a 5V → 3.3V converter from the battery power for this. I’m starting to cram a lot into this little boombox. I’ll give it a break and resume tomorrow. :)

---

<div class="post-metadata">

**Author:** ![bablokb](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@bablokb](https://forums.pimoroni.com/u/bablokb)\
**Post date:** [April 30, 2024, 5:51am UTC](https://forums.pimoroni.com/t/pirate-audio-spi-puzzle-multiple-spi-devices-possible-on-a-pi/24722/11 "2024-04-30T05:51:14Z")

</div>

You could use the TLV62569 (Adafruit 4711, fixed 3V3 output) or a MINI-360 based on a MP2307 (variable output voltage, with a fiddly screw, very small and very cheap).
