Use Ifttt to control the built in led

Correct. However, currently, there is a limit - 1 webhook per pin per device per minute is allowed.

thank you for ur advice. in the setting of webhook. I dont understand the following blocks. What they are doing and what do I need to fill in. How do they affect the result?

Content Type – switch to one of supported webhook request content type:

  • Web Form Fill the corresponding fields. Add as much rows as you need – once a row’s fields are filled the Add row button appears. Hover right to the row to make Delete button visible (at least 2 rows needed for it to appear).

    • Form fields constructor

      • Key – type any meaningful key. 100 characters limit

      • Value – select from the list (manual scroll or quick search by typing)

Moreover, I have set a switch in the blynk platform to control the webhook.
here is my following code.

BLYNK_WRITE(V0)
{
  Serial.println("WebHook data:");
  Serial.println(param.asStr());
  if (param.asStr()== 1)
  {
    Blynk.virtualWrite(V0, "https://maker.ifttt.com/trigger/");
  }
}

v0 is a interger swich. is it able to send the web to it?? or I need to change it??

I’ve not tried using the webhook functionality in Blynk IoT, but it appears to me that you choose which event you want to use to trigger the webhook, and in in your case this would be a change of status of the widget attached to pin V0.
In that situation you wouldn’t need a BLYNK_WRITE(V0) function in your sketch, the webhook will trigger automatically when the widget attached to V0 is toggled.

Presumably, you’ll capture the device_pinValue and pass this to your webhook call in whatever format the API you are calling is expecting - probably JSON.

You’ll need to read the documentation for the receiving API to decide which parameters you need to choose to make the API call in the format that it is expecting.

Pete.

um i am not sure if my understand is right or not. please tell me if i am wrong. When I tried to create a webhook i need to choose device and pin. Therefore i expected that i need to have a switch or any things in order to enable it. let say a switch. so i think i need to have the Blynk_write function as it is a switch??
but after reading yours answer

can i say that i dont need and switch widget on blynk? than how can I trigged it?? and do i need to change v0 to string instead of interger??

You’d have a switch widget attached to V0 and use this to trigger the webhook.

I guess it depends what your API is expecting, but I’d assume that it would be an integer 0=off, 1=on.

We’re all just guessing, without some info about the API that you’re calling.

Pete.

In IFTTT with webhook, what I need to do is get my device reached the webpage that webhook give me then it will trigged the event. This is what i understand. Is there any api hiden behind?

IFTTT is acting as middleware between Blynk and the Phillips Hue API.
You’re calling the IFTTT API from the Blynk webhook.
You should have some documentation from IFTTT that tells you what data, and in which format, IFTTT is expecting.

Pete.

This is what I got from IFTTT webhook. https://help.ifttt.com/hc/en-us/articles/115010230347 I am not sure if it is useful. cause i dont need to send any value at this moment.
It said if i need to

To trigger an Event

Make a POST or GET web request to:

https://maker.ifttt.com/trigger//with/key/auth_key

I would have expected that you do need to pass a value, to tell the lightbulb to turn on or off.
As I said earlier, this value would come from the switch widget…

Pete.

I have to say that if Blynk keep the limit of one webhook call per minute then it’s usefulness as a way to control things like Phillips Hue lightbulbs is very limited, especially if you also want to use a slider to control brightness or colour.
In that case you’d be better making an API call directly from your sketch, but you’d need to use an ESP8266 or ESP32 for this, rather than an Arduino + ESP-01 combination.

Pete.

The way that IFTTT work is i set a if then statement in IFTTT. In my project, I have set if i receive a webhook, then toggle the philips light bulb on off only.(not the brightness or any other for now). And this work when i post the link that IFTTT gave me on a browser. Light bulb can be toggle. Therefore, i believe I just need to make blynk open the link when i use the switch on with the webhook widget? (I want a button more actually, but seems Blynk get switch only.)

Here is my updated code which work in IFTTT now.

#define BLYNK_TEMPLATE_ID ""
#define BLYNK_DEVICE_NAME ""
#define BLYNK_AUTH_TOKEN ""


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial
// Allow for receiving messages up to 512 bytes long
#define BLYNK_MAX_READBYTES 512

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";

// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1

// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200

ESP8266 wifi(&EspSerial);

void setup()
{
  // Debug console
  Serial.begin(115200);

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, wifi, ssid, pass, "blynk.cloud", 80);
  //Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8080);

  Blynk.virtualWrite(V4, "https://maker.ifttt.com/trigger/email/with/key/");

  // You can perform HTTPS requests even if your hardware alone can't handle SSL
  // Blynk  can also fetch much bigger messages,
  // if hardware has enough RAM (set BLYNK_MAX_READBYTES to 4096)
  //Blynk.virtualWrite(V0, "https://api.sunrise-sunset.org/json?lat=50.4495484&lng=30.5253873&date=2016-10-01");
}

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

This can triggle the IFTTT once I upload and run the program in the first time
Now, I would like to use a switch to control it. can i do sth like this?

BLYNK_WRITE(V0)
{
  Serial.println("WebHook data:");
  Serial.println(param.asInt());
  if (param.asInt()== 1)
  {
    Blynk.virtualWrite(V4, "https://maker.ifttt.com/trigger/email/with/key/");
    Serial.println("fire");
  }
}

I tried this but it seems i cannot connect the light bulb and cannot even display those serial println on IDE. That is strange. Am I missing sth?

How is your V0 datastream set-up, and how is your switch widget attached to V0 configured?

Pete.

This is my datastream setup for v0


and here is the widget setting.

Are you saying that this line of code is not being executed…

Where within your sketch have you placed the BLYNK_WRITE(V0) function?

Pete.

let me sent you the whole code now.

#define BLYNK_TEMPLATE_ID "TM"
#define BLYNK_DEVICE_NAME "Wk"
#define BLYNK_AUTH_TOKEN "pGXF4D8nCy"


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial
// Allow for receiving messages up to 512 bytes long
#define BLYNK_MAX_READBYTES 512

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "O";
char pass[] = "2";


// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200

ESP8266 wifi(&EspSerial);

BLYNK_WRITE(V0)
{
  Serial.println("WebHook data:");
  Serial.println(param.asInt());
  if (param.asInt()== 1)
  {
    Blynk.virtualWrite(V4, "https://maker.ifttt.com/trigger/email/with/key/o7u_O_jkb9DB3-");
    Serial.println("fire");
  }
}

void setup()
{
  // Debug console
  Serial.begin(115200);

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);


  Blynk.virtualWrite(V4, "https://maker.ifttt.com/trigger/email/with/key/o7u_O_jkLbr5U5wQb9DB3-");
}

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

when I try to use the switch, sometime it will send me back something like this on the serial moniter.

15:45:53.305 -> [505234] Ready (ping: 11ms).
15:46:05.021 -> [505234] Ready (ping: 13ms).

If you’re using an Arduino Uno then it doesn’t have the processor speed to reliably emulate a serial port at anything faster than 9600.

You need to reconfigure your ESP-01 to communicate at 9600 (using an AT command) and change your c as sketch to use the same baud rate.

Pete.

well after changing to 9600, it seems it runs more smoothly now. Thank you for ur help.

It depends how you’ve configured your webhook, but I do t think that it’s actually necessary to send the url to the webhook. Anything sent to V4 should trigger the webhook, assuming that you’ve placed the url inside the webhook configuration.
Try this and see if it works.

I’ve said before that I don’t think you need any code to trigger the webhook. Simply attaching a switch widget directly to the webhook pin (V4) should trigger it, so if it works this way then your Arduino hardware is actually redundant.

Pete.

What do you mean by the Arduino hardware is redundant?? If the device is not online. How can the switch work?