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.

  • 3,641 views
  • 3 comments
  • 12 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 COM port and displays it on your laptop screen. The data used in this project is IDs, names and roll numbers of students, coming from a micro-controller (AVR or simply arduino). The software reads the values with 'Serial' module of Python and displays it using 'Tkinker'.

RFID Monitor

How is the data coming to COM port?

In this project arduino is used to send data to the COM port so it is easier to understand that how the data is coming to COM 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 the 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 the 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 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 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 variables v, c an p respectively. The values are then stored in sqlite3 database and are displayed on the software screen with the help of 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 changings for your own data?

You need to make the following changes for your own data:

  • You need to change the Arduino code which is sending data to COM 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 which are used for string parsing to separate values from the string (in our case alphanumeric values if id, name and roll number).
  • Change the names of columns in database.
  • Change the tree used in python code.

Code

Github
The code is open source. (MIT License)

Comments

Similar projects you might like

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

Project tutorial by Harshgosar

  • 1,992 views
  • 9 comments
  • 8 respects

Arduino Ethernet Rfid card reader

Project tutorial by David Smerkous

  • 30,692 views
  • 15 comments
  • 50 respects

rfid attendance system using arduino with GSM

Project tutorial by sarful

  • 5,044 views
  • 3 comments
  • 13 respects

Arduino Controlled Lock Box with Solenoid and RFID

Project tutorial by Team RobotGeek Projects Team

  • 4,913 views
  • 2 comments
  • 16 respects

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

Project tutorial by Team RobotGeek Projects Team

  • 5,079 views
  • 0 comments
  • 14 respects

Access RFID with Light Feedback

Project showcase by Werzaire

  • 1,741 views
  • 0 comments
  • 3 respects
Add projectSign up / Login