0

as the title suggest I am unable to interface the MFRC522 module with a raspberry pi pico W. For context I mostly followed this explanation and after further research I found it is the most commonly used method. But my problem is that It doesn't want to work with me. I tried multiple hardware fix ideas such as replacing the wires, Soldering the headers etc. But nothing seems to work. Which leads me to suspect it is a software issue ? I found on another question on SO that suggests a different code which I tried but still nothing. The new code is as follows :

Main.py

import time
from machine import I2C, Pin, SPI

from mfrc522 import MFRC522

sck = Pin(2, Pin.OUT)
mosi = Pin(3, Pin.OUT)
miso = Pin(4, Pin.OUT)
spi = SPI(0, baudrate=100000, polarity=0, phase=0, sck=sck, mosi=mosi, miso=miso)
sda = Pin(1, Pin.OUT)
rst = Pin(0, Pin.OUT)

while True:
    rdr = MFRC522(spi, sda, rst)
    uid = ""
    (stat, tag_type) = rdr.request(rdr.REQIDL)
    print(stat)
    if stat == rdr.OK:
        (stat, raw_uid) = rdr.anticoll()
        if stat == rdr.OK:
            uid = ("0x%02x%02x%02x%02x" % (raw_uid[0], raw_uid[1], raw_uid[2], raw_uid[3]))
            print(uid)

the SO post in question is this one I hope I made things clear.

RaoufM
  • 525
  • 5
  • 22
  • I don't know if there are other issues, but MISO (master-in-slave-out) is an input to the master, not an output. You have `miso = Pin(4, Pin.OUT)`. – pmacfarlane Feb 20 '23 at 21:36
  • Unfortunately I updated that detail and it still gives me the same result. When I output the stat it is still a 2 meaning an error – RaoufM Feb 20 '23 at 21:55
  • 1
    Probably best to get a logic analyser or oscilloscope to see what the SCK, MISO and MOSI signals are doing. And the sda signal, which I think is really SS. – pmacfarlane Feb 20 '23 at 22:17

0 Answers0