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
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
}
}
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
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
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