Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ def do_read():
rdr = mfrc522.MFRC522("GP14", "GP16", "GP15", "GP22", "GP17")
elif uname()[0] == 'esp8266':
rdr = mfrc522.MFRC522(0, 2, 4, 5, 14)

elif uname()[0] == 'esp32':
rdr = mfrc522.MFRC522(18, 23, 19, 4, 2)

else:
raise RuntimeError("Unsupported platform")

Expand Down Expand Up @@ -43,4 +47,4 @@ def do_read():
print("Failed to select tag")

except KeyboardInterrupt:
print("Bye")
print("Bye")
3 changes: 3 additions & 0 deletions mfrc522.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ 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 == 'esp32':
self.spi = SPI(baudrate=100000, polarity=0, phase=0, sck=self.sck, mosi=self.mosi, miso=self.miso)
self.spi.init()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as you are doing precisely the same thing as 3 lines above, how about just changing line 32 to:

elif board == 'esp8266' or board == 'esp32':

else:
raise RuntimeError("Unsupported platform")

Expand Down