akash614
Posts: 41
Joined: Tue Dec 05, 2017 2:48 am

RFID based Attendance system using raspberry pi 3

Wed Oct 31, 2018 3:34 pm

i would like to work on a project with rfid lcd and raspberry pi 3 in which whenever a card which exists in the database it activates relay when the card scanned is not in database it says error and card can be scanned only once in a day at same place so if scanned again i would be receiving a message that already used how do i implement this idea into raspberry pi 3 hope you guys help me out

Andyroo
Posts: 3378
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: RFID based Attendance system using raspberry pi 3

Wed Oct 31, 2018 3:50 pm

Sounds quite possible. Taking it step by step:

1) Do you have a reader / cards?
2) Do you have a small display or are you planning to use the Pi screen?
3) How many cards? If it’s only a demo then a simple file would do to store the numbers else you need to plan for a database?
4) Do you have any programming skills?

The program / programs would need to bet able to:

1) Register a new card as being valid and possibly enter the persons name
2) Delete old cards
3) Read the card and check it’s valid. If not report ‘invalid card’
4) If a valid card, check if it’s been used today. If so report ‘already used’
5) If not, log the date used for the card and report ‘Welcome’

The data you need to store would be:
a) The card number (unique)
b) The date it was last used
c) Optionally the name of the person
Need Pi spray - these things are breeding in my house...

User avatar
B.Goode
Posts: 7875
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: RFID based Attendance system using raspberry pi 3

Wed Oct 31, 2018 3:58 pm

Maybe one or more of the previous discussions on this topic would have information relevant to your project: https://duckduckgo.com/?q=Rfid+attendan ... a4a&ia=web

akash614
Posts: 41
Joined: Tue Dec 05, 2017 2:48 am

Re: RFID based Attendance system using raspberry pi 3

Thu Nov 01, 2018 1:33 am

Andyroo wrote:
Wed Oct 31, 2018 3:50 pm
Sounds quite possible. Taking it step by step:

1) Do you have a reader / cards?
2) Do you have a small display or are you planning to use the Pi screen?
3) How many cards? If it’s only a demo then a simple file would do to store the numbers else you need to plan for a database?
4) Do you have any programming skills?

The program / programs would need to bet able to:

1) Register a new card as being valid and possibly enter the persons name
2) Delete old cards
3) Read the card and check it’s valid. If not report ‘invalid card’
4) If a valid card, check if it’s been used today. If so report ‘already used’
5) If not, log the date used for the card and report ‘Welcome’

The data you need to store would be:
a) The card number (unique)
b) The date it was last used
c) Optionally the name of the person
yes i have MFRC522 RFID Card Reader
i have 16*2 character display which shows only about events happening
its not like demo i need a database to store all the cards like minimum 500
i am just a beginner i got this idea to implement for minimum coding experience

no need to enter persons name just a VIP user and normal user and not scan any card just check with database if it presents or not
no need to delete old cards i will give each a unique number so i can delete it later from database
yes that would be easy plus activate a relay for solenoid
yes it needs to check if it is already scanned on the day it is used
it needs to log data to database and can be accessed if connected to ethernet

yes the data need to be stored is correct but just time and number for normal persons
and name for like VIP Persons

Andyroo
Posts: 3378
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: RFID based Attendance system using raspberry pi 3

Thu Nov 01, 2018 2:45 am

Looks like you have most of the bits then :)

What do you need from this forum?
Need Pi spray - these things are breeding in my house...

akash614
Posts: 41
Joined: Tue Dec 05, 2017 2:48 am

Re: RFID based Attendance system using raspberry pi 3

Thu Nov 01, 2018 10:42 am

Andyroo wrote:
Thu Nov 01, 2018 2:45 am
Looks like you have most of the bits then :)

What do you need from this forum?
i would like to program each function and create a database as a beginner i would sure use some help in this project

and how do i make one script with all those functions

User avatar
B.Goode
Posts: 7875
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: RFID based Attendance system using raspberry pi 3

Thu Nov 01, 2018 11:18 am

akash614 wrote:
Thu Nov 01, 2018 10:42 am
Andyroo wrote:
Thu Nov 01, 2018 2:45 am
Looks like you have most of the bits then :)

What do you need from this forum?
i would like to program each function and create a database as a beginner i would sure use some help in this project

and how do i make one script with all those functions


Having a challenging project can be a good way of learning. As long as you don't overwhelm yourself by the quantity of things you can't currently implement.

(Have you chosen to do this for your own interest and learning, or has it been imposed on you for some sort of assessed coursework or exam?)

It seems to me there are a number of elements -
Reading the RFID;
Outputting to the display;
Controlling a relay;
Handling the database.

Each of those is a mini-project in its own right. Choose one and get started. It is down to your personality whether you tackle the one you perceive to be 'easy' or 'hard' first.

Once you have written code for one perhaps it will become far more obvious how to write and combine the code for the others.

akash614
Posts: 41
Joined: Tue Dec 05, 2017 2:48 am

Re: RFID based Attendance system using raspberry pi 3

Thu Nov 01, 2018 11:30 am




Having a challenging project can be a good way of learning. As long as you don't overwhelm yourself by the quantity of things you can't currently implement.

(Have you chosen to do this for your own interest and learning, or has it been imposed on you for some sort of assessed coursework or exam?)

It seems to me there are a number of elements -
Reading the RFID;
Outputting to the display;
Controlling a relay;
Handling the database.

Each of those is a mini-project in its own right. Choose one and get started. It is down to your personality whether you tackle the one you perceive to be 'easy' or 'hard' first.

Once you have written code for one perhaps it will become far more obvious how to write and combine the code for the others.
but as a beginner and a project i would rather use some help as of no time i don't know to code python and how do perform all this functions i can just create a database and how do i perform all the other task

are there any already made projects like this i can use for reference of code and learning few commands

User avatar
B.Goode
Posts: 7875
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: RFID based Attendance system using raspberry pi 3

Thu Nov 01, 2018 2:00 pm

I have nothing further to contribute to this discussion.

akash614
Posts: 41
Joined: Tue Dec 05, 2017 2:48 am

Re: RFID based Attendance system using raspberry pi 3

Thu Nov 01, 2018 2:21 pm

B.Goode wrote:
Thu Nov 01, 2018 2:00 pm
I have nothing further to contribute to this discussion.
why i guess i gotta figure it out myself thanks for some tips

akash614
Posts: 41
Joined: Tue Dec 05, 2017 2:48 am

Re: RFID based Attendance system using raspberry pi 3

Thu Nov 01, 2018 2:26 pm

B.Goode wrote:
Thu Nov 01, 2018 2:00 pm
I have nothing further to contribute to this discussion.
i made an arduino version of this video belowhttps://www.youtube.com/watch?v=PFuqp0TDiKk

and it works same with database just i need to upgrade with rpi which has its own processing and code running everything so this is my idea

danjperron
Posts: 3334
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: RFID based Attendance system using raspberry pi 3

Thu Nov 01, 2018 3:59 pm

This is what I did 4 years ago. Wow time goes by ...
Multiple RFID reader using modbus connected to an Raspberry Pi.
When a card is read by a station it is check on a sql database to allow permission or not .

A small video of my Modbus systemhttps://dl.dropboxusercontent.com/s/ihw ... sClip1.mp4

viewtopic.php?f=37&t=92566&hilit=rfid

you should check the full post.

The code for the RFID on modbus is on github https://github.com/danjperron/modbusMFRC522

But you could connect the RFID directly to the PI .


Code in Python https://github.com/danjperron/MFRC522-python

Code in C that was modified to run without sudo
https://github.com/danjperron/rc522_reader

akash614
Posts: 41
Joined: Tue Dec 05, 2017 2:48 am

Re: RFID based Attendance system using raspberry pi 3

Fri Nov 02, 2018 1:25 am

danjperron wrote:
Thu Nov 01, 2018 3:59 pm
This is what I did 4 years ago. Wow time goes by ...
Multiple RFID reader using modbus connected to an Raspberry Pi.
When a card is read by a station it is check on a sql database to allow permission or not .

A small video of my Modbus systemhttps://dl.dropboxusercontent.com/s/ihw ... sClip1.mp4

viewtopic.php?f=37&t=92566&hilit=rfid

you should check the full post.

The code for the RFID on modbus is on github https://github.com/danjperron/modbusMFRC522

But you could connect the RFID directly to the PI .


Code in Python https://github.com/danjperron/MFRC522-python

Code in C that was modified to run without sudo
https://github.com/danjperron/rc522_reader
i have gone through everything you have given it was excellent but how do i make a command to access the database and check if it is present

danjperron
Posts: 3334
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: RFID based Attendance system using raspberry pi 3

Fri Nov 02, 2018 1:48 am

Please check the python code 'DoorSystem.py' from that post. The function ValidateCard() does everything.
The code is after the picture with the declaration of the SQL database structure.

viewtopic.php?f=37&t=92566&hilit=rfid#p658053

I'm using pymsql module in python

The function ValidateCard() does,

1- Request the card Info using SQL from structure cards
2- Once it is valid it will request the user info link to that card from structure users.
3- Then if the card and the user is valid for that station it will accept it.

N.B. I don't have too many cards so I used the web application phpmyadmin to fill the database structures manually.

akash614
Posts: 41
Joined: Tue Dec 05, 2017 2:48 am

Re: RFID based Attendance system using raspberry pi 3

Fri Nov 02, 2018 10:47 am

danjperron wrote:
Fri Nov 02, 2018 1:48 am
Please check the python code 'DoorSystem.py' from that post. The function ValidateCard() does everything.
The code is after the picture with the declaration of the SQL database structure.

viewtopic.php?f=37&t=92566&hilit=rfid#p658053

I'm using pymsql module in python

The function ValidateCard() does,

1- Request the card Info using SQL from structure cards
2- Once it is valid it will request the user info link to that card from structure users.
3- Then if the card and the user is valid for that station it will accept it.

N.B. I don't have too many cards so I used the web application phpmyadmin to fill the database structures manually.
how can i like connect directly to raspberry pi all MFRC522 and Relay buzzer every thing to single board instead of arduino usage

Andyroo
Posts: 3378
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: RFID based Attendance system using raspberry pi 3

Fri Nov 02, 2018 1:30 pm

akash614 wrote:
Fri Nov 02, 2018 10:47 am
how can i like connect directly to raspberry pi all MFRC522 and Relay buzzer every thing to single board instead of arduino usage
A quick Google search for raspberry pi mfrc522 will take you to https://pimylifeup.com/raspberry-pi-rfid-rc522/ - that will get you both the hardware connections and a great walkthrough of the code needed to support and handle the board in Python. Depending on the board you have, the wiring on its end may need to be changed but as long as you map out the pins first and match the Pi end its straightforward connections.
Need Pi spray - these things are breeding in my house...

akash614
Posts: 41
Joined: Tue Dec 05, 2017 2:48 am

Re: RFID based Attendance system using raspberry pi 3

Fri Nov 02, 2018 1:48 pm

Andyroo wrote:
Fri Nov 02, 2018 1:30 pm
akash614 wrote:
Fri Nov 02, 2018 10:47 am
how can i like connect directly to raspberry pi all MFRC522 and Relay buzzer every thing to single board instead of arduino usage
A quick Google search for raspberry pi mfrc522 will take you to https://pimylifeup.com/raspberry-pi-rfid-rc522/ - that will get you both the hardware connections and a great walkthrough of the code needed to support and handle the board in Python. Depending on the board you have, the wiring on its end may need to be changed but as long as you map out the pins first and match the Pi end its straightforward connections.
these connections are already done but how do i like use the door python with the data from rfid module connected to raspberry pi

danjperron
Posts: 3334
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: RFID based Attendance system using raspberry pi 3

Fri Nov 02, 2018 7:22 pm

ok I updated my github and add the walkthrough on how to create the door system using the RFID reader connected to the Raspberry Pi.
It is not exactly like the one I made with the modbus but I'm using only one table for simplicity.

https://github.com/danjperron/MFRC522-python

I made this modification,

- Remove the GPIO from MFRC522 class
- Remove the reset pin from the GPIO. Just let it open.
- Change The MFRC522 class to use spidev instead of spi .
- Use python3
- Change the python script "Read.py" to return a string instead of a list
- Add a DoorSystem "how to" with a step by step.
- Add python DoorSystem.py This is an example on how to use mariadb sql to read the validity of a card via a database.

I'm using a RGB led which is common anode and my relay is active on low. Depending of your system please change the GPIO and the OFF/ON value to fit your need inside DoorSystem.py.

akash614
Posts: 41
Joined: Tue Dec 05, 2017 2:48 am

Re: RFID based Attendance system using raspberry pi 3

Sat Nov 03, 2018 12:42 am

danjperron wrote:
Fri Nov 02, 2018 7:22 pm
ok I updated my github and add the walkthrough on how to create the door system using the RFID reader connected to the Raspberry Pi.
It is not exactly like the one I made with the modbus but I'm using only one table for simplicity.

https://github.com/danjperron/MFRC522-python

I made this modification,

- Remove the GPIO from MFRC522 class
- Remove the reset pin from the GPIO. Just let it open.
- Change The MFRC522 class to use spidev instead of spi .
- Use python3
- Change the python script "Read.py" to return a string instead of a list
- Add a DoorSystem "how to" with a step by step.
- Add python DoorSystem.py This is an example on how to use mariadb sql to read the validity of a card via a database.

I'm using a RGB led which is common anode and my relay is active on low. Depending of your system please change the GPIO and the OFF/ON value to fit your need inside DoorSystem.py.
then how do i add cards using python script when i execute it

plus i would like to add another column if the card validity expires the card to be deleted from database and it can no longer be used with door python

danjperron
Posts: 3334
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: RFID based Attendance system using raspberry pi 3

Sat Nov 03, 2018 2:26 am

then how do i add cards using python script when i execute it
This is a script to add a rfid card

addCard.py

Code: Select all

import pymysql


serial_no = input("RIFD card serial number ?")
user_id = input("user name?")

#put serial_no uppercase just in case
serial_no = serial_no.upper()

# open an sql session

sql_con = pymysql.connect(host='localhost', user='rfidreader',
                          passwd='password', db='rfidcardsdb')
sqlcursor = sql_con.cursor()


#first thing is to check if the card exist

sql_request ='SELECT card_id,serial_no,user_id,valid' + \
          ' FROM cards  WHERE serial_no = "' + serial_no + '"'

count = sqlcursor.execute(sql_request)

if count > 0 :
     print("Error! RFID card {} already in database".format(serial_no))
     T= sqlcursor.fetchone()
     print(T)
else:
   sql_insert =  'INSERT INTO cards (serial_no,user_id,valid) values("{}","{}","1")'.format(serial_no,user_id)
   count = sqlcursor.execute(sql_insert)
   if count>0:
     sql_con.commit()
     #let's check it  just in case
     count = sqlcursor.execute(sql_request)
     if count>0:
      print("RFID card {} inserted to database".format(serial_no))
      T = sqlcursor.fetchone() 
      print(T)
   if count == 0:
     print("Error! RFID card {} not inserted to database! ".format(serial_no))
plus i would like to add another column if the card validity expires the card to be deleted from database and it can no longer be used with door python
The valid field is already in the cards table. you just have to set it to 0 and the cards wont activate the relay.

Did you check my 'How To' because if you look at the table there were already a rfid cards with the valid flag at zero.

If you want to add a date field for expiration it is simple using mysql,

Code: Select all

MariaDB [(none)]> use rfidcardsdb
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [rfidcardsdb]> ALTER TABLE cards ADD column ( `expire` datetime NOT NULL );
Query OK, 0 rows affected (8.07 sec)
Records: 0  Duplicates: 0  Warnings: 0

MariaDB [rfidcardsdb]> describe cards;
+-----------+-------------+------+-----+---------+----------------+
| Field     | Type        | Null | Key | Default | Extra          |
+-----------+-------------+------+-----+---------+----------------+
| card_id   | int(11)     | NO   | PRI | NULL    | auto_increment |
| serial_no | varchar(20) | NO   |     | NULL    |                |
| user_id   | varchar(40) | NO   |     | NULL    |                |
| valid     | tinyint(1)  | NO   |     | 0       |                |
| expire    | datetime    | NO   |     | NULL    |                |
+-----------+-------------+------+-----+---------+----------------+


But you will have to change the python script if you want expiration, start date and create also a log database.

It is also possible to create html web page which is way simpler for user to add, remove or edit contents of a database.
You should read about mysql database! it's a must . (look at MariaDB this is the default SQL for the raspberry PI).
Also you could implement phpmyadmin with a web browser on the raspberry pi.

akash614
Posts: 41
Joined: Tue Dec 05, 2017 2:48 am

Re: RFID based Attendance system using raspberry pi 3

Sat Nov 03, 2018 2:35 am

danjperron wrote:
Sat Nov 03, 2018 2:26 am
then how do i add cards using python script when i execute it
This is a script to add a rfid card

addCard.py

Code: Select all

import pymysql


serial_no = input("RIFD card serial number ?")
user_id = input("user name?")

#put serial_no uppercase just in case
serial_no = serial_no.upper()

# open an sql session

sql_con = pymysql.connect(host='localhost', user='rfidreader',
                          passwd='password', db='rfidcardsdb')
sqlcursor = sql_con.cursor()


#first thing is to check if the card exist

sql_request ='SELECT card_id,serial_no,user_id,valid' + \
          ' FROM cards  WHERE serial_no = "' + serial_no + '"'

count = sqlcursor.execute(sql_request)

if count > 0 :
     print("Error! RFID card {} already in database".format(serial_no))
     T= sqlcursor.fetchone()
     print(T)
else:
   sql_insert =  'INSERT INTO cards (serial_no,user_id,valid) values("{}","{}","1")'.format(serial_no,user_id)
   count = sqlcursor.execute(sql_insert)
   if count>0:
     sql_con.commit()
     #let's check it  just in case
     count = sqlcursor.execute(sql_request)
     if count>0:
      print("RFID card {} inserted to database".format(serial_no))
      T = sqlcursor.fetchone() 
      print(T)
   if count == 0:
     print("Error! RFID card {} not inserted to database! ".format(serial_no))
plus i would like to add another column if the card validity expires the card to be deleted from database and it can no longer be used with door python
The valid field is already in the cards table. you just have to set it to 0 and the cards wont activate the relay.

Did you check my 'How To' because if you look at the table there were already a rfid cards with the valid flag at zero.

If you want to add a date field for expiration it is simple using mysql,

Code: Select all

MariaDB [(none)]> use rfidcardsdb
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [rfidcardsdb]> ALTER TABLE cards ADD column ( `expire` datetime NOT NULL );
Query OK, 0 rows affected (8.07 sec)
Records: 0  Duplicates: 0  Warnings: 0

MariaDB [rfidcardsdb]> describe cards;
+-----------+-------------+------+-----+---------+----------------+
| Field     | Type        | Null | Key | Default | Extra          |
+-----------+-------------+------+-----+---------+----------------+
| card_id   | int(11)     | NO   | PRI | NULL    | auto_increment |
| serial_no | varchar(20) | NO   |     | NULL    |                |
| user_id   | varchar(40) | NO   |     | NULL    |                |
| valid     | tinyint(1)  | NO   |     | 0       |                |
| expire    | datetime    | NO   |     | NULL    |                |
+-----------+-------------+------+-----+---------+----------------+


But you will have to change the python script if you want expiration, start date and create also a log database.

It is also possible to create html web page which is way simpler for user to add, remove or edit contents of a database.
You should read about mysql database! it's a must . (look at MariaDB this is the default SQL for the raspberry PI).
Also you could implement phpmyadmin with a web browser on the raspberry pi.

thanks for all those script i would like to have your email id if i have anymore query thanks again

danjperron
Posts: 3334
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: RFID based Attendance system using raspberry pi 3

Sat Nov 03, 2018 2:38 am

thanks for all those script i would like to have your email id if i have anymore query thanks again
I post this for everybody! if you have question maybe somebody else will have the same. Just post it on the forum!

Please don't reply all my post in quote !
This make things harder to read when the next post is a copy of the previous one in quote.

akash614
Posts: 41
Joined: Tue Dec 05, 2017 2:48 am

Re: RFID based Attendance system using raspberry pi 3

Sat Nov 03, 2018 10:49 am

my simple goal is as follows

1) connect rfid scanner to raspberry pi with display of 16*2 characters lcd

2) then when card is scanned it have to check if present and validate
if not reject

3) and automatically show card which are expired with date and status of card to invalid so it does not valid

4)adding cards before itself makes it easier to delete later

5) i want to store all this data on database and show this through php or any other page

6) when the card which was expired used with new expiry date it has to validate

these are the things i want in one script how do i accomplish these all in one single script

danjperron
Posts: 3334
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: RFID based Attendance system using raspberry pi 3

Sat Nov 03, 2018 4:21 pm

these are the things i want in one script how do i accomplish these all in one single script
I won't recommend to do everything in one script!

One script to control the access!

And other scripts to do the rest. You have a multi-task, multi-user system. Break your tasks!

I will go even further and had a user name and password with only grant access to read the database and write log for the script to read the RFID and grant access to the door.

And the rest of the stuff should be on a web application to access the administration of the RFID cards. (create account, Validate card, set expire date, etc...). This should be another user name and password with grant all access to the data base. It is possible to use only one Raspberry PI but you should use one to check the door and another one for administration. If you use a display in The PI which check the door then you need to enclose it in a secure way. A touch screen is easy to brake.

akash614
Posts: 41
Joined: Tue Dec 05, 2017 2:48 am

Re: RFID based Attendance system using raspberry pi 3

Sun Nov 04, 2018 1:34 am

i have seen few on youtube and this one was one i wanted to implement with the idea

https://youtu.be/Xgf9mkEm77s?t=4m5s

so hope you guys help me out on how to carry those functions please

Return to “Other projects”