Project tutorial
Python Software for Arduino RFID

Python Software for Arduino RFID © MIT

HK RFID Monitor is basically a Python based software for RFID. It reads the data coming to COM port and displays it on your laptop screen.

  • 10,162 views
  • 3 comments
  • 17 respects

Components and supplies

Apps and online services

About this project

Introduction

HK RFID Monitor is basically a Python-based software for RFID. It reads the data coming to the com port and displays it on your laptop screen. The data used in this project are IDs, names, and roll numbers of students, coming from a micro-controller (AVR or simply Arduino). The software reads the values with the serial' module of Python and displays it using 'Tkinker.'

RFID Monitor

How is the data coming to the COM port?

In this project, Arduino is used to sending data to the COM port, so it is easier to understand how the data is coming to the port for those who have worked with Arduino or AVR microcontroller.

Let us assume that our microcontroller board (Arduino UNO) is connected to COM port 4 of our PC and take the following dummy Arduino code:

void setup() {  
Serial.begin(9600); }void loop() {
Serial.print("id=1000; name=Hamza Khalid; rollnumber=115;");
Serial.print("\n "); delay(3000);
Serial.print("id=1001; name=Ahmed Arif; rollnumber=120;");
Serial.print("\n ");
delay(3000);
Serial.print("id=1002; name=Ammar Ahmed; rollnumber=142;");
Serial.print("\n ");
delay(3000);
}

So, the output on Arduino's serial monitor will be:

id=1000; name=Hamza Khalid; rollnumber=115;id=1001; name=Ahmed Arif; rollnumber=120;id=1002; name=Ammar Ahmed; rollnumber=142; (... continue)

How is software processing data?

The following line (Line 121) in our Python file allows you to type the port name on which the data is coming. As our Arduino is connected to port No. 4 so we write 'COM4' in the input box:

Labelh=Label(root,text='Enter port Name. E.g: COM4',font=("Arial","14")).place(x=120,y=40)

The python program now starts reading 'COM4' and saves every line in a string with the help of the following lines (Line 55, 56):

thing = self.ser.readline().decode('ascii')        
string = str(thing)

The program now does string parsing to separate the values of id, name, and roll number of a student with the help of the following lines (Line 72-83):

for i in range(2, len(string)):       
if string[i] == ';':
break
v = string[3:i]
for j in range(10, len(string)):
if string[j] == ';':
break
c = string[i + 7:j]
or k in range(20, len(string)):
if string[k] == len(string):
break
p = string[j + 13:k-1]

Storing in the database

The values of id, name, and roll number are stored in variable v, c, and p. The values are then stored in thethesqlite3 database and are displayed on the software screen with the help of the following lines:

call.execute("INSERT INTO rfid (datestamp, id, name, rollnumber) VALUES (?,?,?,?)", (date, v, c, p))                
conn.commit()
call.execute('SELECT * FROM rfid ORDER BY datestamp DESC LIMIT 5')for row in call.fetchall():
print(row)
self.tree.insert("", 0, text="FETCHED --- >", values=(date, v, c, p))

How to make changes for your own data?

It would be best if you made the following changes for your own data:

  • You need to change the Arduino code, which is sending data to the port. *Note that your source of sending data to the COM port can be anything, so make changes accordingly.
  • Make changes in lines (61-72) of Python program used for string parsing to separate values from the string (in our case, alphanumeric values if their, name, and roll number).
  • Change the names of columns in the database.
  • Change the tree used in the python code.

Code

Github
The code is open source. (MIT License)

Comments

Similar projects you might like

Attendance System Using Arduino and RFID with Python

Project tutorial by Embedotronics Technologies

  • 18,370 views
  • 2 comments
  • 26 respects

Arduino Ethernet Rfid card reader

Project tutorial by David Smerkous

  • 53,252 views
  • 18 comments
  • 76 respects

RFID Tag Windows (Vista, 7, 8, and 10) Login

Project tutorial by RobotGeek Projects Team

  • 7,935 views
  • 0 comments
  • 17 respects

u-blox LEA-6H 02 GPS Module with Arduino and Python

Project tutorial by Harshgosar

  • 4,407 views
  • 9 comments
  • 8 respects

Chrome Dino Game "Revamped" with arduino and python

Project tutorial by yashastronomy

  • 2,673 views
  • 1 comment
  • 7 respects
Add projectSign up / Login