Skip to content

Instantly share code, notes, and snippets.

@lamoboos223
Created October 9, 2023 15:52
Show Gist options
  • Save lamoboos223/15d2751738e0caa6b917fe41935c124f to your computer and use it in GitHub Desktop.
Save lamoboos223/15d2751738e0caa6b917fe41935c124f to your computer and use it in GitHub Desktop.
sudo raspi-config
sudo reboot
lsmod | grep spi
sudo apt-get update -y && sudo apt-get upgrade -y && sudo apt-get install -y python3-dev python3-pip && sudo pip install spidev mfrc522 && mkdir ~/pi-rfid && cd ~/pi-rfid
printf "
import RPi.GPIO as GPIO
from mfrc522 import SimpleMFRC522
reader = SimpleMFRC522()
try:
text = input('New Data:')
print('Place your tag on the reader')
reader.write(text)
print('Done')
finally:
GPIO.cleanup()
" > write.py
printf "
import RPi.GPIO as GPIO
from mfrc522 import SimpleMFRC522
reader = SimpleMFRC522()
try:
id, text = reader.read()
if text:
print(f"id is: {id} and text is: {text}")
else:
print("No data read from the card.")
except Exception as e:
print(e)
finally:
GPIO.cleanup()
" > read.py
printf "
import RPi.GPIO as GPIO
from mfrc522 import SimpleMFRC522
reader = SimpleMFRC522()
try:
id, text = reader.read()
if text:
print(f"id is: {id} and text is: {text}")
input('Place your new card and enter any key:')
reader.write(text)
print('Done')
else:
print("No data read from the card.")
except Exception as e:
print(e)
finally:
GPIO.cleanup()
" > clone.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment