Ifttt and Google assistant botton push

#define BLYNK_PRINT Serial
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
SimpleTimer timer;

char auth[] = "xxxxxxxxxxxxxxxxxxx";
 
char ssid[] = "xxxxxxxxxxxxx";
char pass[] = "xxxxxxxxxxxx";
 
void setup() {
  Serial.begin(115200);


  pinMode(4, OUTPUT); //D2 is GPIO 4 (POMPA ANTICONDENZA IN4) (RELAY SWITCH)
  digitalWrite(4, HIGH); // Set GPIO 4 HIGH

  
  pinMode(13, OUTPUT); //D7 is GPIO 13 (Cancello Grande RELE IN1)(RELAY BUTTON)
  digitalWrite(13, HIGH); // Set GPIO 13 HIGH
  timer.setTimeout(500L, []() {  // Run after 0.5 seconds second
    digitalWrite(13, HIGH);  // Set  Pin 13 HIGH
  });  // END Timer Function

  pinMode(14, OUTPUT); //D5 is GPIO 14 (Cancello Piccolo RELE IN2)(RELAY BUTTON)
  digitalWrite(14, HIGH); //Set GPIO 14 HIGH
  timer.setTimeout(500L, []() {  // Run after 0.5 seconds second
    digitalWrite(14, HIGH);  // Set  Pin 14 HIGH
  });  // END Timer Function
  
  pinMode(5, OUTPUT); //D1 is GPIO 5 (Relay ACS RELE IN3)(RELAY BUTTON)
  digitalWrite(5, HIGH); //Set GPIO 5 HIGH
  timer.setTimeout(500L, []() {  // Run after 0.5 seconds second
    digitalWrite(5, HIGH);  // Set  Pin 5 HIGH
  });  // END Timer Function

  
 Blynk.begin(auth, ssid, pass);
  
}
 
void loop() {
  Blynk.run();
}

this is the code all buttons only the relay 4 is a switch.

Can it work like this?

It does not work, where am I wrong?

You have all of your code in your setup. You will need to utilize BLYNK_WRITE(Vpin) and use virtual pins. In the IFTTT applet you will need to manipulate the virtual pin.

Here is an example, it should be placed before/outside of your setup(). You will need one of these for each relay/pin. Assuming relays are active HIGH
Use this URL in the applet (with your token inserted): http://blynk-cloud.com/auth_token/update/V0?value=1

BLYNK_WRITE(V0)
{   
  int value = param.asInt(); // Get value as integer
  
  if (value == 1)
  {
     digitalWrite(13, HIGH); // Set GPIO 13 HIGH
     timer.setTimeout(500L, []() {  // Run after 0.5 seconds second
          digitalWrite(13, LOW);  // Set  Pin 13 LOW
           });  // END Timer Function

}
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
SimpleTimer timer;

char auth[] = "XXXXXXXXXXXXXXXXX"; //nodemcu test
 
char ssid[] = "XXXXXXXX";
char pass[] = "XXXXXXXXXXX";

BLYNK_WRITE(V0)
{   
  int value = param.asInt(); // Get value as integer
  
  if (value == 1)
  {
     digitalWrite(13, HIGH); // Set GPIO 13 HIGH
     timer.setTimeout(500L, []() {  // Run after 0.5 seconds second
          digitalWrite(13, LOW);  // Set  Pin 13 LOW
           });  // END Timer Function

}
}

BLYNK_WRITE(V1)
{   
  int value = param.asInt(); // Get value as integer
  
  if (value == 1)
  {
     digitalWrite(14, HIGH); // Set GPIO 13 HIGH
     timer.setTimeout(500L, []() {  // Run after 0.5 seconds second
          digitalWrite(14, LOW);  // Set  Pin 13 LOW
           });  // END Timer Function

}
}

BLYNK_WRITE(V2)
{   
  int value = param.asInt(); // Get value as integer
  
  if (value == 1)
  {
     digitalWrite(5, HIGH); // Set GPIO 13 HIGH
     timer.setTimeout(500L, []() {  // Run after 0.5 seconds second
          digitalWrite(5, LOW);  // Set  Pin 13 LOW
           });  // END Timer Function

}
}


void setup() {
  Serial.begin(115200);


  pinMode(4, OUTPUT); //D2 is GPIO 4 (POMPA ANTICONDENZA IN4) (RELAY SWITCH)
  digitalWrite(4, HIGH); // Set GPIO 4 HIGH

  
  pinMode(13, OUTPUT); //D7 is GPIO 13 (Cancello Grande RELE IN1)(RELAY BUTTON)
  digitalWrite(13, HIGH); // Set GPIO 13 HIGH
  
  pinMode(14, OUTPUT); //D5 is GPIO 14 (Cancello Piccolo RELE IN2)(RELAY BUTTON)
  digitalWrite(14, HIGH); //Set GPIO 14 HIGH
 
  
  pinMode(5, OUTPUT); //D1 is GPIO 5 (Relay ACS RELE IN3)(RELAY BUTTON)
  digitalWrite(5, HIGH); //Set GPIO 5 HIGH
  

  
 Blynk.begin(auth, ssid, pass);
  

} 
void loop() {
  Blynk.run();
}

I hope I have understood and written correctly?

For the speech, HIGH or LOW I to “standby” I have to put HIGH otherwise I will start the relay alone

1 Like

seems correct. Although I am a little confused by your last statement.

Are you relays active LOW or active HIGH?

As you set them HIGH in the setup it makes me think they are active LOW. If they are active LOW, you will need to change the logic around in the BLYNK_WRITE functions.

Example:

BLYNK_WRITE(V0)
{   
  int value = param.asInt(); // Get value as integer
  
  if (value == 1)
  {
     digitalWrite(13, LOW); // Set GPIO 13 LOW
     timer.setTimeout(500L, []() {  // Run after 0.5 seconds second
          digitalWrite(13, HIGH);  // Set  Pin 13 HIGH
           });  // END Timer Function

}
}

does not work,
the ifttt parameters are as follows

Make a web request
http://139.59.206.133/xxxxxxxxxxxxxxx/update/V0?value=1

Method
PUT

Content Type (optional)
application / json

for the HIGH or LOW speech
if I put in the LOW setup the relays start when I give the power to the circuit while if I put HIGH the relays start on command

Well seems like you got it from here. Happy BLYNKing!!

I do not understand what you mean

You have the IFTTT stuff, and the code for your hardware. Was there something else giving you trouble, or is it still not working correctly.

If still not working, post latest code and describe your issue.

Actually, it looks as if I missed something. See below, make sure all of the BLYNK_WRITE functions get this update. Again Assuming relays are active LOW

BLYNK_WRITE(V0)
{   
  int value = param.asInt(); // Get value as integer
  
  if (value == 1)
  {
     digitalWrite(13, LOW); // Set GPIO 13 LOW
     timer.setTimeout(500L, []() {  // Run after 0.5 seconds second
          digitalWrite(13, HIGH);  // Set  Pin 13 HIGH
          Blynk.virtualWrite(V0, LOW);// Set  Virtual Pin 0 LOW
           });  // END Timer Function

}
}
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
SimpleTimer timer;

char auth[] = "bca78xxxxx"; //nodemcu test
 
char ssid[] = "xxxxx";
char pass[] = "xxxxx";

BLYNK_WRITE(V0)
{   
  int value = param.asInt(); // Get value as integer
  
  if (value == 1)
  {
     digitalWrite(13, LOW); // Set GPIO 13 HIGH
     timer.setTimeout(500L, []() {  // Run after 0.5 seconds second
          digitalWrite(13, HIGH);  // Set  Pin 13 LOW
          Blynk.virtualWrite(V0, LOW);// Set  Virtual Pin 0 LOW
           });  // END Timer Function

}
}

BLYNK_WRITE(V1)
{   
  int value = param.asInt(); // Get value as integer
  
  if (value == 1)
  {
     digitalWrite(14, HIGH); // Set GPIO 13 HIGH
     timer.setTimeout(500L, []() {  // Run after 0.5 seconds second
          digitalWrite(14, LOW);  // Set  Pin 13 LOW
           });  // END Timer Function

}
}

BLYNK_WRITE(V2)
{   
  int value = param.asInt(); // Get value as integer
  
  if (value == 1)
  {
     digitalWrite(5, HIGH); // Set GPIO 13 HIGH
     timer.setTimeout(500L, []() {  // Run after 0.5 seconds second
          digitalWrite(5, LOW);  // Set  Pin 13 LOW
           });  // END Timer Function

}
}


void setup() {
  Serial.begin(115200);


  pinMode(4, OUTPUT); //D2 is GPIO 4 (POMPA ANTICONDENZA IN4) (RELAY SWITCH)
  digitalWrite(4, HIGH); // Set GPIO 4 HIGH

  
  pinMode(13, OUTPUT); //D7 is GPIO 13 (Cancello Grande RELE IN1)(RELAY BUTTON)
  digitalWrite(13, HIGH); // Set GPIO 13 HIGH
  
  pinMode(14, OUTPUT); //D5 is GPIO 14 (Cancello Piccolo RELE IN2)(RELAY BUTTON)
  digitalWrite(14, HIGH); //Set GPIO 14 HIGH
 
  
  pinMode(5, OUTPUT); //D1 is GPIO 5 (Relay ACS RELE IN3)(RELAY BUTTON)
  digitalWrite(5, HIGH); //Set GPIO 5 HIGH
  

  
 Blynk.begin(auth, ssid, pass);
  

} 
void loop() {
  Blynk.run();
}

this is the last code I wrote in practice with ifttt does not work. if you have already done so you can indicate the values of ifttt so I will verify them at least that we put them safe

PS. I focused only on the V0 then fix the others

I use http://blynk-cloud.com/auth_token/update/V0?value=1 for my IFTTT applet

you can make a screen

method: PUT???

ok I understand, where’s the problem. then if I send the web request “1” on the V0 the relay stays on but does not return to the rest position after 0.5 seconds

You don’t have timer.run(); in your loop… you need it in order for any timers to work :wink:

2 Likes

great works … thanks thanks thanks

void loop () {

timer.run ();

Blynk.run ();
}

1 Like

Thanks for the catch @Gunner. Totally overlooked that.
@eddie for method I use get

now I have to enable OTA updates.

Tomorrow I will do it

THANKS to everyone for the time you have dedicated to me

I have been tricked, tricked I say, three times by forgetting that… tricked…

The post can be closed. Thank you