I have two raspberrys on different locations with NFC readers (RC522). They have the basic python program to open the door with one relay:
Code: Select all
#!/usr/bin/env python
# -*- coding: utf8 -*-
import RPi.GPIO as GPIO
import MFRC522
import signal
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(31, GPIO.OUT)
GPIO.output(31, GPIO.LOW)
continue_reading = True
# Capture SIGINT for cleanup when the script is aborted
def end_read(signal,frame):
global continue_reading
print " -- Beendet!"
continue_reading = False
GPIO.cleanup()
# Hook the SIGINT
signal.signal(signal.SIGINT, end_read)
# Create an object of the class MFRC522
MIFAREReader = MFRC522.MFRC522()
def relay():
GPIO.output(35, GPIO.LOW)
time.sleep(2.4)
GPIO.output(35, GPIO.HIGH)
GPIO.cleanup()
# This loop keeps checking for chips. If one is near it will get the UID and authenticate
while continue_reading:
time.sleep(0.1)
# Scan for cards
(status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)
# If a card is found
if status == MIFAREReader.MI_OK:
continue
# Get the UID of the card
(status,uid) = MIFAREReader.MFRC522_Anticoll()
# If we have the UID, continue
if status == MIFAREReader.MI_OK:
if uid == [11,19,92,128,247]:
relay()
elif uid == [26,4,150,12,22]:
relay()
elif uid == [2,4,29,75,10]:
relay()
elif uid == [1,4,0,3,23]:
relay()
elif uid == [16,4,11,7,6]:
relay()
elif uid == [11,4,15,9,30]:
relay()
elif uid == [11,4,18,68,6]:
relay()
elif uid == [16,4,5,13,6]:
relay()
elif uid == [11,4,20,234,186]:
relay()
elif uid == [11,4,3,73,13]:
relay()
else:
print "wrong tag"
I think if I have one database (with sql or what else) on one server (maybe one of the raspberry), then can I manage it very better.
Have you any ideas for this problem?