Industrial Safety & Security System

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

Things used in this project

Hardware components

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

Software apps and online services

Arduino IDE

Hand tools and fabrication machines

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





In this project we are going to make a project that is related to Industrial/Factory safety and security system. Here we will build up a demo project for this. But it can be implemented in real life.


Hardware list


There are a lot of hardware we have used in this project. All the hardware list has given below:


-Arduino Mega


-Arduino Nano




-Potentiometer (1K)


-Gas Sensor Module (Model-MQ4 )


-Vibration Sensor Module (Model- MOD-00187)


-PIR Motion Sensor


-Dust Sensor (Model-SEN-00170)


-Temperature Sensor (dht22)






-LCD Monitor (20x4)


-Servo Motor (SG90)


-4 x 4 Matrix Keypad


-LED (5 mm) --> Green-1 and Red-2




First we we build up a secured door for the industry/factory. It will be a password protected door. If anyone press the wrong password it would be alert everyone through the buzzer. Only the door will open when someone enter the correct password.


Next we have to take care some machines of the industry or factory. When operating some machines, it can vibrate more than normal situation. So, our vibration sensor will sense the vibration and alert the control room to turn off the machines or speed down to the machines.


Some rooms will be store some important things in a factory or industry. So there will maybe few employees have the right to enter those room. So, there will be a motion sensor in these rooms. So, any unauthorized persons will not be entered these rooms. If authorize persons enter the room they will turn off the motion sensor before entering the room.


Temperature plays an important roles in an industry or factory. So, every time we need to monitor the temperature of machines or products. From the control room they can control the temperature by turning on or off the fans.


Gas emission will also be monitor properly in an industry or factory. Some gas are toxic and that will not good for human health. So, when gas emits in a inaccurate level an exhaust fan will turn on automatically and emit the gases from the industry.





We have provide all the codes and whole circuit diagram in this project. In this project we have used two micro-controller one is Arduino Mega and Arduino Nano. For each board we have provided 2 codes in the code section.



Github Project links:

Custom parts and enclosures

Industrial Safety and Security System


Industrial Safety and Security System


Industrial Safety Code


// 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)

#define DHTPIN 11     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)
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() {

  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


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

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

void loop() {

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

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

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

void temperature() {
  //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");

//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);
    digitalWrite(ledpin1, LOW);

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

//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);
    //digitalWrite(Buzzerpin, LOW);
  else {
    digitalWrite(exFan, LOW);

  //  Serial.println(analogRead(A0));

Industrial Security Code (Only for Door)


#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
  pinMode(redled, OUTPUT);
  pinMode(greenled, OUTPUT);
  myservo.attach(12); //SERVO ATTACHED//
void loop()

void mykeypad() {
  char code = keypad.getKey();
  if (code)
  if (code != NO_KEY) {
    if (code == password[currentposition]) {
      if (currentposition == 4) {
        digitalWrite(greenled, HIGH);
        currentposition = 0;
        digitalWrite(greenled, LOW);
    else {
      currentposition = 0;

//Door Open
void unlockdoor()

  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

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

//Wrong Code
void incorrect()
  digitalWrite(redled, HIGH);
  digitalWrite(redled, LOW);

Industrial Safety and Security System

MakerBuddy / Smart_Industry

A smart security and safety system of an industry. This is a Arduino based project. — Read More

icon 1.1MB Download(1)

The article was first published in hackster, September 10, 2021


Khaled Md. Saifullah;
Shahadat Hossain Afridi;

Avijit Datta

All Rights