*Pi RFID Reader

15 Jan

In efforts to come up with a really simple RFID reader I expanded my project to include:

– A LCD screen
– WiFi operation.
– Programmable (writable) “Master Cards”.

Basic thought process.

– Keep minimal python script.
– Program a “master card(s)” using their ID. One card will be a “Add Card” and “Delete Card”. If the ID matches the one in the Python script then allow it to write (or delete) data to a MySQL table “registeredCards”.
– PHP script will lookup “registeredCards” then query the “cardActivity” table.

passwd
sudo su –
raspi-config

cp /usr/share/zoneinfo/America/Edmonton /etc/localtime

apt-get update

apt-get install git python2.7-dev python-smbus ntp

cd ~
git clone https://github.com/lthiery/SPI-Py.git
cd SPI-Py
python setup.py install

cd ~
git clone https://github.com/sourceperl/rpi.lcd-i2c.git
cd rpi.lcd-i2c
python setup.py install

cd ~
git clone https://github.com/pimylifeup/MFRC522-python.git
cd MFRC522-python

#!/usr/bin/env python

import RPi.GPIO as GPIO
import SimpleMFRC522
import RPi_I2C_LCD
from time import *

import mysql.connector

mydb = mysql.connector.connect(
host=”localhost”,
user=”clock”,
passwd=”password”,
database=”clock”
)

mycursor = mydb.cursor()
sql = “INSERT INTO activity (name, number) VALUES (%s, %s)”

lcd = RPi_I2C_LCD.LCD()
lcd.set_backlight(True)
reader = SimpleMFRC522.SimpleMFRC522()

while True:
lcd.clear()
lcd.message(“Ready for card.”)

try:
id, text = reader.read()
print(id)
print(text)
lcd.clear()
lcd.message(text)
val = (text, id)
mycursor.execute(sql, val)
mydb.commit()
sleep(3)

except KeyboardInterrupt:
GPIO.cleanup()

sudo apt-get install apache2 php mariadb-server php-mysql python-mysql.connector

Leave a Reply

Your email address will not be published.