Spark Core with Spark Relay Board - Garage Door Issues - please help!

CODE UPDATED - it was incorrect on the OP:

Greetings fellow Particle People! I am in desperate need of some assistance from the community for my garage door project others have made look so easy. I’ll thank you in advance!! I’ve laid out my request for help in two parts…Questions without detail and questions with detail:

  • I have already setup my Spark/Particle Core and it is operating correctly.

Questions without the details
(1) Where do the two garage wires go into the relay board?
(2) Where do the two wires from the reed switch come from (COM/NO or COM/NC)?
(3) Where do the two wires from the reed switch go into the relay board (COM/NO or COM/NC)?
(4) When coding the software, do I simply bring the Relay Board and IFTTT libraries in and flash the Spark/Particle?

Desired State: Operate my single garage door using IFTTT, by way of the Spark Core and Spark Core Relay Board.

Products being used: (1) Spark Core module (1) Spark Core Relay Board (1) Standard “reed switch” (can be wired to NO or NC)

**Please note that the Spark Core items were replaced by the Particle Core and I understand they operate if not exact, very similar to the Partcle Core. I’m just ruling out that as a possible issue. Photos are included with the questions below:

Here is what is (not) going on:

I have been reading several other members’ tutorials on building a garage door opener with the Particle, some have used various means to operate. Personally, I like the IFTTT route as we use this in our household with other projects. That said, I’m having the hardest time trying to figure out how to wire and code my project.

Hardware/Wiring:
(1) From my garage door button on the wall, there are two wires…red and white. I understand that these are just signals and need to go into one of the four relay “pods” (green in photo). Do I wire into COM/NO or COM/NC? (first and second pictures)


(2) From the “reed switch”, there are two wires…red and white with an option to wire COM/NO or COM/NC. Which of these combos should I wire into? Do they go into the relay and if so, to COM/NO or COM/NC? (third picture)
<img src="//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/business7/uploads/particle/original/2X/4/4ea744008a470c91c95c695587e77fe1c1c9ac5d.JPG” width=“375” height=“500”>

Coding/Software:
(1) Attached/below is the code from the libraries I am using. As I understand, I should bring in the Relay Board library, make a slight adjustment to indicate it’s the Spark Core Relay Board, save, verify and flash. However, doing that, I don’t get any response from the Relay Board, just the Spark which is responsive. The relay board is getting power and appears to be working correctly.

    // This #include statement was automatically added by the Particle IDE.
#include "RelayShield/RelayShield.h"

// Create an instance of the RelayShield library, so we have something to talk to
RelayShield myRelays;

void setup() {
    // .begin() sets up a couple of things and is necessary to use the rest of the functions
    myRelays.begin(2);

    // Use myRelays.begin(2); if you have the square, white RelayShield (from the Core)
    // to use, just add a '2' between the parentheses in the code above.
}

void loop() {
    // If relay1 is on, then turn it off
    
    
    if(myRelays.isOn(1)){    // myRelays.isOn(1) will return TRUE if relay 1 on and FALSE if it's off
        myRelays.off(1);     // myRelays.off(#) will switch relay # off
    }
    
    // If it wasn't already on, then turn it on
    else{
        myRelays.on(1);      // myRelays.on(#) will switch relay # on
    }
    
    // Change it once a second
    delay(1000);
}

I truly believe that everything is working properly, it’s just hooked up incorrectly. The hardware can’t read the incorrect software or the software can’t tell the hardware what to do. For whatever the reason, I am stuck right in the middle and would really appreciate some assistance! Thanks again in advance!

Andrew

Just a few questions:

What kind of garage door control is it (there are simple ones which you would replace completely and more fancy ones which you’ll keep but only talk to via the Core)?
Have you had that garage door wired conventionally before?
If so, what did/does the momentary switch that’s usually there too do, when you push it?
What happens when you push it once? Release it? Push it twice?

The answers to this should give you some clue what you’d need to “copy” in order to make your Particle appear as if it were the push button.

As for the reed switch.
What does it do in the conventional setup?
Does it “interact” with the switch or just signal open/closed without any direct action?

If you want to replace the control unit completely, I’d say you wouldn’t feed the reed through a relay (as itself acts as a switch) but rather wire it directly to an input pin of the Core.

Thanks for the response, see below:

The garage door is a simple one that works perfectly, similar to what others have used with their Core’s. It’s never been wired “conventionally” other than the original install.

  • Button on the wall - Press once and it either opens or closes (inside there are two wires - red and white). Press again and it either opens or closes, depending on the previous state. Again, simple button.
  • The reed switch or magnetic door sensor - this is new and similar to what others have used. Ideally this switch should tell the system if the garage is open or closed. Again, I’ve seen most other tutorials on here that use the same setup as I wish to use.
  • Control unit replacement - I don’t think I need to replace the wall button as I have seen others on here with the same setup.

Any suggestions on the code below? This is what is currently flashed on my Spark Core. IF I were to add in the reed switch, I believe I need to add some code for that…but I don’t know what that would be.

// This #include statement was automatically added by the Particle IDE.
#include "RelayShield/RelayShield.h"

// Create an instance of the RelayShield library, so we have something to talk to
RelayShield myRelays;

void setup() {
    // .begin() sets up a couple of things and is necessary to use the rest of the functions
    myRelays.begin(2);

    // Use myRelays.begin(2); if you have the square, white RelayShield (from the Core)
    // to use, just add a '2' between the parentheses in the code above.
}

void loop() {
    // If relay1 is on, then turn it off
    
    
    if(myRelays.isOn(1)){    // myRelays.isOn(1) will return TRUE if relay 1 on and FALSE if it's off
        myRelays.off(1);     // myRelays.off(#) will switch relay # off
    }
    
    // If it wasn't already on, then turn it on
    else{
        myRelays.on(1);      // myRelays.on(#) will switch relay # on
    }
    
    // Change it once a second
    delay(1000);
}

Let’s focus on the wiring first.

Without knowing what your wall button does, I’d guess it’s an N/O button that closes the circuit when pushed.
So this is what you’d need to copy with a relay which is wired parallel to your button (COM - N/O).

This should give you the control side of things.

The reed sensor is the feedback side of it.
For starters you could connect COM to GND on the Core and N/O to any free pin on the Core.
Use pinMode(sensPin, INPUT_PULLUP) and check digitalRead(sensPin) to see if the reed gets switched.

If that doesn’t work, you might need to use Vin instead of GND and an external pull-down resistor in combination with pinMode(sensPin, INPUT) instead.

To test your setup you could first go with the Tinker app before writing your own logic (you won’t need the ReleayShield library at all).

ScruffR - this was helpful, at least I’m a little closer to getting it up and running! Here’s the latest:

(1) Connected two wall wires (red/white) to RELAY #4 (COM/NO) (which incidentally is controlled in Tinker by D3) - I can open/close my garage via Tinker!

(2) Reed sensor connected D1 and GND, as you suggested with any free pin, I used D1 and tried digitalRead, digitalWrite and even analogWrite. The only thing it did was light up & click the RELAY #1. I think it’s just missing some code to get it to work correctly, which leads me to my next question.

My question to you is the code you indicated above, where does that go? Since I’m using Tinker for the moment, I don’t see a place to put this?

Here are some updated photos, just in case:

Thanks again for your help, I really, really appreciate it!

With free pin I meant a pin that is not used on the Relay Shield.
When you hear a relay work when you do digitalWrite on the pin it’s not free :wink:

For sensing the reed, you’d use digitalRead on the pin, but since you won’t be able to use INPUT_PULLUP with Tinker, you’d just need to put your own pull-up resistor (e.g. 10k) from your sensing pin to 3V3.
Then you should digitalRead HIGH when the reed is open and LOW when it’s closed.

So, here’s an update to my garage door project. It’s not 100% working but getting close.

The photo below is how it is hooked up. At this point, the only way the door opens or closes is by me holding the other side of the magnetic reed switch. It’s basically operating as the ‘button’. The good news is that I believe it’s wired correctly at this point. The bad news, IFTTT is not recognizing it.

<img src="//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/business7/uploads/particle/original/2X/9/97f23422e87dc9fbbc57468ec3b230ad55d05259.JPG” width=“375” height=“500”>

I believe the code is too heavy and incorrect. I’m hoping you can comment and provide a solution to this final step to my setup!

Please note that I’ve basically copied everything from this Particle project - it happens to be the exact project I’m trying to complete. The project is located: https://www.hackster.io/silicon-override-15/photon-garage-opener-775152?ref=part&ref_id=9500&offset=39

// This #include statement was automatically added by the Particle IDE.
#include "RelayShield/RelayShield.h"
// This #include statement was automatically added by the Particle IDE.
#include "RelayShield/RelayShield.h"
// Create an instance of the RelayShield library, so we have something to talk to
RelayShield myRelays;
// Create prototypes of the Spark.functions we'll declare in setup()
int relayOn(String command);
int relayOff(String command);
int checkStatus(String command);

//pin initializations
const int pinReedSensor = A0;

// Initialize a generic message in case we don't get a real status lower.
const char* STATUS_MESSAGE_UNAVAILABLE = "Status unavailable.";
const char* STATUS_MESSAGE_CLOSED = "Closed";
const char* STATUS_MESSAGE_OPEN = "Open";

void setup() {
    
    //.begin() sets up a couple of things and is necessary to use the rest of the functions
    myRelays.begin(2);

    // Register Spark.functions and assign them names
    Particle.function("relayOn", relayOn);
    Particle.function("relayOff", relayOff);
    Particle.function("toggleRelay", toggleRelay);
    Particle.function("checkStatus", checkStatus);
    // door reed sensor - this is visible from an IFTTT check if you wish
    Particle.variable("doorStatus", STATUS_MESSAGE_UNAVAILABLE, STRING);

}
//sense if door is open or not in this loop.
void loop() {
    // loop over Reed switch status to see if doors are open or closed.

    const char* message = STATUS_MESSAGE_UNAVAILABLE;
    
    if(digitalRead(pinReedSensor) ==1){
        // Left door closed (removed code for right to simplify)
        message = STATUS_MESSAGE_CLOSED; 
    }
    
    if(digitalRead(pinReedSensor) ==0){
        // door open
        message = STATUS_MESSAGE_OPEN;
    }    
   
    // this constantly sets the variable for dooStatus that can be seen by IFTTT
    Particle.variable("doorStatus", message, STRING);
}

// function to check door status that we can use from DO Button app.  
//  Same as in loop, but only checks when called.  
//  The DO Button calls this, and raises a Spark.publish("status") variable which IFTTT listens for.
//  This is what allows you to call the function via your iPhone or Apple Watch, and in about a second, get an answer.
int checkStatus(String command){
    // Ritual incantation to convert String into Int
    char inputStr[64];
    command.toCharArray(inputStr,64);
    
    const char* message = STATUS_MESSAGE_UNAVAILABLE;
    
    if(digitalRead(pinReedSensor) ==1){
        // Left door closed
        message = STATUS_MESSAGE_CLOSED;
    }
    
    if(digitalRead(pinReedSensor) ==0){
        // door open
        message = STATUS_MESSAGE_OPEN;
    }    
   
    Particle.publish("status", message);
    return 1;
}

int relayOn(String command){
    // Ritual incantation to convert String into Int
    char inputStr[64];
    command.toCharArray(inputStr,64);
    int i = atoi(inputStr);
    
    // Turn the desired relay on.  
    // From your Do Button config, call the relay, and pass in 1 through 4 for the Relay to turn on.
    myRelays.on(i);
    
    // Respond
    return 1;    
}

// Momentarily turn on, then off the relay you want.  This simulates a button press when you hook the 
// physical button to the normally open (two left) leads on the relay.  Again, pass in the number of the relay to control.
// In IFTTT Do Button app, call the Photon, then point the function to toggleRelay, and in the arguments field, jut put a 1 for example.
int toggleRelay(String command){
    // Ritual incantation to convert String into Int
    char inputStr[64];
    command.toCharArray(inputStr,64);
    int i = atoi(inputStr);
    
    // Turn the desired relay on
    myRelays.on(i);
    delay(500);
    myRelays.off(i);
    // Respond
    return 1;    
}

//  This is used in toggleRelay, however, it can also be used stand alone if you have a normally closed relay and want
//  to temporarily open it.
int relayOff(String command){
    // Ritual incantation to convert String into Int
    char inputStr[64];
    command.toCharArray(inputStr,64);
    int i = atoi(inputStr);
    
    // Turn the desired relay off
    myRelays.off(i);
    
    // Respond
    return 1;    
}

As always, a HUGE thanks in advance!!!

I see several problems and places for improvement.

You’ve included RelayShield/RelayShield.h twice, so remove one of those.

Particle variables, like particle functions should only be registered once in setup, they should not be called from loop. However, if I remember IFTTT correctly, it would be better to use Particle.publish() anyway. IFTTT will pick up the data from it whenever you publish, whereas with a variable, IFTTT only reacts to it when it meets a certain criteria (like > than some value).

It’s ok to poll the value of your input pin in loop, but I would generally use an interrupt to do that instead, since it is an asynchronous event. In the ISR, you would set the value of some flag ( e.g. reedSwitchState), and you would check that in loop instead of what you’re doing there now. You would then publish the state of the pin (in loop), but only when it changes. Be aware of the limit on how often you can publish. You might have to debounce the reed switch signal to ensure it doesn’t trigger the ISR multiple times in quick succession (I’m not sure about that, since I haven’t used a reed switch before).

To simplify the code somewhat, I would probably only use one particle function for the relay. The value you pass to that function could be something like “on:1”, or “toggle:2”. You could then use strtok to separate that string into the action and number and go from there. Alternately, you could just pass a number as a string, convert that string to an int, and use that in a switch statement. Since you have 2 relays and 3 conditions (on, off, and toggle), you would have 6 possible cases to handle.

I’m very new to all of this, especially the coding. For what it’s worth, I’ve read more about this amazing world, trying to educate myself so I can limit the questions. Until then, I really appreciate this community.

Would you mind looking at this code to see if this will allow me to accomplish my objective? Again, I would really appreciate it!

int interval = 1000;

int state = 1;
char oldState;
int ts = Time.now();

int IN1 = D1; // variable for IN1 on relay
int IN2 = D2; // variable for IN2 on relay
int reed = D5; // variable for reed switch
int led = D7;

int doorstatus = digitalRead(reed); //variable for door status

String statusCheck(){
    int status = digitalRead(reed);
    if(status == HIGH){
        return "CLOSED";
    }
    else if(status == LOW){
        return "OPEN";
    }
    else{
        return "OFFLINE";
    }
}

void setup() {
    // Time.zone(-5);
    Spark.function("relay", relayPulse); 
    Spark.function("open", openDoor);

    pinMode(reed, INPUT_PULLDOWN);
    pinMode(led, OUTPUT);
    pinMode(IN1, OUTPUT);
    pinMode(IN2, OUTPUT);
    
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, LOW);
    
    Spark.variable("state", &state, INT);
    Spark.variable("ts", &ts, INT);
    // startup status
    Spark.publish("door_status", statusCheck());
    Serial.begin(9600);

}


void loop() {

	oldState = digitalRead(reed); //Check the current state
	
	if (doorstatus != oldState){ //Compare current state to status.
		doorstatus = oldState; //Make oldState the new status
		Spark.publish("door_status", statusCheck());
		state = doorstatus;
		ts = Time.now();
		digitalWrite(led, (doorstatus) ? HIGH : LOW);
	}
    
   delay(interval); //Delay Interval millisecond, as to not to overload the server.

}
// for loacation based IFTTT
int openDoor(String command){
    if (statusCheck() == "CLOSED"){ 
    relayPulse(command);
    return 1;
    }
    return 0;
};

int relayPulse(String command){
    Spark.publish("button pushed by ", command);
    digitalWrite(IN1, HIGH);
    delay(2000);
    digitalWrite(IN1, LOW);
    return 1;
};

This code doesn’t do quite what your other code was trying to do, so I’m not sure exactly what you’re trying to accomplish. I still see a few things that are wrong, or outdated. You’re using the old syntax for Particle.variable, which I think still works, but you don’t need the ampersand, or the INT, you can do it simply like so,

Spark.variable("state", state);

Your have a type mismatch in this statement,

oldState = digitalRead(reed);

You typed oldState as a char but digitalRead returns an int. You should change oldState to an int

Other than those things, I think the code looks ok.

In your previous code, you had two relays. I assume one is used to open and close the door, what’s the other one for?

This initialization should not happen since pinMode() is not set at this point, but you can rely on the variable to be reset to zero on startup anyway.

This can be compressed considerably :wink:

String statusCheck(){
    int status = digitalRead(reed);
    if(status == HIGH){
        return "CLOSED";
    }
    else if(status == LOW){
        return "OPEN";
    }
    else{
        return "OFFLINE";
    }
}
// try this instead
String statusCheck() {
    return digitalRead(reed) ? "CLOSED" : "OPEN";
}

Digital read has only two possible results so that'll do fine.

Your pic shows the reed wired to D0 but your code uses D5 - and you should have less of the copper exposed on your wires to avoid risk if shorting.

This will do just the same doorstatus already is exactly this already.

		digitalWrite(led, doorstatus);  // why double work? (doorstatus) ? HIGH : LOW 

Thanks Ric and ScruffR for both of your help. I’ve actually learned quite a bit with this troubleshooting, thank you to you both. I’m pleased to share that I’m able to open & close my garage door using the app Do Button from IFTTT! I simply pull up the app on my iPhone and press the icon.

While this is great, I’m still missing 2 important steps to my initial objective, clearly this is a coding issue and I’m asking for some additional help:

Missing functions - need code?
(1) Determine if my garage door is open or closed by using IFTTT or Do Button. I believe my code needs to have an option to “read” the status of the reed switch sensor so that I can build a recipe in the app. Right now, I’m able to select ‘relay on…’ or ‘open on…’ in Do Button to trigger the open or close recipe. (picture attached) What code would need to be added to “read” the magnetic switch status, giving me the option in the app?

(2) Setup IFTTT and allow it to open the garage automatically when I’m 100 or so yards from my house. Additionally, the moment I leave my driveway, the garage door closes automatically. I’ll tackle these recipes in the app but is there any code I’m missing in Particle to allow this to happen?

int interval = 1000;
int state = 1;
int oldState;
int ts = Time.now();

int IN1 = D1; // variable for IN1 on relay
int IN2 = D2; // variable for IN2 on relay
int reed = D5; // variable for reed switch
int led = D7;
int doorstatus = digitalRead(reed); //variable for door status

String statusCheck(){
    int status = digitalRead(reed);
    return digitalRead(reed) ? "CLOSED" : "OPEN";
    
}

void setup() {
    // Time.zone(-5);
    Spark.function("relay", relayPulse); 
    Spark.function("open", openDoor);

    pinMode(reed, INPUT_PULLDOWN);
    pinMode(led, OUTPUT);
    pinMode(IN1, OUTPUT);
    pinMode(IN2, OUTPUT);
    
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, LOW);
    
    Spark.variable("state", state);
    Spark.variable("ts", ts);
    // startup status
    Spark.publish("door_status", statusCheck());
    Serial.begin(9600);

}

void loop() {

	oldState = digitalRead(reed); //Check the current state
	
	if (doorstatus != oldState){ //Compare current state to status.
		doorstatus = oldState; //Make oldState the new status
		Spark.publish("door_status", statusCheck());
		state = doorstatus;
		ts = Time.now();
		
	}
    
   delay(interval); //Delay Interval millisecond, as to not to overload the server.

}
// for loacation based IFTTT
int openDoor(String command){
    if (statusCheck() == "CLOSED"){ 
    relayPulse(command);
    return 1;
    }
    return 0;
};

int relayPulse(String command){
    Spark.publish("button pushed by ", command);
    digitalWrite(IN1, HIGH);
    delay(2000);
    digitalWrite(IN1, LOW);
    return 1;
};

To check whether the door is opened or closed, you can call a Particle.variable (status) or call a Particle.function; either could be done from an iPhone app. Are you writing any iOS code, or are you just using the Do Button app? As far as opening or closing the door as you leave or approach the house, the one way I can think of to do that, is through an iPhone app that would use the phone’s GPS abilities to determine when it is a certain distance from you home. When it meets that criterion, you would call a Particle.function to open or close the door. You might be able to do this with IFTTT’s iOS Location channel. You should check that out.

Hi Ric,

you can call a Particle.variable (status) or call a Particle.function

I thought I had the correct in the code already? What am I missing?

[quote="Ric, post:13, topic:20611"]
either could be done from an iPhone app
[/quote] Since my coding is using the Particle IDE and not Tinker, I don’t think that’s possible. Are you suggesting there is a way to do this?

[quote="Ric, post:13, topic:20611"]
Are you writing any iOS code, or are you just using the Do Button app?
[/quote] Not writing iOS code. The main code is written in Particle IDE then the ‘recipe’ is made in Do Button. The Do Button reads from Particle but I don’t know what the specific coding is that should be used.

Please know that my questions to the forum have been prefaced by hours of research, trial and error. Good news is that I’m learning along the way!

Sorry, I was imprecise in my wording. What I meant is that you can use a particle variable or function (or a publish) with IFTTT, so I don't think you need any more code (if by code you mean your Particle code). It should be a matter of creating a recipe in IFTTT, but that depends on what you want. Do you want the Photon to automatically alert you (text message, email, something else?) when the door state changes, or do you want to ask it what the state is? I haven't used the Do Button app, so I'm not familiar with its capabilities. Can it display the result passed back from a function, or the data sent in a publish, or display the value of a variable? If so, then you could use that, if not, it seems you'll probably have to make the "action" of the recipe be to send an sms or a notification to your phone.

When I said that either could be done from an iPhone app, I mean that if you're writing your own iOS apps, then yes, you can do that. You can call functions and look at the returned result, or query a variable, etc.

As to your second question, have you checked out the IFTTT iOS location channel? I think that's the only way you'll be able to do what you asked in that question without making a native iOS app, or a web page.

When you say "coding", do you mean on the Particle or are you talking about creating the recipe? I don't think you need any more in your Particle app since you already publish the door state, and also have a variable that reflects that state. I could be more specific in advising you on which way to go, if you can tell me what the Do Button app is capable of, and how you want to see the state of the door.

Ric and ScruffR -

Thanks to you both for your assistance. I learned quite a bit along the way of my garage door project and am delighted to say that it’s almost complete. The code in Particle IDE looks very different from when I began, several of your suggestions were included.

I’ve since posted on the IFTTT/Particle board for some assistance with the final piece - determining what line/code specifically goes into the Particle IDE for IFTTT to “read” the status of the door (open or closed). I’m still lost when it comes to that line(s).

At any case, I’m posting the current code below in case it helps someone else out in the future. Thanks again for all your assistance!!

The following code will accomplish the following:
Open/Close a garage door using a Spark Core or Particle Photon via GO Button by IFTTT. From there, you can make a “recipe” in IFTTT to open or close your garage based on iOS proximity.

int interval = 1000;
    int state = 1;
    int oldState;
    int ts = Time.now();
    
    int IN1 = D1; // variable for IN1 on relay
    int IN2 = D2; // variable for IN2 on relay
    int reed = D5; // variable for reed switch
    int led = D7;
    int doorstatus = digitalRead(reed); //variable for door status
    
    String statusCheck(){
        int status = digitalRead(reed);
        return digitalRead(reed) ? "CLOSED" : "OPEN";
        
    }
    
    void setup() {
        // Time.zone(-5);
        Spark.function("relay", relayPulse); 
        Spark.function("open", openDoor);
    
        pinMode(reed, INPUT_PULLDOWN);
        pinMode(led, OUTPUT);
        pinMode(IN1, OUTPUT);
        pinMode(IN2, OUTPUT);
        
        digitalWrite(IN1, LOW);
        digitalWrite(IN2, LOW);
        
        Spark.variable("state", state);
        Spark.variable("ts", ts);
        // startup status
        Spark.publish("door_status", statusCheck());
        Serial.begin(9600);
    
    }
    
    void loop() {
    
    	oldState = digitalRead(reed); //Check the current state
    	
    	if (doorstatus != oldState){ //Compare current state to status.
    		doorstatus = oldState; //Make oldState the new status
    		Spark.publish("door_status", statusCheck());
    		state = doorstatus;
    		ts = Time.now();
    		
    	}
        
       delay(interval); //Delay Interval millisecond, as to not to overload the server.
    
    }
    // for loacation based IFTTT
    int openDoor(String command){
        if (statusCheck() == "CLOSED"){ 
        relayPulse(command);
        return 1;
        }
        return 0;
    };
    
    int relayPulse(String command){
        Spark.publish("button pushed by ", command);
        digitalWrite(IN1, HIGH);
        delay(2000);
        digitalWrite(IN1, LOW);
        return 1;
    };

I’m not sure what you expect, but you actually seem to have all the required stuff in your firmware as it is.
As either @Ric or @BulldogLowell have already mentioned in another post.

You’ve set up your Spark.variable("state", state) (which should be updated to Particle.variable() tho’) and you are updating status regularly.

Having this in place will already allow you to check your open/closed state
Just have a check with one of these
http://suda.github.io/particle-web-interface/
http://jordymoors.nl/interface/

In order to have IFTTT inform you, you’d need to set up a recipe there (which is not my strongpoint tho’ :blush: )

ScruffR,

I'm not sure what you expect, but you actually seem to have all the required stuff in your firmware as it is.
As either @Ric or @BulldogLowell have already mentioned in another post.

That actually helps me knowing I have the correct firmware. I’ll just need to focus on the IFTTT recipe. BTW, you may have me confused with another post as @BulldogLowell is a new name to me and this is the only thread I’ve been working on. :grinning:

I appreciate the other posts you included, I’ll take a look to see what I can find! Lastly, I wanted to share some photos of the project so you can see the end result. Again, many thanks for the assistance and knowledge gained along the way. Both you and @Ric are exceptional.

This is the Spark Relay board with the Spark Core attached and ready to mount. I ended up soldering in some headers for a clean and safe install. The red/white wires (Reed Switch) go into the D6 and GND headers, respectively. They are secured with a glob of hot glue and will come out the side of the 3D printed case I made.

Underside (I really do enjoy soldering!!)
<img src="//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/business7/uploads/particle/original/2X/e/e154a10c36e133cb02798c7bcdbc361e17374f9b.JPG” width="375" height="500">

This is the case I 3D printed for the Spark Core Relay board - the “posts” and holes on top serve a purpose by driving the LED light from the board to the top of the case.
<img src="//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/business7/uploads/particle/original/2X/5/563bbd0ca9b3afda9df7d7e71ae20de99e40c538.JPG” width="666" height="500">

Wrapped up and ready to mount
<img src="//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/business7/uploads/particle/original/2X/0/043b9f98ba15e373420382c0d5b3403784102ae6.JPG” width="375" height="500">

Power and signal was tied directly into the garage door motor
<img src="//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/business7/uploads/particle/original/2X/5/5465b269b7be25b70afece21b3983b981d127451.JPG” width="375" height="500">

Mounted up - power is fed from a power strip, zip tied to the other side of the garage motor. Notice the blue (sorry, I mean “cyan” :slight_smile: ) LED peeking through on top?

Mounted - the red/white wires in the connector go directly to the garage motor. Coming from the back, the red/white twisted wires are the Reed Switch that serve as sensors - open/closed.

The all important Reed Switch which acts as a sensor - open or closed.

With the 3D printed case, I’m able to tell the status of the Spark Core - in this photo it is glowing a reassuring cyan. I’m also able to see any other indicating LED status very easily.

1 Like