0

Is it possible to connect two RC522 readers with one RaspberryPi 3?

As far as I know I should just choose different CS pins for them (Add more than 2 SPI slaves).

I have following connections:

1st rc522:

SDA - GPIO7/ **spi0cs0** (26)
SCK - gpio11/spi0 sclk (23)
MOSI - gpio10/spi0 mosi (19)
MISO - gpio09/spi0 miso (21)
IRQ - none
GND - ground
RST - none
3.3V - 3.3V

2nd rc522:

SDA - GPIO16/ **spi1cs0** (36)
SCK - gpio21/spi1 sclk (40)
MOSI - gpio20/spi1 mosi (38)
MISO - gpio19/spi1 miso (35)
IRQ - none
GND - ground
RST - none
3.3V - 3.3V

In my /bood/config.txt I got following lines:

device_tree_param=spi=on
dtoverlay=spi-bcm2708

dtparam=spi=on

in /dev/ I can see:

pi@raspberrypi:~/MFRC522-python $ ls /dev/spidev0.*
/dev/spidev0.0  /dev/spidev0.1

I am using this code for tests: https://github.com/mxgxw/MFRC522-python/blob/3f25de5fc1d8cbfc7d788d13eaac18fc043ce901/MFRC522.py#L110

On line 110 I am trying to switch between /dev/spidev0.1 and /dev/spidev1.1

Unfornatelly only one reader is working (when /dev/spidev0.2 is set) when I switch no reader is alive.

PS: I have also 7" display connected (in case that matter)

2

Enable SPI by adding the line dtparam=spi=on to /boot/config.txt.

This will enable the main SPI device (two slave selects).

crw-rw---- 1 root spi 153, 0 Oct 18 21:01 /dev/spidev0.0
crw-rw---- 1 root spi 153, 1 Oct 18 21:01 /dev/spidev0.1

To also enable the auxiliary SPI device (three slave selects) add the line dtoverlay=spi1-3cs to /boot/config.txt.

crw-rw---- 1 root spi 153, 4 Oct 18 21:01 /dev/spidev1.0
crw-rw---- 1 root spi 153, 3 Oct 18 21:01 /dev/spidev1.1
crw-rw---- 1 root spi 153, 2 Oct 18 21:01 /dev/spidev1.2

For options see /boot/overlays/README.

  • I have enabled spi1. Unfornatelly its not working as I thought. Changing parameter to /dev/spidev1.0 doesn't work... Problem is probalby on software side. I should connect both readers to same spi but different cs? Can I somehow spy what signals are send to SPIs? Is there any tool for that? – Maciej Treder Oct 18 '16 at 20:18
  • Your question only shows the main SPI (spidev0.0, 0.1). The main SPI only has two slave selects. There is no listing of the auxiliary SPI (spidev1.0, 1.1, 1.2) with three slave selects. – joan Oct 18 '16 at 21:07
  • I have already enabled rest of SPIs, and I can list them now in /dev/spidev* – Maciej Treder Oct 18 '16 at 21:10
  • If the devices exist the software should work. If you slow the SPI bus to around 70kbps you could check the transaction with piscope. – joan Oct 18 '16 at 21:13
  • Ok. After using piscope, i see tan miso for sp1 is dead. I tried to change wire - no result, what can I do more? It is hardware or definetely software problem? – Maciej Treder Oct 18 '16 at 22:05
0

Ok... I finally found problem.. The CS pin to which I have wired my second reader was number 3!

So:

/dev/spidev0.0 - first device /dev/spidev1.2 - second device

protected by Community Sep 15 '17 at 15:47

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.