Issue
I've been messing around with Raspberry Pi and RFID and found this tutorial:
https://pimylifeup.com/raspberry-pi-rfid-rc522/
Everything went fine with the installation but when I'm running the script it presents an error.
This is the problem:
pi@raspberrypi:~/MFRC522-python $ sudo python Write.py
/home/pi/MFRC522-python/MFRC522.py:115: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(25, GPIO.OUT)
Traceback (most recent call last):
File "Write.py", line 6, in <module>
reader = SimpleMFRC522.SimpleMFRC522()
File "/home/pi/MFRC522-python/SimpleMFRC522.py", line 14, in __init__
self.READER = MFRC522.MFRC522()
File "/home/pi/MFRC522-python/MFRC522.py", line 117, in __init__
self.MFRC522_Init()
File "/home/pi/MFRC522-python/MFRC522.py", line 390, in MFRC522_Init
self.MFRC522_Reset();
File "/home/pi/MFRC522-python/MFRC522.py", line 120, in MFRC522_Reset
self.Write_MFRC522(self.CommandReg, self.PCD_RESETPHASE)
File "/home/pi/MFRC522-python/MFRC522.py", line 123, in Write_MFRC522
spi.transfer(((addr<<1)&0x7E,val))
TypeError: function takes exactly 2 arguments (1 given)
This is the Write.py file:
#!/usr/bin/env python
import RPi.GPIO as GPIO
import SimpleMFRC522
reader = SimpleMFRC522.SimpleMFRC522()
try:
text = raw_input('New data:')
print("Now place your tag to write")
reader.write(text)
print("Written")
finally:
GPIO.cleanup()
I can't find the solution to this problem in any place. Already tried to use Python 3 and other libraries but I'm still getting the error.
UPDATE :
Edited this on MFRC522.py file :
def Write_MFRC522(self, addr, val):
spi.transfer( (addr<<1)&0x7E, val )
And now I get this output :
/home/pi/MFRC522-python/MFRC522.py:115: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(25, GPIO.OUT)
First argument must be a valid dictionary.: Success
Aborted
Solution
I had the same issue for at least 2 hours... now i found out, that the IRQ channel of RC522 has to be soldered to pin 18 of raspberry PI... I also renewed the soldered pins on the rc522, now it works fine.. seems to be a mechanic issue, no software problem..
This also helps: https://github.com/ondryaso/pi-rc522
Befor (error msg):
pi@raspberrypi:~/MFRC522-python $ sudo python Write.py
/home/pi/MFRC522-python/MFRC522.py:115: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(25, GPIO.OUT)
Traceback (most recent call last):
File "Write.py", line 6, in <module>
reader = SimpleMFRC522.SimpleMFRC522()
File "/home/pi/MFRC522-python/SimpleMFRC522.py", line 14, in __init__
self.READER = MFRC522.MFRC522()
File "/home/pi/MFRC522-python/MFRC522.py", line 117, in __init__
self.MFRC522_Init()
File "/home/pi/MFRC522-python/MFRC522.py", line 390, in MFRC522_Init
self.MFRC522_Reset();
File "/home/pi/MFRC522-python/MFRC522.py", line 120, in MFRC522_Reset
self.Write_MFRC522(self.CommandReg, self.PCD_RESETPHASE)
File "/home/pi/MFRC522-python/MFRC522.py", line 123, in Write_MFRC522
spi.transfer(((addr<<1)&0x7E,val))
TypeError: function takes exactly 2 arguments (1 given)
Now:
pi@raspberrypi:~ $ sudo python rfidreader2.py
/usr/local/lib/python2.7/dist-packages/pi_rc522-2.2.1-py2.7.egg/pirc522/rfid.py:78: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
clean up
Tag detected
UID: [169, 112, 111, 72, 254]
Reading block 10: (False, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
Answered By - eldorado