I am facing same problem.I am using Nodemcu ESP8266 12e.
This my original code
#define BLYNK_PRINT Serial // Comment this out to disable prints and save
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <TimeLib.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxxxxxxxxxxxxx";
// Set your LED and physical button pins here
const int ledPin = 16;
const int btnPin = 5;
SimpleTimer timer;
void checkPhysicalButton();
int ledState = LOW;
int btnState = HIGH;
void sendUptime() {
Blynk.virtualWrite(V20, millis() / 60000);
long rssi = WiFi.RSSI();
Blynk.virtualWrite(V15, rssi);
}
void setup()
{
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
pinMode(btnPin, INPUT_PULLUP);
digitalWrite(ledPin, ledState);
timer.setInterval(100L, checkPhysicalButton);
Blynk.begin(auth, "xxxxxxx", "xxxxxxx");
while (Blynk.connect() == false) {
// Wait until connected
}
timer.setInterval(60000L, sendUptime);
// Setup a function to be called every 100 ms
}
bool isFirstConnect = true;
// This function will run every time Blynk connection is established
BLYNK_CONNECTED() {
if (isFirstConnect) {
Blynk.syncAll();
isFirstConnect = false;
}
}
// When App button is pushed - switch the state
BLYNK_WRITE(V2) {
ledState = param.asInt();
digitalWrite(ledPin, ledState);
}
void checkPhysicalButton()
{
if (digitalRead(btnPin) == LOW) {
// btnState is used to avoid sequential toggles
if (btnState != LOW) {
// Toggle LED state
ledState = !ledState;
digitalWrite(ledPin, ledState);
// Update Button Widget
Blynk.virtualWrite(V2, ledState);
}
btnState = LOW;
} else {
btnState = HIGH;
}
}
void loop()
{ timer.run();
Blynk.run(); // Run Blynk
// Run SimpleTimer
}
I have tried your code but got many errors. can explain how to implement this your my code???
I am using Nodemcu ESP 8266 12e.