I am setting up my automation system and am looking for a solution as explained below:
I am using IFTTT, with the google assistant as the input and Webhooks as the output. I can sucessfully change the value of pins like that, but what i really need is to send a command to set the pin value to “1” (high), and few miliseconds after set its value to “0” (low). That’s because i am using impulse relays, so if the pin value continues as high, the relay won’t change state when I try to comand it from other sources, like the blynk app it self.
So,
1 - How can I do that in a single web request?
2 - How can I do that for more pins in the same web request?
I would like to thank the Blynk team in advance, the app is simply amazing!
What I really want to do is to simulate a button (push mode) trough the webrequest, like I have on the app.
Maybe its possible to do it straigh like that, instead of making the pin work as a button switch?
I want first to make sure it is possible to do without adding line codes to the nodemcu sketch. Righ now i am using only the Blynk.run(); function and the rest needed for conection.
I checked the Blynk API but couldn’t find out yet if its possible do this.
That “simple” mode get people started, flicking the state of a few pins and blinking some LEDs, etc… But you will need to invest in some coding to really utilise the power of Blynk and things like API, IFTT, Webhooks, etc.
Like quick, timed, pin activation/deactivation pulses
BLYNK_WRITE(Vx) { // when Button Widget or Web API called
if (param.asInt() == 1) {
digitalWrite(6, HIGH);
timer.setTimeout(100L, []() { // reset pin in 100ms
digitalWrite(6, LOW);
});
}
}
I installed the simple timer and made it work flawless. Some minutes ago I had succeeded using a delay funtion (thanks to this topic I found: Virtual pin to control momentary latch relay) and trigging the virtual pin trough webhook to change the state of the digital pin, but now its even better with the timer your time function.
I have some comments about the code though, for whoever needs it in the future:
1 - After setting the digital pin low, it’s better to set the virtual pin low as well.
2 - It’s necessary to add the timer funcion to the void loop to make the timer work.
And you are right about investing in some coding to really utilise the power of Blynk!
...(other libraries)+
#include <SimpleTimer.h>
SimpleTimer timer;
void setup() {
...(other confings) +
pinMode (14, OUTPUT);
}
BLYNK_WRITE(V1) {
if (param.asInt()==1){ // act only on the HIGH and not the LOW of the momentary
digitalWrite(14, !digitalRead(14)); // invert pin state just once
timer.setTimeout(100L, [](){
digitalWrite(14, !digitalRead(14)); // then invert it back after 100ms
Blynk.virtualWrite(V1, LOW);
// });
});
}
}
void loop() {
Blynk.run();
timer.run();
}
Buona sera premetto che non sono in grado di programmazione ma ho usato blynk X fare una domotica casalinga ho lo stesso problema vorrei usare relè come pulsanti mi aiutereste a modificare il programma grazie X farlo funzionare