Skip to content

Instantly share code, notes, and snippets.

@elktros
Created February 19, 2018 09:16
Show Gist options
  • Save elktros/da138e743d127eec2d48de0cdcc28bf7 to your computer and use it in GitHub Desktop.
Save elktros/da138e743d127eec2d48de0cdcc28bf7 to your computer and use it in GitHub Desktop.
Python Script for Interfacing RFID Reader with Raspberry Pi.
import time
import serial
data = serial.Serial(
port='/dev/ttyS0',
baudrate = 9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS
)
#timeout=1 # must use when using data.readline()
#)
print " "
try:
while 1:
#x=data.readline()#print the whole data at once
#x=data.read()#print single data at once
print "Place the card"
x=data.read(12)#print upto 10 data at once and the
#remaining on the second line
if x=="13004A29E191":
print "Card No - ",x
print "Welcome Bala"
print " "
elif x=="13006F8C7282":
print "Card No - ",x
print "Welcome Teja"
print " "
else:
print "Wrong Card....."
print " "
#print x
except KeyboardInterrupt:
data.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment