If you have a widget in the app or desktop dashboard that triggers the webhook then you don’t need any hardware.
Pete.
If you have a widget in the app or desktop dashboard that triggers the webhook then you don’t need any hardware.
Pete.
Here is my code. I would like to use a ultrasonic sensor to trigger the IFTTT through Blynk. However, it keep pinging the blynk server on the serial monitor
#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 "BlynkSimpleShieldEsp8266.h"
#include "ESP8266_Lib.h"
#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3);
// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
char ssid[] = "";
char pass[] = "";
char auth[] = BLYNK_AUTH_TOKEN;
BlynkTimer timer;
#define echoPin 12// attach pin D2 Arduino to pin Echo of HC-SR04
#define trigPin 13//attach pin D3 Arduino to pin Trig of HC-SR04
long duration; // variable for the duration of sound wave travel
int distance; // variable for the distance measurement
void sendSensor()
{
// Clears the trigPin condition
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
//Sets the trigPin HIGH (ACTIVE) for 10 microseconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
//Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
if(distance > 50){
Blynk.virtualWrite(V4, "https://maker.ifttt.com/trigger/email/with/key/o7u_O_jkLbr3-");
}
}
void setup() {
// Debug console
Serial.begin(9600);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT
pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
Blynk.virtualWrite(V4, "https://maker.ifttt.com/trigger/email/with/key/o7u_O_jkLbr5U-");
timer.setInterval(10000L, sendSensor);
}
void loop() {
Blynk.run();
timer.run();
}
this is what happening on serial moniter
12:18:41.576 -> [72968] Ready (ping: 23ms).
12:19:17.212 -> [108628] Ready (ping: 28ms).
12:19:52.888 -> [144306] Ready (ping: 24ms).
12:20:28.453 -> [179881] Ready (ping: 24ms).
12:21:04.034 -> [215424] Ready (ping: 25ms).
12:21:39.556 -> [250980] Ready (ping: 25ms).
12:22:15.113 -> [286529] Ready (ping: 25ms).
12:22:50.668 -> [322079] Ready (ping: 24ms).
12:23:26.242 -> [357638] Ready (ping: 24ms).
You’re not doing it the right way, your sketch just write data to virtual pin 4.
You can trigger IFTTT applet using email by sending a tagged email to “trigger@applet.ifttt.com”
I am not sure what you are talking, but this is what webhook widget works in Blynk(I guess). This is my original code. and it can work fine. However when I changed to the upper one, it just keep pinging with sending any webhook.
#define BLYNK_TEMPLATE_ID "T"
#define BLYNK_DEVICE_NAME "Wk"
#define BLYNK_AUTH_TOKEN "p"
// 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[] = "GO";
char pass[] = "2";
// 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 9600
#define echoPin 12 // attach pin D2 Arduino to pin Echo of HC-SR04
#define trigPin 13 //attach pin D3 Arduino to pin Trig of HC-SR04
// defines variables
long duration; // variable for the duration of sound wave travel
int distance; // variable for the distance measurement
BlynkTimer timer;
ESP8266 wifi(&EspSerial);
void sendSensor()
{
// Clears the trigPin condition
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin HIGH (ACTIVE) for 10 microseconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance = duration * 0.034 / 2; // Speed of sound wave divided by 2 (go and back)
// Displays the distance on the Serial Monitor
Serial.println("Distance: ");
Serial.println(distance);
if(distance>50)
{
Blynk.virtualWrite(V4, "https://maker.ifttt.com/trigger/email/with/key/o7-");
Serial.println("fire");
}
}
void setup()
{
// Debug console
Serial.begin(9600);
pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT
pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
// 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/o7u_OB3-");
timer.setInterval(10000L, sendSensor);
}
void loop()
{
Blynk.run();
timer.run();
}
Show me how did you configure ifttt please
what do u mean about this??
A screenshot
this??
from Dmitriy, it said it can be trigger through this code. and I do can unless i changed those order.
Right, you’re using the new webhook service, I forgot that, sorry.
Now your problem is only the ping right?
i hope yes
and for now yes
i dont think 2 code got that much difference but it gave me different result on serial monitor…
The only difference in your both sketches is Serial.printIn(“fire”), have you tried the sketch without it ?
that line is there because I wanna know is the blynk vitural write (Webhook) is compiled or not. I removed that but it still can be run normally.
It keep ping the server and the blynk server is keeping online and offline
My guess is that you have a power supply issue, or an intermittent connection between your Uno and your ESP-01.
Are you using a breadboard for any of this hardware? They are notorious for having high resistance connections.
In addition, there are some issues with your sketch.
You don’t seem to have understood / taken on board the comments I made earlier about how the Blynk webhook is triggered.
You are doing this:
and this:
when in reality, writing ANYTHING to V4 will trigger the webhook.
If you’re still using the toggle feature of a Philips Hue bulb then it will all work fine until your bulb gets out of sequence with the commands being sent to it. Then, it will turn off when you want it on, and on when you want it off.
It would be gar better if you sent an explicit value, such as 1 for on and 0 for off to pin V4.
You could then configure your Blynk webhook to use these values in the command it sends to IFTTT and configure your IFTTT recipe so that an incoming 1 turns the light on and a 0 turns it off.
In addition, the Blynk webhook is limited to 1 webhook call per minute, yet you are polling your distance sensor once every 10 seconds with no method of limiting the rate at which data writes to V4 are occurring.
This will mean that many of the webhook calls will be ignored, which will inevitably lead to the out of sequence toggling that I mentioned earlier.
Is this project designed to measure water levels, and trigger the light as an alert if the level gets too high or low?
Or, is it meant to be a way to turn a light on when an object is detected, like a PIR sensor?
Pete.
I tried to compile a code like that
#define BLYNK_TEMPLATE_ID "Tc"
#define BLYNK_DEVICE_NAME "Io\n"
#define BLYNK_AUTH_TOKEN "nfx"
// 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[] = "GO";
char pass[] = "2992";
// 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 9600
#define echoPin 12 // attach pin D2 Arduino to pin Echo of HC-SR04
#define trigPin 13 //attach pin D3 Arduino to pin Trig of HC-SR04
// defines variables
long duration; // variable for the duration of sound wave travel
int distance; // variable for the distance measurement
int bigger = 0;
int smaller = 0;
BlynkTimer timer;
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_jkLbr5U5ilQBWo7rvB4zq4KAcYNU-wQb9DB3-");
Serial.println("fire");
}
}*/
void sendSensor()
{
// Clears the trigPin condition
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin HIGH (ACTIVE) for 10 microseconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance = duration * 0.034 / 2; // Speed of sound wave divided by 2 (go and back)
// Displays the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);
if (distance > 50) {
bigger = bigger + 1;
Serial.print("bigger:");
Serial.println(bigger);
Serial.print("smaller:");
Serial.println(smaller);
if (bigger == 1)
{
Blynk.virtualWrite(V4, "https://maker.ifttt.com/trigger/email/with/key/o7u_O_jkLbr5U5ilQBWo7rvB4zq4KAcYNU-wQb9DB3-");
Serial.println("on");
smaller = 0;
}
} else if (distance < 50)
{
smaller = smaller + 1;
Serial.print("bigger:");
Serial.println(bigger);
Serial.print("smaller:");
Serial.println(smaller);
if (smaller == 1)
{
Blynk.virtualWrite(V4, "https://maker.ifttt.com/trigger/email/with/key/o7u_O_jkLbr5U5ilQBWo7rvB4zq4KAcYNU-wQb9DB3-");
Serial.println("off");
bigger = 0;
}
}
}
void setup()
{
// Debug console
Serial.begin(9600);
pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT
pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
// 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/o7u_O_jkLbr5U5ilQBWo7rvB4zq4KAcYNU-wQb9DB3-");
timer.setInterval(65000L, sendSensor); //10000L = 10s, 65000L = 65s, Blynk Webhook can only send once in 60s
// 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();
timer.run();
}
However it keep disconnecting, online and offline on blynk server
Also, when I changed the virtual write to sth like this, the connection become unstable, keep pinging the blhnk server
Blynk.virtualWrite(V4,1);