Buy from US Buy from UK Buy from DE Buy from FR Buy from IT Buy from ES

In this project, we will make a simple RFID (IC card) + IoT controlled security door system.

Security Door normally is often opened by servo motor. To make things simple, we just use servo turning 90 degree to imitate door open and rotate back to 0 degree to imitate door close.

The whole procedure will be work as follows:
When an IC card  detected by RC522 RFID module, Arduino will verify if its ID matches record.

If ID matches record, then servo turn 90 degree . Green LED turn on and Red LED turn off.

If  ID does not match record, then, servo does not move, instead, the buzzer will alarm(you need use browser to turn off alarm from remote computer).

At any time, remote browser can open the door(servo rotate to 90 degree) or close the door (servo back to 0 degree)  or turn off buzzer and monitor door status.

First, please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:

Then connect the modules with the OSOYOO MEGA-IoT Extension Board with three 3-pin PnP cables and one 8pin 12cm Female to Female Cable as below (Jumper Cap should connect ESP8266 RX with A8, TX with A9):

Green LED Module – D12

Red LED Module – D11

Buzzer Module – D5

Micro Servo Motor – D3

RFID Module – RFID

Notice: Shut off your battery or Unplug your power adapter when upload sketch code to Arduino.

Step 1 Install latest Arduino IDE (If you have Arduino IDE version after 1.1.16, please skip this step)
Download Arduino IDE from https://www.arduino.cc/en/Main/Software?setlang=en , then install the software.

Step 2 WifiEsp Library Installation (if you have installed WifiESP library, please skip this step)

OSOYOO MEGA-IoT extension TX/RX pin to Arduino A9/A8 pin by default. So in Arduino sketch code, we need use Software Serial Port to communicate with ESP8266 (set A9 as TX and A8 as RX in softwareserial object).

To use this wifi shield in Arduino IDE, we need download WiFiEsp-master library from following link:
https://osoyoo.com/driver/WiFiEsp-master.zip

Open Arduino IDE, click Sketch – Include Library- Add .Zip library to load above zip files into Arduino IDE.

Step 3 RFID Library Installation

You need install RFID library and save it as above operations.  Please read following article to test RFID library:

Osoyoo MEGA-IoT Shield RFID Tutorial: Get ID of a RFID card

Remember to change write down the RFID number of one ID card.

Step 4 After installing above library, please download the main code from following link, unzip it, you will see a folder called “smarthome-lesson16”:

https://osoyoo.com/driver/smarthome/smarthome-lesson16.zip

Step 4 After above operations are completed, connect OSOYOO MEGA2560 Board to PC with USB cable.

Step 5 Arduino IDE:  Choose corresponding board type and port type for you project .

Step 6 Arduino IDE:  Click file – Open, then choose code “smarthome-lesson16.ino” in the folder, load up the  sketch onto your Arduino.

Remember to change the lines 19 of the code with the card number you got from Step 3):
unsigned char my_rfid[] = {186,11,86,89,190}; // replace {186,11,86,89,190} with your own RFID card number

Note: In the  sketch, find  line 24,25 as following:

char ssid[] = "******"; // your network SSID (name)char pass[] = "******"; // your network password

please replace the ****** with your correct wifi SSID and password, otherwise your project can not connect to Internet.

After loading the sketch to Arduino , open the serial monitor in the upper-right corner of Arduino IDE, you will see following result:

From the serial monitor, you can see the IP address of your MEGA2560 board in the read circle (in above picture, 192.168.50.102).

Then use your browser to visit the website http://mega2560-ip-address (in following case, http://192.168.50.27), you will see following result :
Figure A

Running Result:
When you use an IC card which matches the value in code line 19, the door will open(servo rotate to 90 degree) and Green LED is ON.

When you use an IC card which does not match value of line 19, the door will NOT open and RED LED is ON. Buzzer will also alarm.

In remote browser showed in Figure A, click one of the 3 links, you can open the door, close the door and turn off buzzer from remote browser.