mxgxw / MFRC522-python

A small class to interface with the NFC reader Module MFRC522
GNU Lesser General Public License v3.0
526 stars 420 forks source link

how run RC522 by using SPI1 #54

Open mohamedmohsen20 opened 6 years ago

mohamedmohsen20 commented 6 years ago

Hi, I try to use my RPi3 and the RC522 and a touchscreen display aswell so i need to put my RC522 on the SPI1 How can I do it ?

muhammadAgfian96 commented 4 years ago
  1. Change wiring, to SPI1 with others friend (MOSI, MISO, SLCK, CE2), reference https://pinout.xyz/pinout/spi

  2. Enable SPI1 on /boot/config.txt: dtoverlay=spi1-3cs

  3. reboot ur system sudo reboot

  4. open terminal ls /dev/spidev* and you will see: /dev/spidev1.0 /dev/spidev1.1 /dev/spidev1.2

  5. Initialize class MFRC522 with this (on Read.py or Write.py) MIFAREReader = MFRC522.MFRC522(dev='/dev/spidev1.XX') if you using CE2 --> /dev/spidev1.2 if you using CE1 --> /dev/spidev1.1 if you using CE0 --> /dev/spidev1.0

if you have problem with SPI that says:

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)

just do this (reference on Stackoverflow derweili answer ):

git clone https://github.com/lthiery/SPI-Py.git
git checkout 8cce26b9ee6e69eb041e9d5665944b88688fca68
sudo python setup.py install