RFID door opener with LCD display » elektronX

In response to a request, I would like to go into the subject of RFID again. In this example, a door is to be opened by scanning a specific RFID card. In addition, there is an LCD display that shows information.

If you want to follow this example step by step, the Raspberry, the LCD display and the RFID reader must be connected as shown in the circuit diagram.
I also recommend using the hardware I used in this example.
LCD display: Amazon Link – Any 16×2 LCD with an HD44780 controller can be used as a display. e
RFID readers: Seeed Studio or Amazon
RFID cards: Amazon

The hardware:

connection plan

The following should be mentioned here:

Pin 15 of the LCD module is the anode of the backlight LED. To be on the safe side, this is supplied via a resistor so that no uncontrolled current is drawn from the Pi. It is also very important that pin 5 (R/W) is connected to GND. This pin allows the display to be set to read or write mode. However, the display would “talk” with a 5V level. This must be prevented in any case, since the GPIO pins of the Pi are not 5V tolerant and it could possibly destroy the Pi! This is prevented by permanently connecting pin 5 to GND!

The complete pin assignment of the LCD display:

  1. GND
  2. VCC 5V
  3. contrast
  4. Register Select
  5. Read/Write
  6. Enable
  7. bit 0
  8. bit 1
  9. bit 2
  10. bit 3
  11. bit 4
  12. bit 5
  13. bit 6
  14. bit 7
  15. backlight anode (+)
  16. Backlight Cathode (-)

The RFID reader is connected with 3 pins.
GND, 5V and RxD.
I have already explained how the module is connected in this article. Again, pay attention to the voltage divider!

The door that is to be opened via the RFID tag is represented in the circuit diagram by an LED, which is connected to pin 13 (GPIO 21).

The software

The whole thing is controlled via Python. We need 3 subprograms / functions.

Function 1: Read in the RFID tag
Function 2: Drive LCD
Function 3: Open main program and door

To read the RFID tags, I defined the code from the article linked above as a function.
The same happens with the logic for controlling the display. Both functions are defined in the functions.py file (download below). This simplifies the main program.

Main program rfid_door.ry

from sys import exit
import RPi.GPIO as GPIO
from time import sleep, clock
from funktionen import *

userdict = {53877037723976: "Christoph", 53877041643557:"Hans",} #Hier die erlaubten Nutzer eintragen

opentime = 5 # Zeit in der die Tuer geoeffnet bleibt

while True:

    lcd ("Karte","einscannen") # Syntax: lcd("Zeile 1 max 16 Zeichen", "Zeile 2 max 16 Zeichen")
    user  = rfid() 

    if user in userdict:  
        lcd ("Guten Tag",userdict[user])
        lcd ("Tuer offen", "fuer "+str(opentime)+" Sek")
        GPIO.output(21, True)
        sleep (opentime)
        GPIO.output(21, False)
        lcd ("Tuer wieder", "verriegelt")

        lcd("Karte nicht","erlaubt!")


The main program defines the cards that are allowed to open the door.
With the command


the door is opened or closed by the relay connected to GPIO 21.
The “authorized access” and the time of the open door can be changed.

In order to start the program without errors, it is necessary to copy the two files into a folder. To start the main program, switch to the appropriate folder and start the program with:

$ python rfid_door.py

funktions.py and rfid_door.py in the .rar archive

In action, the little project looks like this:
You just think of the door 😉

Previous post Clickfunnels Experiences & Test 2022 ▷ Prices, Costs, Templates
Geld-online-Blog Next post 8 plugins for improving WordPress’ internal search function