It is the ONLY solution discussed here, and suggested by the limited number of people responding to this post. To say it is the ONLY solution may be a bit of an assumption. What have you discovered in your research from when you opened this topic approx. 8 days ago? Or were you just waiting for someone to find it for you?
What is presented above is how I do it, and the ONLY way I have seen. I would suspect that there is another way of doing it using the Google Assistant Tools, but from the little I have looked into that, it looks a lot more complicated than a few lines of code.
Honestly, I have not had the chance to rehearse. I was looking for a different solution than the code because where the device is located is inconvenient to work on it. If this is the only road I’ll try it even if I was hoping for something simpler. My question is this once I put this function will remain that even if I use the app or switch button. Quite right?
As I mentioned, this is the only solution the I know of. It is very possible that there are other ways of doing it.
One plus to pulling the board out and updating the code is that you can now also add OTA updating. OTA This will make future improvements to your device so much easier.
As to if the function will remain the same, I do not know as, I do not know how your current code functions. If you would like to post your code (properly formatted that is), I may be able to look it over and see what the effect may be.
Awesome, good to know. I was going off the opening statement for OTA from the DOCS : OTA DOCS
Blynk also supports over the air updates for - ESP8266, NodeMCU and SparkFun Blynk boards. OTA supported only for the private servers and for the paid customers for now.
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