Build a Smart Cardboard House with Arduino Uno R4 and RFID

In this blog, you are going to learn how to build a house from cardboard and control its door automatically using the Arduino Uno R4 WiFi and the RC522 RFID Reader module.

I’ll show the necessary steps to make the project, as well as the components used.

Make sure you have the Arduino IDE installed on your machine before we get started.

Description

To build the house, I had to use cardboard since I didn’t buy a 3D printer machine. The most important part of the house is the door. While building it, I drew the shape of the door with a pen, of course, then I made the necessary cuts with a sharp knife to create a door that can open and close using the RC522 RFID and a tiny servo motor, SG90.

I invented a mechanical system to control the movement of the door. I used a hot-glue machine and attached two small sticks together, then glued them to the rotating plastic arm of the SG90 servo motor.

On the top-left side of the door, behind it, I fixed the servo motor. The free ends of the two glued sticks were connected to the top-left corner of the door, allowing it to move when the servo motor rotates to open and close the door.

I got another pair of sticks, glued them together, and connected them to a simple linkage mechanism(made out of cardboard) at the bottom-left corner of the door.

Electronic components used

  • Arduino Uno R4 WiFi
  • RC522 RFID Module
  • SG90 Servo Motor
    (You can also use another servo type)
  • Passive Buzzer

Servo Motor Pinout

The SG90 servo motor that I’m using is a very tiny servo motor, and it has three cables:

1- VCC pin (red cable)
2- Data pin (yellow cable)
3- GND pin (brown cable)

We connect the red cable of the servo motor to the Arduino Uno R4 Wi-Fi 5V pin, its data pin (yellow jumper) to an Arduino Uno R4 Wi-Fi pin that’s capable of generating PWM signals, and the GND pin (brown cable) to the Arduino Uno R4 Wi-Fi GND pin.

RFID RC522 Reader

The RFID RC522 reader module is a very popular module based on the MFRC522 controller. It works at a frequency of 13.56 MHz, which is the radio frequency used to communicate with tags and RFID cards. Operating at 13.56 MHz means the module sends and receives electromagnetic waves at 13.56 million cycles per second. The 13.56 MHz electromagnetic field can power passive cards (cards without batteries) like RFID cards and key fobs.

Learn more about the RC522 RFID Module by clicking here: Interface Arduino Uno R4 WIFI with RFID RC522 Module

RC522 RFID module pinout

The module has 8 pins; you may not need to use all of them for simple projects. Here’s the pinout:

3.3V – Power Supply
RST – Reset
GND – Ground
IRQ – Interrupt (optional)
MISO – Master In Slave Out
MOSI – Master Out Slave In
SCK – Clock
SDA/SS – Slave Select for SPI

Only 3.3V, RST, GND, MISO, MOSI, SCK, and SDA are used for most Arduino projects.

Circuit Diagram

Arduino Code

#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>

Servo myservo;

#define SS_PIN 10
#define RST_PIN 9


#define Alarm 7
#define SERVO_PIN 5
int  ServoPosition = 30; 

MFRC522 mfrc522(SS_PIN, RST_PIN);

void setup() {
  myservo.attach(SERVO_PIN);

  Serial.begin(9600);

  SPI.begin();
  mfrc522.PCD_Init();
  myservo.write(ServoPosition);

  pinMode(Alarm, OUTPUT);
}

void loop() {
  // RFID section
  if (!mfrc522.PICC_IsNewCardPresent() || !mfrc522.PICC_ReadCardSerial()) {
    return; // No new card, exit RFID part
  }

  // Read UID
  Serial.print("UID tag: ");
  String content = "";
  for (byte i = 0; i < mfrc522.uid.size; i++) {
    Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(mfrc522.uid.uidByte[i], HEX);

    content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
    content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  Serial.println();
  Serial.println();

  content.toUpperCase();

  // Authorized card
  if (content.substring(1) == "0B 23 9B 15") {
    Serial.println("Access Granted - Door open");
   ServoPosition = 75;
    myservo.write(ServoPosition);
    delay(2000);
    ServoPosition = 30;
    myservo.write(ServoPosition);
  }

  // Unauthorized card
  else if (content.substring(1) == "52 EF E9 1C") {
    Serial.println("Access Denied - Door closes");
    digitalWrite(Alarm, HIGH);
    delay(2500);
    digitalWrite(Alarm, LOW);
    ServoPosition = 30;
    myservo.write(ServoPosition);

  }

  mfrc522.PICC_HaltA();
  mfrc522.PCD_StopCrypto1();
}

How the Project Works

When the system is powered on, the servo motor starts at 30°, which is the closed-door position. The RFID reader and alarm are also ready.

The RFID reader constantly scans for any card placed near it. If no card is detected, the system does nothing and waits.

If the card is not authorized:
The buzzer turns ON for a few seconds, and the door stays at 30°, remaining closed.

The system checks the UID:

  • If the card is authorized:
    The servo moves from 30° to 75°, opening the door. After a short pause, the servo returns to 30°, closing the door automatically.

  • If the card is not authorized:
    The buzzer turns ON for a few seconds, and the door stays at 30°, remaining closed.

3 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *