Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/python3
# Use this python script to read RFID tag with sb components RFID reader
#
# The original script is located at https://github.com/sbcshop/RFID-Breakout
#
# Added shebang to make the script executable on its own using python3
import serial #import serial module
def read_rfid ():
ser = serial.Serial ("/dev/ttyS0") #Open named port, if using RXD , TXD pin
#ser = serial.Serial ("/dev/ttyUSB0") # with raspberry pi/linux usb interface
#ser = serial.Serial ("COM2") # with windows, use assigned com port number from device manager
ser.baudrate = 9600 #Set baud rate to 9600
data = ser.read(12) #Read 12 characters from serial port to data
ser.close () #Close port
data=data.decode("utf-8")
return data #Return data
while True:
id = read_rfid () #Function call
print (id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment