I get an error when I try and call a function from the console.particle.io that says Bummer! failed to call aerator. The function is called aerator and has some code with delays and switching pins on and off etc for automating a pool valve. The relays click on and off as they are supposed to but it sends the failed message. If I remove the bulk of the code inside the function and just have the return part it succesfully calls and returns a one or a zero. Is there a way to keep this from I’m assuming timeing out? Perhaps by sending the response and then continuing the code? Cause in its current state its screwing up the status of the switch in my smartthings home automation since it thinks that it failed.
Spark.function("aerator", aeratorfunc);
}
//
// runs based upon cloud input
//
int aeratorfunc(String command)
{
// clockwise valve aerator on relay
if (command == "1")
{
digitalWrite(aeratoroffrelay, HIGH); // first make sure the reverse direction re;ay is set to off
delay(2000); // wait for motor to spool down before in case its reversing direction
digitalWrite(aeratoronrelay, LOW); // activate the relay
delay(20000); // wait amount of time then turn the relay off
digitalWrite(aeratoronrelay, HIGH);
return 1;
}
// counterclosckwise valve aerator off relay
else
{
digitalWrite(aeratoronrelay, HIGH); // first make sure the reverse direction re;ay is set to off
delay(2000); // wait for motor to spool down before in case its reversing direction
digitalWrite(aeratoroffrelay, LOW); // activate the relay
delay(20000); // wait amount of time then turn the relay off
digitalWrite(aeratoroffrelay, HIGH);
return 0;
}
}
if I do this I get a successful return
Spark.function("aerator", aeratorfunc);
}
//
// runs based upon cloud input
//
int aeratorfunc(String command)
{
// clockwise valve aerator on relay
if (command == "1")
{
return 1;
}
// counterclosckwise valve aerator off relay
else
{
return 0;
}