Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO-Based RFID and GPS School Entry Notification System with GSM Module

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based RFID and GPS School Entry Notification System with GSM Module

Circuit Documentation

Summary

This circuit integrates an Arduino UNO microcontroller with an RFID-RC522 module, a SIM 800L GSM module, and a GPS NEO 6M module. The system is designed to detect RFID tags, obtain GPS coordinates, and send SMS notifications with the location information.

Component List

Arduino UNO

RFID-RC522

SIM 800L

GPS NEO 6M

Wiring Details

Arduino UNO

RFID-RC522

SIM 800L

GPS NEO 6M

Code Documentation

Arduino Code

#include <SPI.h>
#include <MFRC522.h>
#include <SoftwareSerial.h>
#include <TinyGPS++.h>

// RFID Configuration
#define SS_PIN 10
#define RST_PIN 9
MFRC522 rfid(SS_PIN, RST_PIN);

// GSM Configuration
SoftwareSerial gsmSerial(7, 8); // RX, TX for GSM Module
String parentPhone = "+1234567890"; // Parent phone number (replace with actual phone number)

// GPS Configuration
SoftwareSerial gpsSerial(3, 4); // RX, TX for GPS Module
TinyGPSPlus gps; // Create an object of TinyGPS++

String validRFID = "YOUR_RFID_UID";  // Replace with the RFID UID of the student

// LEDs and Buzzer (optional)
int greenLED = 6;
int redLED = 5;
int buzzer = 4;

void setup() {
  // Initialize RFID
  SPI.begin();
  rfid.PCD_Init();
  Serial.begin(9600);
  gsmSerial.begin(9600);
  gpsSerial.begin(9600); // Start GPS serial communication

  // Initialize LEDs and Buzzer
  pinMode(greenLED, OUTPUT);
  pinMode(redLED, OUTPUT);
  pinMode(buzzer, OUTPUT);
}

void loop() {
  if (rfid.PICC_IsNewCardPresent()) {
    if (rfid.PICC_ReadCardSerial()) {
      String rfidUID = "";
      for (byte i = 0; i < rfid.uid.size; i++) {
        rfidUID += String(rfid.uid.uidByte[i], HEX);
      }

      // If the RFID UID matches the student's card, send the SMS
      if (rfidUID == validRFID) {
        digitalWrite(greenLED, HIGH);  // Green LED (entry indication)
        digitalWrite(redLED, LOW);     // Turn off Red LED
        digitalWrite(buzzer, HIGH);    // Turn on Buzzer (optional)

        // Get GPS data
        float latitude = 0.0;
        float longitude = 0.0;
        
        while (gpsSerial.available() > 0) {
          gps.encode(gpsSerial.read());
          
          if (gps.location.isUpdated()) {
            latitude = gps.location.lat();
            longitude = gps.location.lng();
            break;
          }
        }

        // Create the message with GPS coordinates
        String message = "Entry detected: Child has entered the school.\n";
        message += "Location: Latitude: " + String(latitude, 6) + ", Longitude: " + String(longitude, 6);

        // Send SMS to the parent with location info
        sendSMS(message);

        delay(5000); // Wait for 5 seconds to keep the indicators on
        digitalWrite(buzzer, LOW);  // Turn off the buzzer
      } else {
        digitalWrite(greenLED, LOW);  // Turn off Green LED
        digitalWrite(redLED, HIGH);   // Red LED (exit indication)
      }

      delay(2000); // Delay for 2 seconds before next card scan
    }
  }
}

// Function to send SMS with GPS location
void sendSMS(String message) {
  gsmSerial.println("AT+CMGF=1");  // Set SMS to text mode
  delay(1000);
  gsmSerial.println("AT+CMGS=\"" + parentPhone + "\"");  // Send SMS to parent's phone number
  delay(1000);
  gsmSerial.println(message);  // The message to send
  delay(1000);
  gsmSerial.write(26);  // End of message (Ctrl+Z)
  delay(1000);
}

This code initializes the RFID, GSM, and GPS modules, and continuously checks for new RFID cards. When a valid RFID card is detected, it retrieves the GPS coordinates and sends an SMS to a predefined phone number with the location information.