0

Ok, So I have one RC522 reader working with no issues. I want to have 3. I don't care which receiver picks up the RFID tag, I just want to know whenever a tag was picked up at all by any of them. Essentially, if I detect any RFID tag with an expectation of just one unique tag at a time, I want to get the RFID tag number and do stuff with it. I am using the MFRC522.py library to control the device.

I was reading through a bunch of other guides and it seems there is a chip select and a way to set overlays. I set the 3cs overlay in order to have 3, but the default CS0 (18) pin doesn't seem to work the way I expect. Previously, I used the standard CE0 (24) pin and my code worked, but after changing the overlay and moving the pin to 18, the one reader is not working (though it still works on 24).

What am I missing here? I'm not super new to coding and hardware, but I'm also no pro in the hardware area.

EDIT for further clarification:

I have one currently working RC522. It's connected via pin 24 - CE0 as well as the MISO/MOSI/SCLK pins. And, at the end of the day I want to have all three working together on the same Rpi. The code can be found here - https://github.com/DevMattM/MFRC522-python

The library I am using uses SpiDev, and does a spi.open(0,0).

As far as pins go, I am just going by the pin number, not GPIO number, but after reading your comment and checking the pin out ( GPIO Pinout Orientation RaspberyPi Zero W) we are talking about the same pin. Thank you for clarifying.

  • So what exactly is the question? Did you already attach three readers and they didn't work? – RalfFriedl Jun 8 at 21:25
  • Are you using the following statement to select SPI CE0/1? device_0 = spi.openSPI(device="/dev/spidev0.0",mode=0,speed=500000,bits=8,delay=0) Link: github.com/lthiery/SPI-Py – tlfong01 Jun 9 at 0:39
  • I am a bit confused. You mentioned CS0 (18) and CE0 (24). But the Rpi CE0/1 pins are GPIO pin 8/7. – tlfong01 Jun 9 at 0:54
  • @RalfFriedl I've updated my post with some more information, thank you for your assistance. – Matthew Jun 9 at 1:50
  • @tlfong01, after reviewing the pinouts, it seems we are talking about the same pins. I'm still working my way around the proper ways to talk about these kind of hardware issues. – Matthew Jun 9 at 1:52
0

Question

How can Rpi talk to 3 SPI RFID reader at the same time?

Answers

Short Answer

No problem. You use the NSS (Not Slave Selected) signal to disslect what you don't want.

rfid nss

/ to continue, ...

Long Answer

/ to continue, ...

References

PN532/C1 Near Field Communication (NFC) controller - NXP 2017

AliExpress RC522 Modules

AliExpress PN532 NFC RFID Module V3

Adafruit PN532 NFC/RFID Controller Shield for Arduino + Extras $40

RFID Selection Guide - EBV Elektronik

MFRRC522 Python

SPI-Py: Hardware SPI as a C Extension for Python - Louis Thiery

/ to continue, ...

Appendices

Appendix A - Rpi Pinout

rpi pinout

Appendix B - Use Rpi/MCP23017 GPIO pins to select more than 16 SPI Devices

Instead of RPi’s built in CE0, CE1 signals. I can use, says, 6 GPIO pins as CE0, CE1, to CE5 pins to select 6 SPI devices.

In other words, I almost never only use Rpi’s GPIO pins for "GPIO" - I only use them for SPI select or similar demux jobs. I only use the I2C, SPI, and UART pins. This way I can easily port my python/microPython software and I2C/SPI/UART hardware between Rpi, PyBoard, MicroBit, and CircuitPython etc.

For selecting more than 16 SPI devices, my trick is using MCP23017 GPIO signals to pretend to be CEn signals. So, only 1 MCP23017 can chip select 16 SPI devices. And I can use two MCP23017 to select 32 SPI devices. I have tried it a couple of times and so far so good.

Appendix C - RC522 Module Pinout

rc522 pinout

  • Thanks, I was finally able to understand how to get more than one working. So, the only thing I noticed was that they don't run together. After doing some research, it seems I can only have one at a time running? So, what I tried instead was to connect all 3 RC522 to the same CE0 chipselect. Now, they all seem to work at the same time and all will return the RFID tag they pick up. But this doesn't seem stable and sometimes has weird behavior. I want them all to work together in this fashion, but be reliable. What am I missing? – Matthew Jun 10 at 23:59
  • Ah, now I understand why I found your connection a bit confusing. Actually the SPI is designed in such a way that only one master (Rpi) talks to more than one slaves (RFID guys) . So you can connect Rpi CE0 to SS (slave select, chip select, or other names) of one RFID module, and CE1 to SS of another RFID module. If the master pulls low either CE0 or CE1 to select which slave. In other words, you CANNOT connect more than one device's SS pin to CE0 or CE1. Now if you wish to have more slaves, you can DIY your own CE2, CE3 etc by using GPIO pins to pretend to be CEs. – tlfong01 Jun 11 at 2:02
  • Gotcha, I understand. So, is this the case even if I don't care about which slave is on/reads the RFID chip? I was able to run 2 RC522 on the same SS, and both read a chip at the same time (or at least within seconds of each other on the same running code). When I connected a third RC522 to the same SS, things failed, my guess is too much current draw. – Matthew Jun 11 at 12:53
  • So, here's a synopsis of what I am trying to do. I want to put 3 RC522 readers side by side inside of a book facing the cover that will be constantly on. When an RFID chip gets waved over the book, I want any module to read it, send the RFID tag number over to the code, and then I will perform whatever task I want (the RFID reading will be paused while the code executes). Then, the next RFID tag will be waved over, rinse and repeat. I am building this for the average user and want to make it super easy for the chip to be detected wherever on the book cover it is placed, hence three modules. – Matthew Jun 11 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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