In this lesson, we will show how to use the Osoyoo IoT Kit to build a RFID access control system. Before starting this lesson, you can get more information about the RFID module from this link.
First, please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:
Build the circuit as below:
RFID Module – RFID Port
Please confirm whether the wiring is correct according to the VCC and GND pins
Prerequisite:
You need to install Local Blynk Server, Blynk APP, Arduino IDE, Blynk Libraries before running the code of this lesson. We suppose you have installed them in previous lessons. If you haven’t done these installations, please read following contents in lesson2-1 link:
https://osoyoo.com/2021/04/29/osoyoo-smart-home-iot-blynk-lesson-2-1-simple-control/#prerequisite
You also need to download and install the Servo library and RFID library from following links:
https://osoyoo.com/driver/Servo.zip
https://osoyoo.com/driver/Smart_House_IoT_Learning_Kit_V2.0_code/RFID.zip
In Arduino IDE, click Sketch->Include Library ->Add .ZIP library and upload the library zip files to the IDE.
Servo Test
Step i)Before upload the code, we should adjust the servo angle first. Please remove the items from the wooden house’s door area:
Then please download the servo test code from this link, unzip it:
https://osoyoo.com/driver/Smart_House_IoT_Learning_Kit_V2.0_code/servo_config.zip
Step 2 After above operations are completed, connect OSOYOO MEGA2560 Board to PC with USB cable.
Step ii) Open Arduino IDE: Choose corresponding board type and port type for you project.
Step iii) Arduino IDE: Click file – Open, then choose code in the folder, load up the sketch onto your Arduino.
Upload the sketch to the board. Wait until you see something like this:
Done uploading
Step iv) After upload the code, the servo will turn to 0 degree position, now we install the wooden gear and the white fixed arm:
Step 5 Press the button, the door can be simulated to open, when released, the door can be simulated to close.
After Servo test and installation is completed, we can go to next task
Download and Edit Lesson2-5 Arduino code file:
Step 1 : Download the code from following link:
https://osoyoo.com/driver/Smart_House_IoT_Learning_Kit_V2.0_code/Lesson2-5.zip
Unzip above file and double click lesson2-5.ino to open the file in Arduino IDE.
You need to edit the code as following:
**********************************************************
Note: In the sketch, find these code in line 13,14 as following:
char auth[] =”0ByWpc50cmOJ5O6OyHMaK4OSHkDvUeI-”;
char server_ip[]=”192.168.1.81″; // replace this line with your Blynk Server IP addres;
Replace 0ByWpc50cmOJ5O6OyHMaK4OSHkDvUeI- with your local Blynk Token.
Replace 192.168.1.81 with your local Blynk Server LAN IP address.
If you don’t know how to get token and Server IP address, read this article.
In lines 18,19 and replace *** with your wifi ssid/password
char ssid[] = "***";//replace this line with your wifi ssid
char pass[] = "***"; //replace this line with your wifi password
please replace the *** with your correct wifi SSID and password, otherwise your project can not connect to Internet.
**********************************************************
Add your own RFID Card ID:
After completing the above steps and uploading the code, open the IDE serial monitor, you can see that the system is initialized successfully, and then put your RFID card in the RDID module recognition area, you will see your serial monitor will display your The card information is as follows:
RFID START!
Find the card!
Card type: Unknown
The card's number is : 71BA2F2ECA
Then find these lines:
if( id[0]==0x32 && id[1]==0xDA && id[2]==0x94 && id[3]==0x10 )
And change the id data to your own card number,so the changed code is:
if( id[0]==0x71 && id[1]==0xBA && id[2]==0x2F && id[3]==0x2E )
In the same way, you can add or modify your card information at will, and finally, re-upload the code to the Arduino and continue the experiment.
**********************************************************
Upload the sketch to the board. Wait until you see something like this:
Done uploading
Now open your Serial Monitor, you will see Arduino is trying to talk to Blynk server. After 20 to 30 seconds, your Serial monitor will finally shows Arduino’s IP address and a “Ready (ping: 25ms)” ending message.
Congratulations! You are all ready! Your hardware is now connected to the Blynk server.
Open your project page and press the “+” button to add the “LCD” Widget.
Widget settings:
INPUT ADVANCED
INPUT V11
After you finished all above operations, press the “▷“ button. This will switch you from EDIT mode to PLAY mode where you can interact with the hardware.
While in PLAY mode, you won’t be able to drag or set up new widgets, press “□” and get back to EDIT mode.
After you finished all above operations, approximate the RFID card or the keychain to the reader. Open the Serial Monitor and you will get some informations of the card. If you update your card information to the code, when you use the corresponding card, Let the reader and the tag closer , you will see that the corresponding name is printed in the serial monitor, and LED will be lit for a second.
No. | Picture | Device | Qty. | Link |
1 | OSOYOO MEGA2560 Board | 1 | Click here to buy | |
2 | OSOYOO MEGA-IoT Extension Board | 1 | Click here to buy | |
3 | Photosensitive Sensor | 1 | Click here to buy | |
4 | Temp & Hum Sensor | 1 | Click here to buy | |
5 | OSOYOO Active Buzzer Module | 1 | Click here to buy | |
6 | Flame Detection Sensor | 1 | Click here to buy | |
7 | Fan Motor Module | 1 | Click here to buy | |
8 | Micro Servo Motor | 1 | Click here to buy | |
9 | RGB Module | 1 | Click here to buy | |
10 | Ultrasonic Sensor | 1 | Click here to buy | |
11 | PIR Motion Sensor | 1 | Click here to buy | |
12 | Microphone Module | 1 | Click here to buy | |
13 | 1602 I2C LCD Screen | 1 | Click here to buy | |
14 | RFID Module | 1 | Click here to buy | |
15 | White LED Module | 1 | Click here to buy | |
16 | Red LED Module | 1 | Click here to buy | |
17 | Colorful Light | 1 | Click here to buy | |
18 | Red Button Module | 1 | Click here to buy | |
19 | Blue Button Module | 1 | Click here to buy | |
20 | Philips Screwdriver | 1 | Click here to buy |
DownLoad Url osoyoo.com