It is a room availability project developed by the SkySis team.
Table of Contents
This project is a collaboration between SKYSIS and WebLab teams. By scanning student cards inside the room, the project displays real-time information about individuals and activities on oda.skylab.com. This allows authorized personnel in our club room to monitor activities remotely.
To get a local copy up and running follow these simple steps.
You need to have Arduino IDE installed on your machine.
-
Clone the repo:
https://github.com/skylab-kulubu/Skysis-Room-Availability-System.git cd project_name
-
Follow the steps below to set up the development environment.
- Download and install Arduino IDE.
- Open Arduino IDE and navigate to
File -> Preferences
. - In the "Additional Boards Manager URLs" field, add
https://dl.espressif.com/dl/package_esp32_index.json
and click "OK". - Go to
Tools -> Board -> Boards Manager
, search foresp32
, and install the ESP32 boards. - Select your board as
ESP32 Wrover Module
:Tools -> Board -> ESP32 Wrover Module
.
You need to install the following libraries:
- WiFi
- HTTPClient
- SPI
- MFRC522
- ArduinoJson
To install these libraries, open Arduino IDE and navigate to Sketch -> Include Library -> Manage Libraries
. Search for each library and click the "Install" button.
- Open Arduino IDE.
- Navigate to
File -> Open
and select the.ino
file in the project directory. - After opening the project in Arduino IDE, make the necessary settings (e.g., selecting the correct board and port).
Connect the ESP32 to your computer and select the correct port from Tools -> Port
. Then, upload the code to the ESP32 by navigating to Sketch -> Upload
(or click the "Upload" button in the top left corner).
Here's the code used in this project:
#include <WiFi.h>
#include <HTTPClient.h>
#include <SPI.h>
#include <MFRC522.h>
#include <ArduinoJson.h>
#include <iostream>
#include <stdio.h>
#include <string.h>
// Wi-Fi settings
const char* ssid = "sky-lab";
const char* password = "sky-labpassword";
// RFID RC522 settings
#define SS_PIN 15
#define RST_PIN 22
MFRC522 mfrc522(SS_PIN, RST_PIN);
void setup() {
Serial.begin(115200);
SPI.begin();
mfrc522.PCD_Init();
Serial.println("Connecting to Wi-Fi...");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nConnected to Wi-Fi.");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
}
void loop() {
if (!mfrc522.PICC_IsNewCardPresent() || !mfrc522.PICC_ReadCardSerial()) {
delay(500);
return;
}
// Read RFID UID
String rfid_uid = "";
for (byte i = 0; i < mfrc522.uid.size; i++) {
rfid_uid += String(mfrc522.uid.uidByte[i] < 0x10 ? "0" : "") + String(mfrc522.uid.uidByte[i], HEX);
}
rfid_uid.toUpperCase();
Serial.print("RFID UID: ");
Serial.println(rfid_uid);
const char* c = rfid_uid.c_str();
// Web server URL
const char* server = "https://oda.yildizskylab.com/api/room/passCard/";
char serverName[100];
strcpy(serverName, server);
strcat(serverName, c);
// Send HTTP request if Wi-Fi is connected
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
http.begin(serverName);
// Create JSON data
StaticJsonDocument<200> jsonDoc;
jsonDoc["room"] = rfid_uid;
String jsonData;
serializeJson(jsonDoc, jsonData);
// Send HTTP POST request
http.addHeader("Content-Type", "application/json");
int httpResponseCode = http.POST(jsonData);
if (httpResponseCode > 0) {
String payload = http.getString();
Serial.print("HTTP Response Code: ");
Serial.println(httpResponseCode);
Serial.print("Response: ");
Serial.println(payload);
}
http.end();
}
delay(10000);
}
Red Wire: VCC
Green Wire: RST
Black Wire: GND
Purple Wire: MISO
Yellow Wire: MOSI
Blue Wire: SCK
Pink Wire: SS
Below is the list of required components for this project along with links to purchase them:
- ESP32 Development Board: Buy here
- MFRC522 RFID Reader: Buy here
- Jumper Wires: Buy here
- Breadboard: Buy here
- USB Cable for ESP32: Buy here
- Gepro UM-0255 5V 2A Adapter:Buy here
- Connect the MFRC522 RFID Reader to the ESP32 as follows:
- RST to GPIO 22
- SDA to GPIO 15
- MOSI to GPIO 23
- MISO to GPIO 19
- SCK to GPIO 18
- GND to GND
- 3.3V to 3.3V
For detailed wiring and setup, refer to the ESP32 and MFRC522 Wiring Guide.
-
After completing the connections, upload the code to your ESP32 using the steps mentioned earlier.
-
Open the Serial Monitor in Arduino IDE (
Tools -> Serial Monitor
) and set the baud rate to115200
. -
Verify that the ESP32 connects to Wi-Fi and reads the RFID card's UID.
-
Each time an RFID card is read, its UID will be sent to the web server, and the response code will be displayed in the Serial Monitor.
"TO KNOW MORE ABOUT OUR STUDENT BRANCH: SKYLAB"