use two rfid 522 readers

October 12, 2024, 07:27

oops.se

There are many different RFID readers...

chayzze

I have the RC522. I would like to use two RC522 readers and be able to know which of the readers read the tag

oops.se

And there are SPI, I2C and serial interfaces on them, some has all and some has just one or two interfaces. An advice, the less information you provide, the less is the probability that someone engage and help you.

chayzze

As part of a project, I need to know by which reader the tag was read. Reader 1 is connected to the pin: SDA : pin 24 SCK : pin 23 MOSI : pin 19 MISQ : pin 21 IRQ : pin 11 GND : pin 14 RST : pin 29 3.3V : pin 1 Reader 2 is connected to the pin: SDA : pin 26 SCK : pin 23 MOSI : pin 19 MISQ : pin 21 IRQ : pin 11 GND : pin 14 RST : pin 29 3.3V : pin 1 And I'm stuck with the code because when I ask to read on reader 2 it always reads on 1 from mfrc522 import SimpleMFRC522 import RPi.GPIO as GPIO import time reader = SimpleMFRC522() GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) CS_1 = 8 CS_2 = 7 GPIO.setup(CS_1, GPIO.OUT) GPIO.setup(CS_2, GPIO.OUT) try: while True: GPIO.output(CS_1, GPIO.LOW) GPIO.output(CS_2, GPIO.HIGH) print("Approchez une carte du lecteur 1") id, text = reader.read() print("ID : %s\nText : %s" % (id, text)) time.sleep(1) GPIO.output(CS_1, GPIO.HIGH) GPIO.output(CS_2, GPIO.LOW) print("Approchez une carte du lecteur 2") id, text = reader.read() print("ID : %s\nText : %s" % (id, text)) time.sleep(1) except KeyboardInterrupt: print("Arrêté par l'utilisateur") finally: GPIO.cleanup()