Introduction: Smart-door-lock-using-raspberry_pi_and_GSM_modemSim800_RFID

In this tutorial, I go over how to integrate the EM-18 RFID Reader module with a Raspberry Pi board. I also show how to integrate an actuator, in this case an Relay, to respond to a correct reading from the RFID module. This actuator can be a solenoid lock, a speaker, or even a web interface that logs data.And also interface with a GSM module to give message notification. I discuss how this design can be implemented as an RFID smart lock.

Connecting the RFID to the Raspberry Pi

A simple RFID Communication System comprises of three parts: an RFID Card or Tag (which contains the user or product information embedded on a chip), an RFID Reader (a device which triggers the RFID card and extracts the information from the Card) and a Host System (like a Computer or a Microcontroller which then processes the data).

In this project, I will be using the popular EM-18 RFID Reader Module and a few RFID Cards. There is another popular RFID Reader called RFID RC522.

The main differences between EM-18 and RC522 RFID Modules are: EM-18 is based on 125 KHz Radio Frequency Communication while the RC522 is based on 13.56 MHz Frequency.Coming to the interface options, EM-18 uses Serial Communication whereas RC522 uses SPI Communication (although the chip supports I2C and UART as well).So, selection of the RFID Reader Module is very important as it defines how you communicate with the module using Raspberry Pi or Arduino.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Components Required

1. Raspberry Pi 3 Model B+ :- The Raspberry Pi 3 Model B+ is the latest product in the Raspberry Pi 3 range,boasting a 64-bit quad core processor running at 1.4GHz, dual-band 2.4GHz and 5GHz wireless LAN, Bluetooth 4.2/BLE, faster Ethernet, and PoE capability via a separate PoE HAT.

2.EM-18 RFID Reader Module:- EM18 RFID Reader is a module which reads the ID information stored in RFID TAGS. This ID information is unique for every TAG which cannot be copied.This module directly connects to any microcontroller UART or through a RS232 converter to PC.It gives UART/Wiegand26 output. This RFID Reader Module works with any 125 KHz RFID tags

3. GSM Module :-SIM800 is a quad-band GSM/GPRS module that works on frequencies GSM 850MHz, EGSM 900MHz, DCS 1800MHz and PCS 1900MHz. SIM800 features GPRS multi-slot class 12/ class 10 (optional) and supports the GPRS coding schemes CS-1, CS-2, CS-3 and CS-4.

4. CP2102 :- CP2102 chip from SiLabs is a single chip USB to UART bridge IC. It requires minimal external components. CP2102 can be used to migrate legacy serial port based devices to USB. ... This module help all those who are comfortable with RS232/Serial Communication protocol, to build USB devices very easily.

5. 5V Relay :- 1-Channel 5V Relay Module is a relay interface board, it can be controlled directly by a wide range of microcontrollers such as Arduino, AVR, PIC, ARM and so on. To put it simply, it is an automatic switch to control a high-current circuit with a low-current signal.5V relay signal input voltage range, 0-5V.

6. Female to Female Jumper Wires.

Step 2: Installing the Libraries

To Install PySerial Package

I don't know whether PySerial package is pre-installed or not with the Rasbian OS, but in my case it was not installed as i am using the Lite version of Raspbian OS, so our first step is to install the PySerial package,

If your Raspberry Pi is connected with internet then use the following command in LXTerminal to install the PySerial library for Python.

sudo apt-get install python-serial

And in case you don't have working internet connection on Raspberry Pi, then you can download the PySerial package by clicking here, on Windows/Linux/Mac platforms and then copy these files into your Raspberry Pi, and then by using LXTerminal go to the directory where you have copied the files and after that use the following command to install the PySerial package.

sudo python install

So after this stage we have PySerial package installed and now we can proceed with writing the simple program for serial read and write operations, but before that we have to enable the Serial communication in Raspberry Pi, which is disabled by default.

Step 3: Connecting Components Together

Circuit Description:

Circuit diagram contains Raspberry Pi 3, RFID Reader, RFID Tags, GSM, Relay and CP2102. Here Raspberry Pi controls the complete process like Reading Data coming from the Reader, comparing data with predefined data, driving Relay and sending informations to GSM. RFID Reader is used to Read RFID Tags. Relay is used for indications. GSM is used for sending messages.

RELAY PIN_VCC ------------------- 2 of Raspberry Pi

RELAY PIN_GND ------------------- 6 of Raspberry Pi

RELAY PIN_INP ------------------- 11 of Raspberry Pi

The RFID is connected to CP2102-ONE and the GSM module is connected to CP2102-TWO . These two CP2102 is connected to the USB port of raspberry pi.

Step 4: Working Explanation

Here Raspberry Pi 3 is controlling the whole the process of this project (User can use any Raspberry Pi Board). RFID Reader reads the RFID card ID, this data is received by Raspberry Pi through UART, then Raspberry Pi validates the card and send the information to GSM.

When a person put their RFID tag over the RFID reader to scan, RFID reads tag’s data and sends it to Raspberry Pi. Then Raspberry Pi reads the Unique Identification Number of that RFID tag and then compares this data with predefined data or information. If data is matched with predefined data, then the relay on and sending the message through GSM, and if data is not matched then Raspberry pi sends a message ‘Invalid Card’ through GSM and relay is off.

Step 5: The Code

Download the code attached here and upload it on your board, and wire everything as shown in previous diagram.

Download code :

Hope this made it easier for you. Be sure to subscribe if you liked this article and found it useful, and if you have any questions or need help with anything, just leave a comment below…Thanks

Be the First to Share


    • Magnets Challenge

      Magnets Challenge
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest