Wemos D1 + Blynk + Arduino IDE (Dont Work)

Thx for all help but idk WHAT HAPPEND i rewrite all code and now works perfect…

#define BLYNK_TEMPLATE_ID           ""
#define BLYNK_DEVICE_NAME           "Wemos Living"
#define BLYNK_AUTH_TOKEN            ""


#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

char ssid[] = "Jarvis Modem";
char pass[] = "";


const int timbre = D7;
const int btntimbre = D8;

const int btnluz = D13;
const int luzliving = D5;
const int luzgarage = D6;

int estadotimbre = LOW;
int estadobtntimbre = LOW;
int estadobtnluz = LOW;
int estadoluzliving = LOW;
int estadoluzgarage = LOW;

BlynkTimer timer;
void checkPhysicalButton();
void checkPhysicalBatton();


BLYNK_CONNECTED() {
  Blynk.syncVirtual(V1);
  Blynk.syncVirtual(V2);
  Blynk.syncVirtual(V3);
}

BLYNK_WRITE(V1) {
  estadoluzliving = param.asInt();
  digitalWrite(luzliving, estadoluzliving);
}
BLYNK_WRITE(V2) {
  estadoluzgarage = param.asInt();
  digitalWrite(luzgarage, estadoluzgarage);
}
BLYNK_WRITE(V3) {
  estadotimbre = param.asInt();
  digitalWrite(timbre, estadotimbre);
}

void checkPhysicalButton()
{
  if (digitalRead(btntimbre) == LOW) {
    if (estadobtntimbre != LOW) {
      estadotimbre = !estadotimbre;
      SonarTimbre();
      Blynk.logEvent("tocarontimbre");
    }
    estadobtntimbre = LOW;
  } else {
    estadobtntimbre = HIGH;
  }
}

void checkPhysicalBatton()
{
  if (digitalRead(btnluz) == LOW) {
    if (estadobtnluz != LOW) {
      estadoluzliving = !estadoluzliving;
      digitalWrite(luzliving, estadoluzliving);
      Blynk.virtualWrite(V1, estadoluzliving);
    }
    estadobtnluz = LOW;
  } else {
    estadobtnluz = HIGH;
  }
}

void SonarTimbre()
{
  digitalWrite(timbre, LOW);
  Blynk.virtualWrite(V3, LOW);
  Serial.print("Timbre Encendido");
  Serial.println();
  timer.setTimeout(1000L, ApagarTimbre);  // Run ActionOFF function in 5 seconds
}

void ApagarTimbre()
{
  digitalWrite(timbre, HIGH);
  Serial.print("Timbre Apagado");
  Serial.println();
  Blynk.virtualWrite(V3, HIGH);


}

void setup()
{
  // Debug console
  Serial.begin(115200);

  Blynk.begin(auth, ssid, pass);

  pinMode(luzliving, OUTPUT);
  pinMode(luzgarage, OUTPUT);
  pinMode(timbre, OUTPUT);

  pinMode(btntimbre, INPUT_PULLUP);
  pinMode(btnluz, INPUT_PULLUP);


  timer.setInterval(100L, checkPhysicalButton);
  timer.setInterval(100L, checkPhysicalBatton);

}

void loop()
{
  Blynk.run();
  timer.run();
}
1 Like

I recommend you to try the automation as well.

i use automation for lighs, what is your commend ?

The new wait function, to create a timer switch.

Where is ? i only have “Time of day” , Sunset / Sunrise, Device state, Scene.

Are you using the latest version of the app 1.3.5 ?

daaaaaaaaam , why no auto update (android).
i gonna check now. thx !!