I didn’t have to reflash mine. It was a working and installed. I wanted to use Alexa to call a existing function, which had always worked from a web interface and Postman. IFTTT said they were aware of the issue and it must be fixed, because since my last post I’ve been able to use the Alexa command and see my functions.
I had the exact same problem when trying to configure one of my existing buttons and it keeps coming back.
However, the simple fix was to start creating a new particle trigger. I selected Monitor a function result and ifttt correctly presented the functions available. I then cancelled the new trigger and I could then update the buttons correctly.
Cheers,
Hey All - I am new to particle.io and new to coding.
I have a particle photon and connected it to my garage doors through a 2 channel relay in order to control my garage from my phone. I got that working fine.
I’d like to also set up ifttt to work with google home and open my garage as well.
I found a small tutorial on how to do this and i ran into the same issue that other folks seem to have having. When i setup the ‘that’ part of the recipe, I add in my particle channel and select to call a function and when i do that, it says “Options unavailable”.
I think it might be something I need to do with the code. Perhaps I need to declare a function? I’m not exactly sure.
#include <blynk.h>
// This is my auth token, this gets generated when you create a project in blynk and get the auth emailed to you
char auth[] = "my auth code";
void CloseGarage() {
// turn on leds
digitalWrite(D0, HIGH); // etc..
}
void setup()
{
Serial.begin(9600);
Blynk.begin(auth);
pinMode(D0, OUTPUT);
pinMode(D3, OUTPUT);
}
void loop()
{
Blynk.run();
}
Any help would be appreciated.
To call a Particle function you need to declare and register one
https://docs.particle.io/reference/firmware/photon/#particle-function-
There also is a section about calling Particle functions via IFTTT in the tutorial
https://docs.particle.io/guide/tools-and-features/ifttt/#monitor-a-function-result
Thanks, that was helpful. I was able to get the function listed within ifttt. I pass “OpenGarage” back after I say a phrase. The problem at this point is I don’t think the code knows what to do when I send it the opengarage argument. I think I have to somehow trigger the pinMode change. Do I need to describe OpenGarage in setup as triggering D0 or D1 pins?
Here is what I have right now.
#include <blynk.h>
// This is my auth token, this gets generated when you create a project in blynk and get the auth emailed to you
char auth[] = "auth";
int OpenGarage (String command);
void setup()
{
Particle.function("OpenGarage", OpenGarage);
Serial.begin(9600);
Blynk.begin(auth);
pinMode(D0, OUTPUT);
pinMode(D3, OUTPUT);
}
void loop()
{
Blynk.run();
}
int OpenGarage(String command)
{
if(command == "OpenGarage")
{
return 1;
}
else return -1;
}
I am a newbie and haven’t coded anything since cobol in 1998. Thanks for the patience.
Try this
int OpenGarage(String command)
{
if(command == "OpenGarage")
{
digitalWrite(D0, HIGH);
return 1;
}
else
{
digitalWrite(D0, LOW);
return 0;
}
// never end here
return -1;
}
Reading the docs never hurts
https://docs.particle.io/reference/firmware/photon/#digitalwrite-
That did it. It works beautifully.
Next up, I need to setup another function that brings D3 to perform a digital write.
I think I can do that. The documentation only helps if you know what you are looking for, I had no idea how to do this. Thank you ScruffR! <3
Ok, I assumed this would work pretty easily. It did not
#include <blynk.h>
// This is my auth token, this gets generated when you create a project in blynk and get the auth emailed to you
char auth[] = "auth";
int OpenGarage (String command);
int OpenGarage2 (String command);
void setup()
{
Particle.function("OpenGarage", OpenGarage);
Particle.function("OpenGarage2", OpenGarage2);
Serial.begin(9600);
Blynk.begin(auth);
pinMode(D0, OUTPUT);
pinMode(D3, OUTPUT);
}
void loop()
{
Blynk.run();
}
int OpenGarage(String command)
{
if(command == "OpenGarage")
{
digitalWrite(D0, HIGH);
return 1;
}
else
{
digitalWrite(D0, LOW);
return 0;
}
// never end here
return -1;
}
int OpenGarage2(String command)
{
if(command == "OpenGarage2")
{
digitalWrite(D3, HIGH);
return 1;
}
else
{
digitalWrite(D3, LOW);
return 0;
}
// never end here
return -1;
}
What am I doing wrong here. I know that I’m missing some fundamentals, but this seems like it would work. I created a new Ifttt recipe and passed the OpenGarage2 statement. Well, I broke it all with the new code. Everything compiled fine : /
It look like the function continues to do D0, High and doesn’t stop. Is there a way to do D0, high for a certain period of time. Maybe 3 seconds? Whats happening now is that I can’t shut the garage from the garage door button, i’m thinking that the relay isn’t shutting off.
I got it to work! I put a delay in and then return the digitalwrite to low. Thanks for the help all!
// This #include statement was automatically added by the Particle IDE.
// * I created this for the particle photon
// * to connect photon to blynk and use it to open garage doors on 2 channel relay
// *
// **************************************************************/
#include <blynk.h>
// This is my auth token, this gets generated when you create a project in blynk and get the auth emailed to you
char auth[] = "my auth";
int OpenGarage (String command);
int OpenGarage2 (String command);
void setup()
{
Particle.function("OpenGarage", OpenGarage);
Particle.function("OpenGarage2", OpenGarage2);
Serial.begin(9600);
Blynk.begin(auth);
pinMode(D0, OUTPUT);
pinMode(D3, OUTPUT);
}
void loop()
{
Blynk.run();
}
int OpenGarage(String command)
{
if(command == "OpenGarage")
{
digitalWrite(D0, HIGH);
delay(1000);
digitalWrite(D0, LOW);
return 1;
}
else
{
digitalWrite(D0, LOW);
return 0;
}
// never end here
return -1;
}
int OpenGarage2(String command)
{
if(command == "OpenGarage2")
{
digitalWrite(D3, HIGH);
delay(1000);
digitalWrite(D3, LOW);
return 1;
}
else
{
digitalWrite(D3, LOW);
return 0;
}
return -1;
}