# Help with IFTTT

**URL:** <https://community.particle.io/t/help-with-ifttt/11619>\
**Category:** Integrations\
**Created:** [May 4, 2015, 10:14pm UTC](https://community.particle.io/t/help-with-ifttt/11619 "2015-05-04T22:14:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![danlee6992](https://avatars.discourse-cdn.com/v4/letter/d/c4cdca/32.png) [@danlee6992](https://community.particle.io/u/danlee6992)\
**Post date:** [May 4, 2015, 10:14pm UTC](https://community.particle.io/t/help-with-ifttt/11619/1 "2015-05-04T22:14:20Z")

</div>

I am hoping to get some help with my starter code and using IFTTT to monitor a variable. I currently get an error though. I greatly appreciate any help getting IFTTT to work.

```auto
int motion = D2;
int led = D7;
int val = 0;
char *myMessage = "test";

void setup(){
  Spark.variable(motion, &motion, INT);
  pinMode(motion, INPUT);
  pinMode(led, OUTPUT);
}

void loop(){

  val = digitalRead(motion);

  if (val == HIGH){
    digitalWrite(led,HIGH);
  }
  else if (val ==LOW){
    digitalWrite(led,LOW);
  }
delay(200);
}

```

```auto
Error is:
In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from ifttt.cpp:3:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
#warning "Defaulting to Release Build"
^
ifttt.cpp:5:19: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
void loop();
^
ifttt.cpp: In function 'void setup()':
ifttt.cpp:8:38: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
int led = D7;
^
In file included from ../inc/spark_wiring.h:33:0,
from ../inc/application.h:29,
from ifttt.cpp:3:
../inc/spark_utilities.h:108:14: error: initializing argument 1 of 'static void SparkClass::variable(const char*, void*, Spark_Data_TypeDef)' [-fpermissive]
static void variable(const char *varKey, void *userVar, Spark_Data_TypeDef userVarType);
^
make: *** [ifttt.o] Error 1

Error: Could not compile. Please review your code.

```

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [May 4, 2015, 10:19pm UTC](https://community.particle.io/t/help-with-ifttt/11619/2 "2015-05-04T22:19:36Z")

</div>

> [@danlee6992](#):
>
> Spark.variable(motion, &motion, INT);

It looks like you missed the quotes around the name of your Spark variable.

```cpp
Spark.variable("motion",&motion,INT);

```

[http://docs.spark.io/firmware/#spark-variable](http://docs.spark.io/firmware/#spark-variable)

---

<div class="post-metadata">

**Author:** ![danlee6992](https://avatars.discourse-cdn.com/v4/letter/d/c4cdca/32.png) [@danlee6992](https://community.particle.io/u/danlee6992)\
**Post date:** [May 4, 2015, 10:50pm UTC](https://community.particle.io/t/help-with-ifttt/11619/3 "2015-05-04T22:50:52Z")

</div>

> [@bko](#):
>
> [http://docs.spark.io/firmware/#spark-variable](http://docs.spark.io/firmware/#spark-variable)

thank you, not sure how i missed that, as i read that a few times. Thank you very much. Am i missing something to getting my variable to register so it appears on the IFTTT drop down menu??

---

<div class="post-metadata">

**Author:** ![danlee6992](https://avatars.discourse-cdn.com/v4/letter/d/c4cdca/32.png) [@danlee6992](https://community.particle.io/u/danlee6992)\
**Post date:** [May 4, 2015, 10:53pm UTC](https://community.particle.io/t/help-with-ifttt/11619/4 "2015-05-04T22:53:19Z")

</div>

> [@bko](#):
>
> [http://docs.spark.io/firmware/#spark-variable](http://docs.spark.io/firmware/#spark-variable)

nevermind, just had to flash it again.

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [May 4, 2015, 10:53pm UTC](https://community.particle.io/t/help-with-ifttt/11619/5 "2015-05-04T22:53:40Z")

</div>

Might be more of a logical error; I’m going to assume you’re using IFTTT to check whether or not there has been motion(?).  
You’re currently having the variable set to `motion = D2`, which will never change. The thing that _does_ change is `val = digitalRead(motion);`, which is what you’re measuring. You might want to use that instead.  
Also, I’m going to assume you’re using some sort of PIR sensor to check for motion. Those things stay HIGH for 10-15s. The problem with using IFTTT with variables is the fact that it’s a polling process. Every so often, IFTTT checks your variable to see if it matches any of the set criteria. Unfortunately, this “every so often” can be a couple of minutes. Seeing as your sensor (probably) only stays HIGH for a fraction of that time, you’re likely to miss events.  
Speaking of events, why don’t you try out the Server Sent Events (SSE), which are perfect for these scenarios? You don’t have to poll for data, and you don’t even have to loop the `digitalRead()`. You can use an Interrupt to trigger a SSE, which in turn triggers an action on IFTTT. Not only is this much cleaner, it should also be much faster 😃
