Create A Simple GUI For USB RFid Reader EM4100 Using Raspberry Pi

Don't know how to interface USB RFid Reader with Raspberry Pi? Read this tutorial.

Introduction

Today I would like to try to interface 125KHz USB RFID Smart Card Reader EM4100. Since it is using USB cable, I choose Raspberry Pi as a controller. Even it is using USB, it is not require a driver to interact with computer. You can open any text editor, once the reader detects tag, it will read and display the tag ID to the text editor. But, how if you want to put it in the program? Let’s try!

Video

This video will show you how to create a simple GUI for USB RFid reader model EM4100 using Raspberry Pi.

Hardware Preparation

This is the list of items used in the video.

Sample Program

This is the sample code for creating a simple GUI, reading RFid tag and compare to the database. You need to create a file named Database.csv before you can run this code. For more details, please refer to the video.

from gpiozero import LED, Buzzer
from guizero import App, Box, Text, TextBox, warn
import csv
led8 = LED(19)
def clearDisplay():
print("Clear display")
rfidStatus.value = "—"
rfidText.value = ""
led8.off()
rfidStatus.repeat(1000, checkRFidTag)
def checkRFidTag():
tagId = rfidText.value
if tagId != "":
RFidRegistered = False
print(tagId)
with open("Database.csv") as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
if row["RFid"] == tagId:
RFidRegistered = True
print("Welcome " + row["User"])
rfidStatus.value = "Welcome " + row["User"]
led8.on()
rfidStatus.after(5000, clearDisplay)
if RFidRegistered == False:
print("RFid tag is not registered")
rfidStatus.value = "RFid tag is not registered"
rfidStatus.after(3000, clearDisplay)
rfidStatus.cancel(checkRFidTag)
app = App(title="RFID EM4100 Simple GUI", width=350, height=150, layout="auto")
instructionText = Text(app, text="Click on the text button below\nand scan your RFid tag.")
rfidText = TextBox(app)
rfidStatus = Text(app, text="—")
rfidStatus.repeat(1000, checkRFidTag)
designBy = Text(app, text="Design by Idris – Cytron Technologies", align="bottom")
app.display()

view raw
RFidEM4100GUI.py
hosted with ❤ by GitHub

Thank You

References:

  1. Raspberry Pi: Getting started with GUIs
  2. GUI library package – guizero
  3. Library to control GPIO on Raspberry Pi – gpiozero

Thanks for reading this tutorial. If you have any technical inquiry, please post at Cytron Technical Forum.

3 thoughts on “Create A Simple GUI For USB RFid Reader EM4100 Using Raspberry Pi”

  1. Dah cucuk RFID Reader dkt raspberry pi 4 tapi data tk boleh baca. Even scan data untuk display dkt text file pun tk boleh. Seakan dia tk functioning kt rpi4. Perlu install driver baru ataupun ada cara lain? Mohon beri pencerahan.

  2. Could we do writing process as we do read operation, I mean before the reading process from Database.csv, I want to enter the names right before manually with the help of another function and write it down to the Database.csv file.

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

Automatic Dustbin Using REKA:BIT
Ultrasonic HC-SR04P Using Raspberry Pi Pico
Object Sense With Servo Using Maker Pi RP2040
Build Otto DIY Robot Using Maker Pi RP2040
Raspberry Pi RP2040 vs STM32F1 vs SAMD21G18 vs ESP32-S2
Tutorials of Cytron Technologies Scroll to Top