Khaled Md. SaifullahShahadat Hossain AfridiAvijit Datta
Published © MIT

Industrial Safety & Security System

In this project we are going to build a safety and security system for an industry or factory.

AdvancedFull instructions provided12 hours2
Industrial Safety & Security System

Things used in this project

Hardware components

Breadboard (generic)
Breadboard (generic)
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Gravity: Analog CH4 Gas Sensor (MQ4) For Arduino
DFRobot Gravity: Analog CH4 Gas Sensor (MQ4) For Arduino
×1
Grove - Vibration Sensor (SW-420)
Seeed Grove - Vibration Sensor (SW-420)
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Buzzer
Buzzer
×1
Axial Fan, 12 VDC
Axial Fan, 12 VDC
×1
Arduino Mega 2560
Arduino Mega 2560
×1
Arduino Nano R3
Arduino Nano R3
×1
Standard LCD - 16x2 White on Blue
Adafruit Standard LCD - 16x2 White on Blue
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
DHT22 Temperature Sensor
DHT22 Temperature Sensor
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Mastech MS8217 Autorange Digital Multimeter
Digilent Mastech MS8217 Autorange Digital Multimeter

Story

Read more

Custom parts and enclosures

Industrial Safety and Security System

Schematics

Industrial Safety and Security System

Code

Industrial Safety Code

C/C++
// Library Files
#include <DHT.h>
#include <LiquidCrystal.h>
#include <Servo.h>

// LCD Display
#include <LiquidCrystal.h> // includes the LiquidCrystal Library 
LiquidCrystal lcd(6, 5, 4, 3, 2, 1); // Creates an LC object. Parameters: (rs, enable, d4, d5, d6, d7)

//Temperature
#define DHTPIN 11     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE);
int chk;
float hum;  //Stores humidity value
float temp; //Stores temperature value

//Motion Sensor
int ledpin1 = 8;// Digital pin n D6
int pir1;
int sensor1 = 10 ;//motion senson1 on D7

//Gas Sensor
const int smoke = A0;
const int exFan = 7; //exFan
const int threshold = 400;//gas sensor

//Vibration sensor
int vibration = A8; //vibration sensor D0
int LedPin3 = 9; //vibration in led D1

//dust sensor
int measurePin = A15;
int ledPower = 52;

unsigned int samplingTime = 280;
unsigned int deltaTime = 40;
unsigned int sleepTime = 9680;

float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;

void setup() {

  //Motion
  pinMode(sensor1, INPUT);   // declare sensor as input
  pinMode(ledpin1, OUTPUT);  // declare LED as output

  //gas sensor
  pinMode(smoke, INPUT);
  pinMode(exFan, OUTPUT); //Buzzpin for fire alarm

  //temperature
  dht.begin();

  //Vibration
  pinMode (vibration, INPUT);
  pinMode(LedPin3, OUTPUT);

  //Display
  lcd.begin(16, 2);
  lcd.print("Smart Industry");
//  Serial.begin(9600);/
}

void loop() {
  gasSensor();
  temperature();
  vibration_sensor();
  motionDetected1();
  lcd.clear();
  lcd.println(temp);
}

//Vibration
void vibration_sensor() {
  int vibrationvalue = analogRead(vibration);
//  Serial.println(vibrationvalue);/

  if (vibrationvalue == 0) {
    digitalWrite(LedPin3, HIGH);
//    Serial.println("\n Vibration");/
    delay(1000);
  }

  else {
    digitalWrite(LedPin3, LOW);
    Serial.println("\n No Vibration");
    delay(1000);
  }
  //  delay(500);
}


//temperature
void temperature() {
  delay(1000);
  //Read data and store it to variables hum and temp
  hum = dht.readHumidity();
  temp = dht.readTemperature();
//  Serial.print("Humidity: ");
//  Serial.print(hum);
//  Serial.print(" %, Temp: ");
//  Serial.print(temp);
//  Serial.println(" Celsius");
  delay(1000);
}

//Motion Sensor Detection
void motionDetected1() {
  pir1 = digitalRead (sensor1);
  //  Serial.println(pir1);

  if (pir1 == HIGH) {
    digitalWrite(ledpin1, HIGH);
//    Serial.println("\n Motion Detected");/
    // Serial.println(pir1);
    delay(50);
    digitalWrite(ledpin1, LOW);

  }
  else {
    digitalWrite(ledpin1, LOW);
//    Serial.println(" Motion Not Detected");/
    //Serial.println(pir1);
    delay(50);
  }
}

//gas sensor
void gasSensor() {
  int analogValue = analogRead(smoke);

//  Serial.println("\n Gas value = ");/
//  Serial.println(analogValue);/

  if (analogValue > threshold) {
    digitalWrite(exFan, HIGH);
  }
  else if (analogValue == threshold) {
    digitalWrite(exFan, LOW);
    delay(400);
    //digitalWrite(Buzzerpin, LOW);
  }
  else {
    digitalWrite(exFan, LOW);
  }

  //  Serial.println(analogRead(A0));
  delay(500);
}

Industrial Security Code (Only for Door)

C/C++
#include <Keypad.h>
#include <LiquidCrystal.h>
#include <Servo.h>

Servo myservo;
int pos = 0; // LCD Connections
const byte rows = 4;
const byte cols = 4;

char key[rows][cols] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
byte rowPins[rows] = {9, 8, 7, 6};
byte colPins[cols] = {5, 4, 3, 2};
Keypad keypad = Keypad(makeKeymap(key), rowPins, colPins, rows, cols);
const char* password = "4567";
int currentposition = 0;
int redled = 10;
int greenled = 11;
int invalidcount = 12;

void setup()
{
  //  keypad
  Serial.begin(9600);
  pinMode(redled, OUTPUT);
  pinMode(greenled, OUTPUT);
  myservo.attach(12); //SERVO ATTACHED//
}
void loop()
{
  mykeypad();
}

void mykeypad() {
  char code = keypad.getKey();
  if (code)
    Serial.print(code);
  if (code != NO_KEY) {
    if (code == password[currentposition]) {
      ++currentposition;
      if (currentposition == 4) {
        digitalWrite(greenled, HIGH);
        unlockdoor();
        currentposition = 0;
        digitalWrite(greenled, LOW);
      }
    }
    else {
      ++invalidcount;
      incorrect();
      currentposition = 0;
    }
  }
}

//Door Open
void unlockdoor()
{
  delay(900);

  for (pos = 90; pos >= 0; pos -= 5) {
    myservo.write(pos); // tell servo to go to position in variable 'pos'
    delay(5); // waits 15ms for the servo to reach the position
  }
  delay(3000);

  for (pos = 0; pos <= 90; pos += 5) { // in steps of 1 degree
    myservo.write(pos); // tell servo to go to position in variable 'pos'
    delay(15);
    currentposition = 0;
  }
}

//Wrong Code
void incorrect()
{
  delay(500);
  digitalWrite(redled, HIGH);
  delay(3000);
  digitalWrite(redled, LOW);
}

Industrial Safety and Security System

Credits

Khaled Md. Saifullah

Khaled Md. Saifullah

9 projects • 16 followers
Technology and robotics fascinate me a lot. I love to build up different types of projects that are related to our daily life.
Shahadat Hossain Afridi

Shahadat Hossain Afridi

1 project • 4 followers
Avijit Datta

Avijit Datta

1 project • 3 followers

Comments

Add projectSign up / Login