MATERIALS



ARDUINO BOARD

Any ARDUINO board will work. These can be programmed and wired up to other elements like LEDs, buttons or screens.

RESISTORS, LEDs, BUTTON

In this procedure, 6x6 push buttons and common cathode LEDs



MFRC522

A RFID card reader (comes with a card and a fob). Both contain a S50 chip which works on a frequency of 13.56MHz. These S50 chips each contain a UID

12V POWER SOURCE

This power source would allow us to power the whole system with a plug, originally for a solenoid but it was malfunctioning



MICRO SERVO SG90

A lightweight servo motor (rotary/linear actuator) that we will use in the lock/door mechanism

HC-05 BT MODULE

A bluetooth module allows our ARDUINO circuit to connect to apps on our mobile devices

PROCEDURE



PART A

MAIN CIRCUITRY

A1: RFID CIRCUITRY

A2: REMAINING CIRCUITRY



PART B

PROGRAMMING

B1: PROGRAMMING



PART C

BLUETOOTH & APP

C1: CIRCUITRY

C2: BLUETOOTH

C3: APPLICATION

PART A1



Follow the schematic below to build the RFID circuit

VCC = Voltage Common Collector
RST = Reset
GND = Ground (negative terminal)
MISO = Master IN Slave OUT
MOSI = Master OUT Slave IN
SCK = Serial Clock
SDA = Serial Data



WHAT IS MASTER AND SLAVE?

Used for SPI (Serial Peripheral Interface) between a master and slaves. The master (our rfid reader), as the name suggests, controls the slave devices (our rfid tags) and serves as their communication hub



BUT... DOES IT WORK?

Opening up the ARDUINO IDE and installing a special package for our RFID module, we can load in a sketch named DumpInfo.

Upload this sketch to our ARDUINO and scan a card. If it shows a hex dump, congrats!

PART A2



The following 3 will be added to the circuit:

LEDs

3 LEDs will light up according to access status, and what mode the user is in

SG90

Servo will drive the door mechanism, which we are not going into detail here

Reset

A wipe button will reset all the UID data for convenience



LEDs

Green wire to pin 3
Red wire to pin 4
Blue wire to pin 2
All to GND via 220ohm resistors


SG90

PWM (orange) to pin 8
VCC (red) to 5V
GND (brown) to GND


RESET

Yellow wire to A0
220ohm resistor to GND
Red wire to 5V

PART B



Next, code a program in the ARDUINO IDE to upload to our ARDUINO. The finished code is found here. The code should ask for a tag to be scanned (which will be the master tag) on the first run

The following is a flowchart explaining what else the code does



PART C1



Below is an explanation of the pins on the HC-05 module:

KEY pin allows us to swap between 2 modes: COMMAND mode (configure module settings) and DATA mode (communicate with other BT devices)

STATE pin allows us to see if the module is functioning as intended

RX and TX pins allows the module to recieve and send data via bluetooth to other devices (respectively)



Now connect the HC-05 module as follows:

VCC to 5V
GND to GND
Tx (blue) to pin 0 (RX<--)
Rx (yellow) to pin 1 (-->TX) via 1Kohm resistor


NOTE: the blue and yellow wires should be connected after any programs are uploaded as it will interfere with the uploading process

PART C2



Before getting to the actual app, we should test the functionality of our module. This section will lead to an app that Turns an LED on and off



CREATING THE APP

First, create an application in MIT app inventor, such as the image below. The names given are important to programming the components, so it's best to follow:

btChooseText: "CONNECT TO BLUETOOTH" list picker, will show a list of bluetooth devices to connect to when clicked

connectedStateText: "NOT CONNECTED" text label, will indicate whether the device is connected to a bluetooth device

onBtn, offBtn: "TURN ON" and "TURN OFF" buttons respectively, will be clicked to switch the LED

BluetoothClient1: will help the application connect with the bluetooth module

Clock1: will execute certain blocks every 1s



Head over to the BLOCKS tab and add the following (explanations below):

TOP BLOCK: btChooseText will show a list of available bt devices to connect to when clicked

BOTTOM BLOCK: The app will connect to a device when its name is clicked on

This block will change connectedStateText to show "CONNECTED" if the app is connected to a bt device, and "NOT CONNECTED" otherwise

These blocks will send the number "1" (decimal 49 in ASCII) when onBtn is clicked, and the number "0" (decimal 48 in ASCII) when offBtn is clicked

ARDUINO IDE

In the arduino IDE, comment out the whole code and add in this code. This will turn on the red LED at pin 4 (refer to Step A2) if it receives a 1 from the BT module, and turns it off if it receives a 0

PART C3



Now the actual application will be made. Note that the edited ARDUINO code will be shown AT THE END OF C3

The following subparts will build up the application:

C3.0

Prepare the application and arduino code and reverse certain changes from C2 for C3.1 and beyond

Each of the following features will have state values that will be sent from the app to the BT module representing different settings and requests. The idle state value is 0

C3.1

Force the lock open even without a key. A state value of 1 will force access

C3.2

Force the lock closed even with valid UIDs scanned. A state value of 2 will keep the lock closed

C3.3

Let the user choose from a selection of 3 lengths which the lock stays open after access is granted. State 3: 2s, state 4: 6s, state 5: 10s







Find the finished C3 code here



REFERENCES

What Is RFID and How Does It Work?

Sarah Amsler & Sharon Shea, TechTarget, Mar 2021

DIY Smart Lock with Arduino and RFID

Ian Buckley, MakeUseOf, Apr 2017

All about HC-05 Bluetooth Module | Connection with Android

Aryan Verma, GeeksforGeeks, Oct 2021

How To Build Custom Android App for your Arduino Project using MIT App Inventor

Dejan Nedelkovski, How To Mechatronics, Mar 2016

RFID Interfacing: MFRC-522 Reader/Writer Module

Ruzell Ramirez, CircuitRocks, Aug 2020