diff --git a/README.md b/README.md index ff50f49..9202d18 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,9 @@ Basic class to access RFID readers of the type [MFRC522](http://www.nxp.com/docu This is basically a re-write of [this](https://github.com/mxgxw/MFRC522-python) Python port for the MFRC522. I tried to strip things down and make them more "pythonic" so the result is small enough to run on [Micropython](https://github.com/micropython/micropython) boards. I tried the class so far on the -[ESP8266](https://github.com/micropython/micropython/tree/master/esp8266) and -the [WiPy](https://github.com/micropython/micropython/tree/master/cc3200). +[ESP8266](https://github.com/micropython/micropython/tree/master/ports/esp8266), +the [WiPy](https://github.com/micropython/micropython/tree/master/ports/cc3200) +and [Pi Pico](https://github.com/micropython/micropython/tree/master/ports/rp2). ## Usage @@ -16,15 +17,15 @@ For the ESP8266 there are multiple solutions to do that. E.g. use the I used the following pins for my setup: -| Signal | GPIO ESP8266 | GPIO WiPy | Note | -| --------- | ------------ | -------------- | ------------------------------------ | -| sck | 0 | "GP14" | | -| mosi | 2 | "GP16" | | -| miso | 4 | "GP15" | | -| rst | 5 | "GP22" | | -| cs | 14 | "GP14" |Labeled SDA on most RFID-RC522 boards | +| Signal | GPIO ESP8266 | GPIO WiPy | GPIO Pi Pico | Note | +| --------- | ------------ | -------------- | -------------- | ------------------------------------ | +| sck | 0 | "GP14" | 18 | | +| mosi | 2 | "GP16" | 19 | | +| miso | 4 | "GP15" | 16 | | +| rst | 5 | "GP22" | 20 | | +| cs | 14 | "GP17" | 17 | SDA on most RFID-RC522 boards | -Now enter the REPL you could run one of the two exmaples: +Now enter the REPL you could run one of the two examples: For detecting, authenticating and reading from a card: diff --git a/examples/read.py b/examples/read.py index 783d554..ef9246e 100644 --- a/examples/read.py +++ b/examples/read.py @@ -4,10 +4,12 @@ def do_read(): - if uname()[0] == 'WiPy': + if uname()[0] == 'WiPy' or board == 'LoPy' or board == 'FiPy': rdr = mfrc522.MFRC522("GP14", "GP16", "GP15", "GP22", "GP17") elif uname()[0] == 'esp8266': rdr = mfrc522.MFRC522(0, 2, 4, 5, 14) + elif uname()[0] == 'rp2': + rdr = mfrc522.MFRC522(18, 19, 16, 20, 17) else: raise RuntimeError("Unsupported platform") @@ -43,4 +45,4 @@ def do_read(): print("Failed to select tag") except KeyboardInterrupt: - print("Bye") \ No newline at end of file + print("Bye") diff --git a/examples/write.py b/examples/write.py index 7878d83..ed0a879 100644 --- a/examples/write.py +++ b/examples/write.py @@ -4,10 +4,12 @@ def do_write(): - if uname()[0] == 'WiPy': + if uname()[0] == 'WiPy' or board == 'LoPy' or board == 'FiPy': rdr = mfrc522.MFRC522("GP14", "GP16", "GP15", "GP22", "GP17") elif uname()[0] == 'esp8266': rdr = mfrc522.MFRC522(0, 2, 4, 5, 14) + elif uname()[0] == 'rp2': + rdr = mfrc522.MFRC522(18, 19, 16, 20, 17) else: raise RuntimeError("Unsupported platform") diff --git a/mfrc522.py b/mfrc522.py index 1833d75..a9a48af 100644 --- a/mfrc522.py +++ b/mfrc522.py @@ -32,6 +32,8 @@ def __init__(self, sck, mosi, miso, rst, cs): elif board == 'esp8266': self.spi = SPI(baudrate=100000, polarity=0, phase=0, sck=self.sck, mosi=self.mosi, miso=self.miso) self.spi.init() + elif board == 'rp2': + self.spi = SPI(0, baudrate=100000, sck=self.sck, mosi=self.mosi, miso=self.miso) else: raise RuntimeError("Unsupported platform")