Electron - Security System Retrofit

So I have a house with a Brinks security system installed that is not being used.

I was thinking that hacking this with a Electron should be pretty simple and this would actually be a useful project.

So the all the doors and windows already have magnetic reed switches installed to detect if any of them are open or closed.

I’m thinking that all I need to do is figure out which wires are ran to each window and door switch and then read the OPEN or closed status via a I/O pin on the Electron. These wires are probably pretty long considering they are running throughout the whole 1500 square foot house. Should the long wires be a issue or not?

I have power to this box so I can feed the Electron power 24/7 and if the power goes out the battery will keep it running for 24 hours or more.

I think the easiest thing to do is hook this up with Ubidots to trigger SMS phone alerts & email alerts when any of the doors are opened and then log that data also for future reference.

I could also find the siren that they should have installed also and use it if I want to using a Mosfet to feed it 12v power.

I’m mainly just looking for advice on tapping the door and window switches with the Electron and how to properly write the code so its scanning all these as quickly as possible without blocking other functions from running.

Any ideas or improvements are welcome.

I guess I could use a XBee and have this Same Electron tell me when the mail arrives via another Xbee in the mail box.

For door and window contacts, things should be pretty straightforward. One thing to know is that most hardwired alarm systems don’t just have a switch at the end of a pair of wires. There is probably either a single or double end-of-line resistor setup. These allow the controller to sense if the wire has been shorted or cut. With a proper pull-up resistor and some math and a connection to an analog input you can also decode the cut or shorted states, in addition to open and closed states. You can just use a digital input and a pull-up resistor if you only want to track open and closed.

1 Like

FYI - Most alarm systems DO NOT have end-of-line resistors installed end-of-line. They’re usually installed in the panel even thought it defeats the purpose.

I’ve done this same thing, but for a trailer alarm. The Electron makes this a great application with the cellular connection.

int door1 = D0;
int door2 = D1;
int door3 = D2;
unsigned long Lockout;


void setup() {
    pinMode(door1, INPUT_PULLDOWN);
    pinMode(door2, INPUT_PULLDOWN);
    pinMode(door3, INPUT_PULLDOWN);
    pinMode(alarm, OUTPUT);
    Lockout = millis();
}

void loop() {
    

if (millis() >= Lockout){  // check how long its been since last opened
        if(digitalRead(door1) == HIGH) {  //read the door switch
            delay(50);
            if(digitalRead(door1) == HIGH) {  // debounce check again to make sure 
                Lockout = millis() + 60000; // set up the lockout period 60 seconds before it will run again
                RGB.control(true);
                RGB.color(0,255,0); // make the LED go green so you know its triggered
                digitalWrite(alarm, HIGH); //Set alarm relay to high to activate alarm
                Particle.publish("yourwebhook","data", PRIVATE);
                
                delay(1000); //so we can see the LED for 1 sec
                RGB.control(false); // put the LED back to normal
           }
      }
}
if (millis() >= Lockout){  // check how long its been since last opened
        if(digitalRead(door2) == HIGH) {  //read the door switch
            delay(50);
            if(digitalRead(door2) == HIGH) {  // debounce check again to make sure 
                Lockout = millis() + 60000; // set up the lockout period 60 seconds before it will run again
                RGB.control(true);
                RGB.color(0,255,0); // make the LED go green so you know its triggered
                digitalWrite(alarm, HIGH);//Set alarm relay to high to activate alarm
                Particle.publish("yourwebhook","data", PRIVATE);
                
                delay(1000); //so we can see the LED for 1 sec
                RGB.control(false); // put the LED back to normal
           }
      }
}     
if (millis() >= Lockout){  // check how long its been since last opened
        if(digitalRead(door3) == HIGH) {  //read the door switch
            delay(50);
            if(digitalRead(door3) == HIGH) {  // debounce check again to make sure 
                Lockout = millis() + 60000; // set up the lockout period 60 seconds before it will run again
                RGB.control(true);
                RGB.color(0,255,0); // make the LED go green so you know its triggered
                digitalWrite(alarm, HIGH); //Set alarm relay to high to activate alarm
                Particle.publish("yourwebhook","data", PRIVATE);
                
                delay(1000); //so we can see the LED for 1 sec
                RGB.control(false); // put the LED back to normal
           }
      }
}
}

A couple of people here helped me out with this code, so why not share it? If you haven’t already finished this project, hopefully this will help. I never added an alarm, but it should be pretty easy to do. I wanted to add a disable button, but I was on a time constraint with this project, so we just dealt with it.

2 Likes