'Why does SimpleMFRC522.write not work when using RFID device on the raspberry-pi?
I just want to connect an RFID device to my raspberry. I did everything as in the tutorial (https://pimylifeup.com/raspberry-pi-rfid-rc522/) but as soon as I want to write to an RFID tag it no longer works. This is my code:
#!/usr/bin/env python
import RPi.GPIO as GPIO
from mfrc522 import SimpleMFRC522
reader = SimpleMFRC522()
try:
text = input('New data:')
print("Now place your tag to write")
reader.write(text)
print("Written")
finally:
GPIO.cleanup()
and this is the error it gave me after I press control+c (I press control+c because after I write in the data nothing happens at all):
Now place your tag to write
^CTraceback (most recent call last):
File "/home/pi/pi-rfid/Write.py", line 11, in <module>
reader.write(text)
File "/usr/local/lib/python3.9/dist-packages/mfrc522/SimpleMFRC522.py", line 62, in write
id, text_in = self.write_no_block(text)
File "/usr/local/lib/python3.9/dist-packages/mfrc522/SimpleMFRC522.py", line 66, in write_no_block
(status, TagType) = self.READER.MFRC522_Request(self.READER.PICC_REQIDL)
File "/usr/local/lib/python3.9/dist-packages/mfrc522/MFRC522.py", line 259, in MFRC522_Request
(status, backData, backBits) = self.MFRC522_ToCard(self.PCD_TRANSCEIVE, TagType)
File "/usr/local/lib/python3.9/dist-packages/mfrc522/MFRC522.py", line 210, in MFRC522_ToCard
self.Write_MFRC522(self.CommandReg, command)
File "/usr/local/lib/python3.9/dist-packages/mfrc522/MFRC522.py", line 159, in Write_MFRC522
val = self.spi.xfer2([(addr << 1) & 0x7E, val])
KeyboardInterrupt
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
