You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pi-rc522 consists of two Python classes for controlling an SPI RFID module "RC522" using Raspberry Pi. You can get this on AliExpress for $3.
2
+
pi-rc522 consists of two Python classes for controlling an SPI RFID module "RC522" using Raspberry Pi. You can get this module on AliExpress or Ebay for $3.
3
3
4
4
Based on [MFRC522-python](https://github.com/mxgxw/MFRC522-python/blob/master/README.md).
5
5
6
-
You'll need **SPI-Py**. Recently Raspbian switched to newer version of SPI driver. This caused compatibility issues with the outdated SPI-Py. Hence it's required to use a slightly modified version of SPI-Py. You can find it [**here**](https://github.com/mab5vot9us9a/SPI-Py).
6
+
You'll also need to install the [**SPI-Py**](https://github.com/lthiery/SPI-Py) library.
7
7
8
8
[MIFARE datasheet](http://www.nxp.com/documents/data_sheet/MF1S503x.pdf) can be useful.
9
9
@@ -29,87 +29,87 @@ and you can connect RST pin to any other free GPIO pin and call the constructor
29
29
__NOTE:__ For RPi A+/B+/2/3 with 40 pin connector, SPI1/2 is available on top of SPI0. Kernel 4.4.x or higher and *dtoverlay* configuration is required. For SPI1/2, *pin_ce=__BOARD numbering pin__* is required.
30
30
31
31
## Usage
32
-
The library is split to two classes - **RFID** and **RFIDUtil**. You can use only RFID, RFIDUtil just makes life a little bit better.
32
+
The library is split to two classes - **RFID** and **RFIDUtil**. You can use only RFID, RFIDUtil just makes life a little bit better.
33
33
You basically want to start with *while True* loop and "poll" the tag state. That's done using *request* method. Most of the methods
34
34
return error state, which is simple boolean - True is error, False is not error. The *request* method returns True if tag is **not**
35
35
present. If request is successful, you should call *anticoll* method. It runs anti-collision alghoritms and returns used tag UID, which
36
-
you'll use for *select_tag* method. Now you can do whatever you want. Important methods are documented. You can also look to
37
-
Read and KeyChange modules for RFIDUtil usage example.
36
+
you'll use for *select_tag* method. Now you can do whatever you want. Important methods are documented. You can also look at the Read and KeyChange examples for RFIDUtil usage.
38
37
39
38
```python
40
-
rdr =RFID.RFID()
39
+
from pirc522 importRFID
40
+
rdr = RFID()
41
+
41
42
whileTrue:
42
43
(error, tag_type) = rdr.request()
43
44
ifnot error:
44
-
print("Tag detected")
45
+
print("Tag detected")
45
46
(error, uid) = rdr.anticoll()
46
47
ifnot error:
47
-
print("UID: "+str(uid))
48
-
#Select Tag is required before Auth
48
+
print("UID: "+str(uid))
49
+
#Select Tag is required before Auth
49
50
ifnot rdr.select_tag(uid):
50
-
#Auth for block 10 (block 2 of sector 2) using default shipping key A
51
+
#Auth for block 10 (block 2 of sector 2) using default shipping key A
0 commit comments