The TFT screen has a 26 pin header, designed for the older Pi boards. It also has a breakout connector underneath giving access to these same pins.
The RFID board is connected as per the instructions here: https://github.com/ondryaso/pi-rc522
My problem is that I can either have the TFT screen working, or the RFID, but not both at the same time. At the moment I have commented out this line in
/boot/config.txt to work on the RFID:
I'm a bit stuck trying to figure out if it's possible to have both the TFT and the RFID connected and working. I understand there may be an alternative way to connect the RFID to a second SPI
What have I tried?
I have enabled
/boot/config.txt and can see the following:
crw-rw---- 1 root spi 153, 0 Aug 2 19:01 spidev0.1 crw-rw---- 1 root spi 153, 1 Aug 2 19:01 spidev1.0
But when I run my
RFIDUtil.py (from ondryaso GitHub), it errors out with:
$ sudo python rfid-util.py Traceback (most recent call last): File "rfid-util.py", line 5, in <module> rdr = RFID() File "/home/pi/Development/printer/rfid/pirc522/rfid.py", line 68, in __init__ self.spi.open(bus, device) IOError: [Errno 2] No such file or directory
The code is as follows:
from pirc522 import RFID import signal import time rdr = RFID() util = rdr.util() # Set util debug to true - it will print what's going on util.debug = True while True: # Wait for tag rdr.wait_for_tag() # Request tag (error, data) = rdr.request() if not error: print("\nDetected") (error, uid) = rdr.anticoll() if not error: # Print UID print("Card read UID: "+str(uid)+","+str(uid)+","+str(uid)+","+str(uid)) # Set tag as used in util. This will call RFID.select_tag(uid) util.set_tag(uid) # Save authorization info (key B) to util. It doesn't call RFID.card_auth(), that's called when needed util.auth(rdr.auth_b, [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]) # Print contents of block 4 in format "S1B0: [contents in decimal]". RFID.card_auth() will be called now util.read_out(4) # Print it again - now auth won't be called, because it doesn't have to be util.read_out(4) # Print contents of different block - S1B2 - RFID.card_auth() will be called again util.read_out(6) # We can change authorization info if you have different key in other sector util.auth(rdr.auth_a, [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]) #If you want to use methods from RFID itself, you can use this for authorization # This will authorize for block 1 of sector 2 -> block 9 # This is once more called only if it's not already authorized for this block util.do_auth(util.block_addr(2, 1)) # Now we can do some "lower-level" stuff with block 9 rdr.write(9, [0x01, 0x23, 0x45, 0x67, 0x89, 0x98, 0x76, 0x54, 0x32, 0x10, 0x69, 0x27, 0x46, 0x66, 0x66, 0x64]) # We can rewrite specific bytes in block using this method. None means "don't change this byte" # Note that this won't do authorization, because we've already called do_auth for block 9 util.rewrite(9, [None, None, 0xAB, 0xCD, 0xEF]) # This will write S2B1: [0x01, 0x23, 0xAB, 0xCD, 0xEF, 0x98, 0x76......] because we've rewritten third, fourth and fifth byte util.read_out(9) # Let's see what do we have in whole tag util.dump() # We must stop crypto util.deauth()
These questions are similar, but haven't got me a working solution as yet.
- How to enable SPI1 and SPI0 at the same time?
- How to enable spi1? / pi 3 and two rc522 RFID readers
- How to connect 2 RFID readers (RC522)
I have access to PiZero 1.3 and PiZero W if that makes any difference? Any help greatly appreciated.