Hello all;
There are two projects that I have done, but neither project is my code.
In project 1, I use a HTML page to trigger the relay. No issues and everything works great
In project 2, I use IFTTT and if an alarm is received than I get an email and notice that the door is open.
Both of these work great alone but I am wondering if I get both of these into one device. This way it will save me 50% cost.
I use this on my family lodge for their front door. The reset works good for resetting the modem that locks up once in a while.
----- Project 1: -----
Boron Lte
Non Latching Relay Featherwing
----- Code -----
int PowerPin = D2;
void setup() {
pinMode(PowerPin, OUTPUT);
Particle.function("cycle",cyclePower);
digitalWrite(PowerPin, LOW);
}
void loop() {
// Nothing to do here
}
int cyclePower(String command) {
digitalWrite(PowerPin,HIGH);
delay(10000);
digitalWrite(PowerPin,LOW);
return 0;
}
----- Project 2: -----
Boron Lte
Magnetic Door switch
----- Code -----
int DAP = D9;
int DAR = D13;
int led = D7;
void setup() {
Serial.begin(230400);
pinMode(DAP,OUTPUT);
pinMode(DAR,INPUT);
pinMode(led, OUTPUT);
}
void loop() {
while (Particle.connected()) {
if(digitalRead(DAR)==HIGH) {
Particle.publish("doorStatus","DOOR OPEN",30);
digitalWrite(led, HIGH);
delay(5000);
}
else {
// Particle.publish("doorStatus","DOOR CLOSED",30);
digitalWrite(led,LOW);
// delay(5000);
}
}
}