# IFTTT and Photon variable posting too often

**URL:** <https://community.particle.io/t/ifttt-and-photon-variable-posting-too-often/23377>\
**Category:** Integrations\
**Created:** [June 1, 2016, 5:19pm UTC](https://community.particle.io/t/ifttt-and-photon-variable-posting-too-often/23377 "2016-06-01T17:19:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaboersma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/jaboersma/32/8197_2.png) [@jaboersma](https://community.particle.io/u/jaboersma)\
**Post date:** [June 1, 2016, 5:19pm UTC](https://community.particle.io/t/ifttt-and-photon-variable-posting-too-often/23377/1 "2016-06-01T17:19:09Z")

</div>

Hello,  
I have created a project that monitors 3 variables and publishes them to a spreadsheet. My problem is that it is posting more than I need. I was thinking that instead of monitoring a variable I could monitor a function that uses those variables and I could use delay to set the interval for the function being called but I am at a loss as how to set up the function.  
The variables are light, temperature, and humidity using a photocell and a DHT11.  
Any thoughts?  
Thank you

---

<div class="post-metadata">

**Author:** ![nrobinson2000](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/nrobinson2000/32/15624_2.png) [@nrobinson2000](https://community.particle.io/u/nrobinson2000)\
**Post date:** [June 1, 2016, 5:38pm UTC](https://community.particle.io/t/ifttt-and-photon-variable-posting-too-often/23377/2 "2016-06-01T17:38:52Z")

</div>

Hi @jaboersma,  
How are you calling the Particle Cloud functions? What kind of spreadsheet are you using? What programming language are you using? You could make a function on the Particle that returns the three variables together and parse it in your project code.

The function could look like this:

```cpp
String sendVariables(String command)
{
String message = String(String(lightVariable) + " " + String(temperatureVariable) + " " + String(humidityVariable));
return message;
}

```

With:

```auto
Particle.function("getVariables", sendVariables);

```

In `setup()`.

Whenever `getVariables` would be called, you would get a string of three numbers in a row separated by spaces. For example: `123 456 789` . Then, whatever programming language you are using in your project could then break up the string again into three substrings and put them into a spreadsheet.

---

<div class="post-metadata">

**Author:** ![jaboersma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/jaboersma/32/8197_2.png) [@jaboersma](https://community.particle.io/u/jaboersma)\
**Post date:** [June 1, 2016, 5:55pm UTC](https://community.particle.io/t/ifttt-and-photon-variable-posting-too-often/23377/3 "2016-06-01T17:55:15Z")

</div>

Hello,  
In setup() I have the following code

```
Particle.variable("humidity", &humidity, INT);
Particle.variable("temperature", &temperature, INT);
Particle.variable("light", &light, DOUBLE);

```

And I’m just using [build.io](http://build.io) and IFTTT. The spreadsheet is a google spreadsheet. I tried adding a delay in the loop code but IFTTT seems to ignore that and just calls the variables when it wants which would still have the former values in them.  
The function I thought I control better and it looks like I can use what you sent me.  
Thank you.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [June 1, 2016, 5:57pm UTC](https://community.particle.io/t/ifttt-and-photon-variable-posting-too-often/23377/4 "2016-06-01T17:57:46Z")

</div>

> [@jaboersma](#):
>
> My problem is that it is posting more than I need

What do you mean by that? _You_ have full control over amount of data and the frequency of your publishes.

How does your publishing code look at the moment?

_Update:_  
_**`Particle.variable()`s are not pushed/published to IFTTT but requested by IFTTT.**_  
Reducing the frequency in which IFTTT requests the variables can only be controlled on the IFTTT side.  
You might want to look into `Particle.publish()`. There _you_ have full control over update frequency.

* * *

That code would need some adaption:  
`Particle.function()` callbacks need to be `int fnName(String)`, you can't have a function that returns a `String`.  
I'd also avoid using `String` that extensive and not as return value either.

Even with `String` I'd rater do this

```cpp
int sendVariables(String dmy)
{
  // assuming your variables are all floats
  String message = String::format("%.1f %.1f %.1f", lightVariable, temperatureVariable, humidityVariable);
  // do something with this String
  return message.length();
}

```

and without `String`

```cpp
char message[64]; // global variable
int sendVariables(String dmy)
{
  // assuming your variables are all floats
  return snprintf(message, sizeof(message-1), "%.1f %.1f %.1f", lightVariable, temperatureVariable, humidityVariable);
}

```

---

<div class="post-metadata">

**Author:** ![nrobinson2000](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/nrobinson2000/32/15624_2.png) [@nrobinson2000](https://community.particle.io/u/nrobinson2000)\
**Post date:** [June 1, 2016, 6:00pm UTC](https://community.particle.io/t/ifttt-and-photon-variable-posting-too-often/23377/5 "2016-06-01T18:00:41Z")

</div>

Oh right. I forgot it had to be an `int` 😉
