IFTTT and Photon variable posting too often

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

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:

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

With:

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.

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 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.

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

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

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);
}

Oh right. I forgot it had to be an int :wink: