BLYNK and Driveway Sensor - Bridged

I finally got a Guardline driveway alarm for my long driveway. They work well and are the favorites in rural settings. Basically a well housed and adjustable PiR and a nice base station. Reading the manual before purchase I found that it indeed has a NO/NC relay output. I can BLYNK that. I set up next to the alarm and added two bridge units for remote parts of the house like downstairs and out back. i also, get Blynki Notifications. Bridge has been very reliable. Best part, I get alarms when I am not at home. Additional Virtuals are to silence the unit.

    // D1 mini pro Driveway Alarm Base
#define BLYNK_PRINT Serial
#include <ESP8266mDNS.h>  // ***********For OTA w/ ESP8266
#include <WiFiUdp.h>  // **********For OTA
#include <ArduinoOTA.h>  // ************For OTA
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "XXXXXXXXXXXXXbb90e47adb36661480d31a738";
// 2nd auth code  XXXXXXXXX66b9e9af21be7a8d8f4
char ssid[] = "OnHub";
char pass[] = "XXXXX";
char IP[] = "blynk.equinemediaworld.com";  // The

WidgetBridge bridge1(V7);
int x, x2, x3, x4, x5, x6;
int val = 0;

SimpleTimer timer;

BLYNK_CONNECTED() {
  bridge1.setAuthToken("XXXXXXXXXXXe9af21be7a8d8f4");
  Blynk.syncVirtual(V0);
  Blynk.syncVirtual(V1);
  Blynk.syncVirtual(V2);
  Blynk.syncVirtual(V3);
  Blynk.syncVirtual(V4);
  Blynk.syncVirtual(V5);
}
BLYNK_WRITE(V0) {
  x = param.asInt();
}
BLYNK_WRITE(V1) {
  x2 = param.asInt();
}
BLYNK_WRITE(V2) {
  x3 = param.asInt();
}
BLYNK_WRITE(V3) {
  x4 = param.asInt();
}
BLYNK_WRITE(V4) {
  x5 = param.asInt();
  if (x5) {
    tone1();
  }
}
BLYNK_WRITE(V5) {
  x6 = param.asInt();
  if (x6) {
    tone2();
  }
}

void tone1( ) {
  Serial.print("TONE 1");
  for (int z = 0; z < 7; z++) {
    tone(15, 440, 200);
    delay(500);
    tone(15, 800, 200);
    delay(500);
  }
  bridge1.virtualWrite(V8, 1);
  delay(500);
  bridge1.virtualWrite(V8, 0);


}
void tone2( ) {
  Serial.print("TONE 2");
  for (int z = 0; z < 8; z++) {
    tone(15, 900, 200);
    delay(100);
    tone(15, 600, 200);
    delay(100);
  }
  bridge1.virtualWrite(V9, 1);
  delay(500);
  bridge1.virtualWrite(V9, 0);

}

void PIRval() {
  val = 0;
  val = digitalRead(13);  // Driveway
  Serial.print("PIRval 1 = ");
  Serial.println(val);
  if ( x2 == 1 && val == HIGH) {
    digitalWrite(16, HIGH);
    tone1( );
  }
  else {
    digitalWrite(16, LOW);
  }
  if (val == HIGH && x == 1) {
    Blynk.notify("Driveway Alarm");
  }
  //=============================================
  val = 0;
  val = digitalRead(12);   // Front Door
  Serial.print("PIRval 2 = ");
  Serial.println(val);
  if ( x4 == 1 && val == HIGH) {
    digitalWrite(16, HIGH);
    digitalWrite(4, HIGH);
    tone2( );
  }
  else {
    digitalWrite(16, LOW);
    digitalWrite(4, LOW);
  }

  if (val == HIGH && x3 == 1) {
    Blynk.notify("Front Door Alarm");

  }

}


//=====================================


void setup()
{
  // Debug console
  // Serial.begin(9600);
  Blynk.begin(auth, ssid, pass, IP, 8080);

  pinMode(12, INPUT);  // PIR 1
  pinMode(13, INPUT);  // PIR 2
  pinMode(16, OUTPUT); //LED
  pinMode(5, OUTPUT); //LED
  pinMode(4, OUTPUT); //LED
  pinMode(15, OUTPUT); //Tone Alarm

  for (int y = 0; y < 6; y++) {
    digitalWrite(16, HIGH);
    delay(100);
    digitalWrite(16, LOW);
    delay(100);
  }

  digitalWrite(16, HIGH);
  delay(500);
  digitalWrite(16, LOW);
  delay(500);
  digitalWrite(5, HIGH);
  delay(500);
  digitalWrite(5, LOW);
  delay(500);
  digitalWrite(4, HIGH);
  delay(500);
  digitalWrite(4, LOW);
  delay(500);

  timer.setInterval(300L, PIRval);
  ArduinoOTA.setHostname("d1 mini Pro Driveway Alarm Base");  // For OTA - Use your own device identifying name
  ArduinoOTA.begin();  // For OTA
}

void loop()
{
  Blynk.run();
  timer.run();
  ArduinoOTA.handle();  //************* For OTA
}

Bridge 1

// D1 Mini Driveway Alarm
//+++++++++ remote ++++++++++++++++
#include <ESP8266mDNS.h>  // ***********For OTA w/ ESP8266
#include <WiFiUdp.h>  // **********For OTA
#include <ArduinoOTA.h>  // ************For OTA
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "XXXXXXXXXXXXXX6b9e9af21be7a8d8f4";
char ssid[] = "OnHub";
char pass[] = "XXXXXXXXX";
char IP[] = "blynk.equinemediaworld.com";  // The
int x1, x2;
BLYNK_CONNECTED() {
  Blynk.syncVirtual(V8);
  Blynk.syncVirtual(V9);
  tone(15, 440, 500);
}
BLYNK_WRITE(V8) {
  x1 = param.asInt();
  if (x1) {
    tone1();
  }
}
BLYNK_WRITE(V9) {
  x2 = param.asInt();
  if (x2) {
    tone2();
  }
}

void tone1( ) {
  Serial.print("TONE 1");
  for (int z = 0; z < 7; z++) {
    tone(15, 440, 200);
    delay(500);
    tone(15, 800, 200);
    delay(500);
  }
}
void tone2( ) {
  Serial.print("TONE 2");
  for (int z = 0; z < 12; z++) {
    tone(15, 900, 200);
    delay(100);
    tone(15, 600, 200);
    delay(100);
  }
}

void setup()
{
  // Debug console
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass, IP, 8080);
  digitalWrite(0, LOW);
  delay(500);
  digitalWrite(0, HIGH);
  pinMode(0, OUTPUT); //LED
  pinMode(15, OUTPUT); //Tone Alarm
  ArduinoOTA.setHostname("D1 Mini Pro Drive Alarm Remote 2");  // For OTA - Use your own device identifying name
  ArduinoOTA.begin();  // For OTA
  tone1();
}

void loop()
{
  Blynk.run();
  ArduinoOTA.handle();  //************* For OTA
}
2 Likes

great. You should perhaps do two things though…
a) remove your auth tokens from this post
b) obtain new auth tokens

now that these ones are public, someone could start sending you false alerts…

1 Like