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

Arduino UNO-Based Smart Hall Management System with PIR Sensors and Temperature Control

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Smart Hall Management System with PIR Sensors and Temperature Control

Circuit Documentation

Summary

This circuit is designed to monitor and control the environment of a hall. It includes sensors to detect entry and exit of people, a temperature sensor to monitor the hall's temperature, a relay module to control a chiller, and a buzzer module to provide alerts. The system is controlled by an Arduino UNO microcontroller.

Component List

  1. Arduino UNO

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. PIR Sensor (Entry)

    • Description: Passive Infrared Sensor for detecting motion.
    • Pins: VDD, SIG, GND
  3. PIR Sensor (Exit)

    • Description: Passive Infrared Sensor for detecting motion.
    • Pins: VDD, SIG, GND
  4. Temperature Sensor (TEMP)

    • Description: Sensor for measuring temperature.
    • Pins: 5V, D3, GND
  5. Relay Module 5V-30V

    • Description: Relay module for switching high voltage devices.
    • Pins: common contact, normally open, normally closed, trigger, V-, V+
  6. Buzzer Module

    • Description: Module for generating sound alerts.
    • Pins: GND, Vcc, I/O

Wiring Details

Arduino UNO

PIR Sensor (Entry)

PIR Sensor (Exit)

Temperature Sensor (TEMP)

Relay Module 5V-30V

Buzzer Module

Code Documentation

#include <Wire.h>

// Pin definitions
#define ENTRY_SENSOR_PIN 2
#define EXIT_SENSOR_PIN 3
#define CHILLER_SWITCH_PIN 4
#define TEMP_SENSOR_PIN A0
#define BUZZER_PIN 5

// Constants
const int MAX_CAPACITY = 100;
const int REOPEN_THRESHOLD = 90;
const int TEMP_UPPER_LIMIT = 25; // Degrees Celsius
const int TEMP_LOWER_LIMIT = 24; // Degrees Celsius

// Variables
volatile int peopleInHall = 0;
bool chillerStatus = false;
int hallTemperature = 25;

// Structure to hold parameters
struct HallData {
  int temperature;
  bool chillerStatus;
  int numberOfPeople;
} hallData;

// Function prototypes
void entryDetected();
void exitDetected();
void updateTemperature();
void controlChiller();
void checkCapacity();
void publishData();

void setup() {
  Serial.begin(9600);

  // Pin configurations
  pinMode(ENTRY_SENSOR_PIN, INPUT_PULLUP);
  pinMode(EXIT_SENSOR_PIN, INPUT_PULLUP);
  pinMode(CHILLER_SWITCH_PIN, OUTPUT);
  pinMode(BUZZER_PIN, OUTPUT);

  // Attach interrupts
  attachInterrupt(digitalPinToInterrupt(ENTRY_SENSOR_PIN), entryDetected, FALLING);
  attachInterrupt(digitalPinToInterrupt(EXIT_SENSOR_PIN), exitDetected, FALLING);

  // Initial states
  digitalWrite(CHILLER_SWITCH_PIN, LOW);
  digitalWrite(BUZZER_PIN, LOW);

  Serial.println("System Initialized");
}

void loop() {
  // Fetch temperature data and update chiller status
  updateTemperature();
  controlChiller();

  // Check hall capacity and control alarms
  checkCapacity();

  // Publish data every minute
  static unsigned long lastPublishTime = 0;
  if (millis() - lastPublishTime >= 60000) { // 1-minute interval
    publishData();
    lastPublishTime = millis();
  }
}

void entryDetected() {
  if (peopleInHall < MAX_CAPACITY) {
    peopleInHall++;
  }
}

void exitDetected() {
  if (peopleInHall > 0) {
    peopleInHall--;
  }
}

void updateTemperature() {
  int sensorValue = analogRead(TEMP_SENSOR_PIN);
  hallTemperature = map(sensorValue, 0, 1023, 15, 35); // Simulate temperature range 15-35°C
}

void controlChiller() {
  if (hallTemperature > TEMP_UPPER_LIMIT && !chillerStatus) {
    chillerStatus = true;
    digitalWrite(CHILLER_SWITCH_PIN, HIGH);
  } else if (hallTemperature < TEMP_LOWER_LIMIT && chillerStatus) {
    chillerStatus = false;
    digitalWrite(CHILLER_SWITCH_PIN, LOW);
  }
}

void checkCapacity() {
  if (peopleInHall >= MAX_CAPACITY) {
    digitalWrite(BUZZER_PIN, HIGH); // Alarm ON
    Serial.println("Hall at maximum capacity! Entry gate closed.");
  } else if (peopleInHall <= REOPEN_THRESHOLD) {
    digitalWrite(BUZZER_PIN, LOW); // Alarm OFF
    Serial.println("Hall below reopen threshold. Entry gate reopened.");
  }
}

void publishData() {
  hallData.temperature = hallTemperature;
  hallData.chillerStatus = chillerStatus;
  hallData.numberOfPeople = peopleInHall;

  Serial.println("Publishing Data:");
  Serial.print("Temperature: ");
  Serial.print(hallData.temperature);
  Serial.println("°C");
  Serial.print("Chiller Status: ");
  Serial.println(hallData.chillerStatus ? "ON" : "OFF");
  Serial.print("Number of People: ");
  Serial.println(hallData.numberOfPeople);
}

This code is responsible for monitoring the entry and exit of people, controlling the chiller based on temperature readings, and providing alerts when the hall reaches its maximum capacity. The data is published every minute to the serial monitor.