Iot 8
Iot 8
Experiment 8
1. Aim:
To create a smart door lock system using RFID
2. Objectives:
• Learn about IoT based simulations.
• Testing and model in IoT based simulation platform.
3. Software/Components Used:
▪ Arduino Uno
▪ RFID
▪ LCD
▪ I2C module
▪ Servomotor
▪ Door lock
▪ Jumper Wires
Arduino:
It is an open-source electronics platform. It consists ATmega328 8-bit Micro controller. It can be able to
read inputs from different sensors & we can send instructions to the micro controller in the Arduino. It
provides Arduino IDE to write code & connect the hardware devices like Arduino boards & sensors.
4. Procedure:
▪ Connect RFID reader (SDA to pin 10, RST to pin 9, SPI pins).
▪ Connect LCD with I2C module (SDA to A4, SCL to A5).
▪ Connect servomotor (signal wire to pin 8).
▪ Power components (5V and GND to Arduino).
▪ Upload the code to Arduino.
▪ Test the system with RFID cards Connect the MQ135 sensor to the Arduino Uno using male-to-
female jumper wires.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
5. CODE:
#include <SPI.h>
#include <Servo.h>
#include <LiquidCrystal.h>
#include <RFID.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
Servo myservo; // Servo object for controlling the door
#define val0 117 // Token value for user 1 #define val1 134 // Token value for user 2 int pos = 0;
#define SDA_DIO 10
#define RESET_DIO 9
RFID RC522(SDA_DIO, RESET_DIO);
void setup()
{ myservo.attach(8);
Serial.begin(9600);
SPI.begin();
RC522.init(); // Initialize RFID reader
lcd.begin(16, 2);
}
void loop() {
byte i = 0; intID; if (RC522.isCard()) {
RC522.readC
ardSerial();
Serial.println(RC522.serNum[i], DEC);
Serial.println("Card detected:");
ID = RC522.serNum[0];
}
User 1
if (val0 == ID) {
lcd.clear();
lcd.print("Access
Granted");
lcd.setCursor(0, 1);
lcd.print("Welcome Haris");
delay(1800); lcd.clear();
lcd.print("Door
Opening"); delay(1500); for (pos = 0;
pos <= 180; pos++) { myservo.write(pos);
// Rotate servo toopen door delay(15);
} delay(5000); lcd.clear(); lcd.print("Door
Closing"); delay(1500); for (pos = 180;
pos >= 0; pos--) { myservo.write(pos); //
Rotate servo to close door delay(15);
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
} } else if (val1
== ID) {
lcd.clear();
lcd.print("Access
Granted");
lcd.setCursor(0, 1);
lcd.print("Welcome
Bilal"); delay(1800);
lcd.clear();
lcd.print("Door
Opening");
delay(1500); for (pos =0;
pos <= 180; pos++)
{ myservo.write(pos);
delay(15);
} delay(5000);
lcd.clear();
lcd.print("Door
Closing");
delay(1500);
for (pos = 180; pos >= 0; pos--) {
myservo.write(pos);
delay(15);
}}else{
Lcd.clear();
lcd.print("DoorSecurity "); lcd.setCursor(0,1);
lcd.print("System");
}
}
6. Connections:
VCC pin 5V
GND pin GND
7. Result:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
8. Conclusion:
By following the setup procedure, the Arduino Uno is ready for programming and communication with
the motor for various projects and experiments. A smart door lock system using RFID offers a secure,
efficient, and modern solution for access control. By integrating an RFID reader with a microcontroller like
Arduino, users can unlock doors by simply tapping authorized RFID cards or tags. The system uses a relay
module to activate an electronic lock, ensuring that access is only granted to approved individuals. This
technology eliminates the need for traditional keys, reducing the risk of unauthorized entry or lost keys..