# Smart-Gym-Locker-ESP32-RFID
An IoT-based secure locker system using ESP32, RFID authentication, and the ThingsBoard platform for remote monitoring and control.
# Smart Gym Locker System with RFID & IoT Monitoring

An intelligent and secure locker management system designed to solve locker scarcity in shared spaces like gyms and universities. This project uses an ESP32 microcontroller, RFID for authentication, and the ThingsBoard IoT platform for real-time remote monitoring and control.

![rendered of the Smart Locker in action](wide_locker.png)
![close front view of the Smart Locker in action](front_view_locker.png)
---

## 🎬 Live Demo

Record of a short 15-30 second GIF showing the locker circuit connection working and the dashboard updating.

![Demo GIF of the Smart Locker in action](GYM_locker.gif)

---

## 🌟 Key Features

* **RFID Authentication:** Assigns lockers on a first-come, first-served basis using unique RFID cards.
* **Timed, Exclusive Access:** Once assigned, a locker is reserved for a user for a predefined period (e.g., 2 or 24 hours).
* **Real-time IoT Dashboard:** Facility managers can view locker status (Green: Vacant, Red: Occupied), review access logs, and receive security notifications via the ThingsBoard platform.
* **Remote Admin Control:** Administrators have the ability to remotely unlock any locker for maintenance or security inspections.
* **Automated Security Alerts:** The system sends a notification if a locker is left open for more than 30 minutes and indicates unauthorized access attempts with a flashing LED.
* **Handle-Free Design:** A servo motor provides automated unlocking, slightly pushing the door open for the user.

---

## 🛠️ Hardware & Tech Stack

| Category | Component / Technology | Purpose |
|---|---|---|
| **Microcontroller** | ESP32 | Core for processing, Wi-Fi & Bluetooth  |
| **Authentication** | MFRC522 RFID Reader & Cards  | Contactless user authentication  |
| **Actuator** | SG90 Servo Motor | Automated locking/unlocking mechanism |
| **Sensors** | Infrared (IR) Sensor  | Detects if the locker door is open or closed |
| **IoT Platform** | ThingsBoard  | Real-time data visualization and remote control  |
| **Firmware** | Arduino IDE (C++)  | Programming the ESP32 |
| **Libraries** | PubSubClient, WiFi  | MQTT Communication & Internet Connectivity |

---

## 🔌 Schematics & Build

The project was assembled on a breadboard for prototyping. The image below shows the physical setup, and the diagram details the pin connections.

| Experimental Setup | Circuit Diagram |
| :---: | :---: |
| <img src="IMG_20250325_200244.jpg" alt="Experimental Setup" width="450"> | <img src="GYM_circuit.png" alt="Circuit Diagram" width="300"> |


---

## ☁️ IoT Dashboard

The ThingsBoard dashboard provides a centralized interface for monitoring all lockers. Administrators can see at a glance which lockers are vacant or occupied and can perform remote actions.

![Screenshot of the ThingsBoard Dashboard](link_to_your_dashboard_screenshot.png)


---

## ⚙️ How to Set Up & Run

1.  **Clone the Repository:**
    ```bash
    git clone [https://github.com/your-username/Smart-Gym-Locker-ESP32-RFID.git](https://github.com/your-username/Smart-Gym-Locker-ESP32-RFID.git)
    ```
2.  **Hardware Assembly:** Connect the components as detailed in the circuit diagram and the pin assignment table.
3.  **Software Setup:**
    * Open the firmware code in the Arduino IDE.
    * Install the required libraries: `PubSubClient`, `MFRC522`, etc.
    * Configure your network credentials and ThingsBoard access token in the `config.h` file.
4.  **Upload & Run:** Flash the code to your ESP32 board. The device will connect to Wi-Fi and begin sending data.
