So like many I am new to using blynk and the NodeMCU. I have been trying to use this like some as a garage door opener. I have looked at many tutorials and for the life of my I can not get it to work.
Using Blynk by itself works fine. I can press the buttons i made and it will turn on my relay. It is getting the relay to me momentary that is the problem for me. I see references to how the webhook are set up but no clear answer as i see it and that may just be my misunderstanding of it. Here is the code that i have found all over the place that I’m trying to use with no joy. I know I have to be missing something. Also included a pic of the webhook.
Using a NodeMCU V2.4.1
Relay connected to labeled pin D3
Any help would be greatly apritiated
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
SimpleTimer timer;
///////////////////////////////////////////////////////////
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "8XXXXXXXXXX2";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "XXXXXXXXXX";
char pass[] = "XXXXXXXXX";
/////////////////////////////////////////////////////////////
int outputPin = D3;
int inputPin = V1;
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
}
//pasted code starts here
BLYNK_WRITE(V1) {
if (param.asInt()==1){ // act only on the HIGH and not the LOW of the momentary
digitalWrite(D3, !digitalRead(D3)); // invert pin state just once
timer.setTimeout(200L, [](){
delay(200);
digitalWrite(D3, !digitalRead(D3)); // then invert it back after 1000ms
Blynk.virtualWrite(V1, LOW);
});
}}
//pasted code ends here
void loop()
{
Blynk.run();
timer.run(); // missing this very important line to make the timer work
}