As shown in the previous tutorial, using the MFRC522-python library (https://github.com/mxgxw/MFRC522-python.git) and the data read example script, I'm able to read the UniqueID (UID) of my NFC card.
On GPIO17 (= pin 11) I have the 220v relay signal that open the electric door lock. Therefore, editing the read example script, if an allowed UID is read than the door will be opened!
I add also a log file to control if somebody try to force the system
import RPi.GPIO as GPIOimport MFRC522import signalimport timeimport logging# Logginglogging.basicConfig(filename='/var/www/nfc.log',filemode='a',format='%(asctime)s %(levelname)s %(message)s',datefmt='%d/%m/%Y %H:%M:%S',level=logging.DEBUG)logging.info("script initialized")# Create an object of the class MFRC522MIFAREReader = MFRC522.MFRC522()# 220v relay - electric door openerGPIO.setmode(GPIO.BOARD) ## Use board pin numberingGPIO.setup(11, GPIO.OUT) ## Setup GPIO17 -> pin 11 to OUTGPIO.output(11,1)# This loop keeps checking for chips. If one is near it will get the UID and authenticatewhile true:# Scan for cards(status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)# If a card is foundif status == MIFAREReader.MI_OK:# Get the UID of the card(status,uid) = MIFAREReader.MFRC522_Anticoll()# If we have the UID, continueif status == MIFAREReader.MI_OK:# My card UIDmyUID = [141,113,243,56, 231]# Check if authenticatedif uid == myUID:# open the doorGPIO.output(11,0)time.sleep(1)GPIO.output(11,1)# save to log filelogging.info('Authenticated uid = %s' % uid)else:logging.error('Authentication failed uid = %s' % uid)