I really wish it was so easy GTT.
When i add that function, nothing happend. The button works , but no feedback when i remove power from Relay or my Wemos D1 Mini.
Btw. in serial print i only get “0” state all the time when i tries to read the coffee switch.
Here is the code i tried:
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
//Put WiFi cridentials and token here----------------------------------
char auth[] = "****";
char ssid[] = "****";
char pass[] = "****";
//---------------------------------------------------------------------
int coffeeSwitch = 5;
BlynkTimer timer;
void setup() {
Blynk.begin(auth, ssid, pass);
Serial.begin(9600);
digitalWrite(coffeeSwitch, HIGH);
pinMode(coffeeSwitch, OUTPUT);
timer.setInterval(1000L, buttonUpdate);
}
void buttonUpdate() {
Blynk.virtualWrite(V1, digitalRead(coffeeSwitch));
Serial.print(digitalRead(coffeeSwitch));
}
BLYNK_CONNECTED() {
Blynk.syncAll();
}
BLYNK_WRITE(V1) {
int pinValue = param.asInt();
digitalWrite(coffeeSwitch, pinValue);
}
void loop() {
Blynk.run();
timer.run();
}