1

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)

Maciej Treder
  • 155
  • 1
  • 9

2 Answers2

3

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.

joan
  • 71,852
  • 5
  • 76
  • 108
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

Maciej Treder
  • 155
  • 1
  • 9