BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Home alarm security

Hello
I want your help with this plan.
First of all, let me introduce it to you, I use the board nodmcu
I have created 6 zones, an indication for activation-deactivation,
as well as a buzzer.
I control all this with the blynk application.
after I have added the following statements:
case1–alarm on
case2–alarm off
case3–alarm panic
case4–home mode
how can i add a RFID sensor to the program (on-off )
and if I can add a 15-second delay to the input door sensor
what other corrections, additions do you suggest?
thanks

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "@@@@@@@";

// Your WiFi credentials.
// Set password to "" for open networks.
//char ssid[] = "@@@@@";
//char ssid[] = "@@@@@";
char ssid[] = "######";
char pass[] = "@@@@@@";

bool alarm_mode = false ;
bool sensorf = false  ;
int alarm_led = 4;
int sensor = 5;  //GPIO Pin number on which sensor is connected
int sensor_1 = 13;  //GPIO Pin number on which sensor is connected
int buzzer = 15; //GPIO Pin number on which buzzer is connecte
int pir_sensor = 14; //GPIO Pin number on which sensor is connected
int pir_sensor1 = 16; //GPIO Pin number on which sensor is connected
int pir_sensor2 = 12; //GPIO Pin number on which sensor is connected
int pir_sensor3 = 10;
BlynkTimer timer;

void myTimerEvent(){
  
    if(digitalRead(sensor) == 0){
    Blynk.virtualWrite(V0, "CLOSE");}

    if(digitalRead(sensor_1) == 0){
    Blynk.virtualWrite(V2, "CLOSE");}

   if(digitalRead(pir_sensor1) == 0){
    Blynk.virtualWrite(V3, "CLOSE");}

    if(digitalRead(pir_sensor2) == 0){
    Blynk.virtualWrite(V4, "CLOSE");}

   if(digitalRead(pir_sensor) == 0){
    Blynk.virtualWrite(V5, "CLOSE");}

    if(digitalRead(pir_sensor3) == 0){
    Blynk.virtualWrite(V6, "CLOSE");}
   
  
  if(digitalRead(sensor) == 1){
    Blynk.virtualWrite(V0, "OPEN");
    if(alarm_mode == true){
     Blynk.notify(" DOOR is open, Alarm Mode ON"); 
     digitalWrite(buzzer, HIGH); 
     }
     }       
      if(digitalRead(sensor_1) == 1){
    Blynk.virtualWrite(V2, "OPEN");
    if(alarm_mode == true){
      Blynk.notify("WINDOW is open,Alarm Mode ON");
      digitalWrite(buzzer,HIGH);
    }
    }

        if(digitalRead(pir_sensor1) == 1){
    Blynk.virtualWrite(V3, "OPEN");
    if(alarm_mode == true && sensorf == false){
      Blynk.notify("ALERT,radar apothikh is open,Alarm Mode ON");
      digitalWrite(buzzer,HIGH);
    }
    }

    if(digitalRead(pir_sensor3) == 1){
    Blynk.virtualWrite(V6, "OPEN");
    if(alarm_mode == true && sensorf == false){
      Blynk.notify("ALERT,RADAR @@@@@@ IS OPEN,ALARM MODE ON");
      digitalWrite(buzzer,HIGH);
    }
    }
    
       if(digitalRead(pir_sensor2) == 1){
   Blynk.virtualWrite(V4, "OPEN");
   if(alarm_mode == true && sensorf == false){
    Blynk.notify("ALERT,radar paidiko is open,Alarm Mode ON");
      digitalWrite(buzzer,HIGH);
    }
    }

       if(digitalRead(pir_sensor) == 1){
    Blynk.virtualWrite(V5, "OPEN");
    if(alarm_mode == true && sensorf == false){
      Blynk.notify("ALERT,radar saloni is open,Alarm Mode ON");
      digitalWrite(buzzer,HIGH);
    }
  }
  }

BLYNK_WRITE(V1) {
  switch (param.asInt()) {
    case 1: { // Item 1
      Serial.println("Item 1 selected");
      alarm_mode = true;
    sensorf = false;
  digitalWrite(alarm_led, HIGH); 
      break;
    }
    case 4: { // Item 4
      Serial.println("Item 4 selected");
      alarm_mode = true;
      sensorf =true;
      digitalWrite(sensor, HIGH); 
    digitalWrite(alarm_led, LOW); 
      break;
    }
    case 2: { // Item 2
      Serial.println("Item 2 selected");
      alarm_mode = false;
    sensorf = false;
   digitalWrite(buzzer, LOW);
      digitalWrite(alarm_led, LOW);  
      break;
    }
    case 3: { // Item 3
      Serial.println("Item 3 selected");
      alarm_mode = false;
    sensorf = false;
    digitalWrite(buzzer, HIGH);  
      digitalWrite(alarm_led, LOW);  
      break;
    }    
  }
}
BLYNK_CONNECTED() {
    Blynk.syncAll();
}
void setup()
{
  pinMode(sensor,INPUT_PULLUP);
  pinMode(buzzer,OUTPUT);
  pinMode(alarm_led,OUTPUT);
  pinMode(pir_sensor,INPUT_PULLUP);
  pinMode(sensor_1,INPUT_PULLUP);
  pinMode(pir_sensor1,INPUT_PULLUP);
  pinMode(pir_sensor2,INPUT_PULLUP);
  pinMode(pir_sensor3,INPUT_PULLUP);

  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  
  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);
  //timer.setInterval(500L, myTimerEvent);
 
}
void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
}

Hello gpoly1973,
I readed your topic because I’m working on a simular project as Home Security.
How far are you with your project ?
In my project , Home Security , I will work following a “Hybride Alert System”, using magnetic sensors and RF Sensors (sending Door_Open and Door_Closed codes), programmed with a ESP32 Pico module. As controlling the system I want to use the Blynk App and a manual command board with buttons and Leds.
For the moment I’m looking for the basic code to integrate the magnetic sensors and the RF sensors, but until now withoutany succes.

The neatest way to do this is to have one (or more if your property needs it) 433MHz receiver connected to a NodeMCU or similar.
This will allow the signals from 433MHz PIR and door/window sensors (plus other 433 devices such as smoke detectors, panic buttons etc) to be picked-up.
My preference for this type of project is to use MQTT messaging between devices, and have the control logic and Blynk integration handled in Node-Red, but it’s possible to do it in Blynk using Bridge code.
Rather than LEDs and physical buttons, a much neater option would be to use a Nextion touch screen.

Either way, you’ll need good programming skills, which it sounds like you may be lacking at the moment?

Pete.

Thanks Pete for your vision on my project. I had the same ideas in mind and concerning programming I’m not a noob. For the moment I prefer to use the ESP32 Pico as processing element with integrated Wifi & Bluetooth connections. I had the Nextion touch screen as visualisation in mind, but for the moment no experience with it ! But we don’t have to invented the wheel again for programming projects, therefore I joined this Blynk forum to find some code snippets to help me. Blynk is a new concept for me !