BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

I need to set timers for relay with esp-01


#1

I need to set timers for relay with esp-01.I have the code in my hand,but it has some sort of problems.
When i set the timer for hours,it will stop in few seconds.

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define relay
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "0fc5f00064694bf1a3489d3170c66868";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Redmi";
char pass[] = "";
BLYNK_WRITE(V1) {
  long startTimeInSecs = param[0].asLong();
  Serial.println(startTimeInSecs);
  Serial.println();
  if(digitalRead(1) == LOW)
  {
    delay(startTimeInSecs);
    digitalWrite(1,HIGH);
  }
  else
  {
    delay(startTimeInSecs);
    digitalWrite(1,LOW);
    
  }
  
}
BLYNK_WRITE(V2) //Button Widget is writing to pin V1
{
  int pinData = param.asInt();
  if(pinData == 1)
  {
    digitalWrite(1,HIGH); 
  }
  else
  {
    digitalWrite(1,LOW);
  }
}
void setup()
{
  // Debug console
  Serial.begin(9600);
  pinMode(1, OUTPUT); 
  Blynk.begin(auth, ssid, pass);
}

void loop()
{
  Blynk.run();
}

Any one help me???


Time input, start/stop time to trigger a solid state relay
#2

Please don’t dump your unformatted code and help issue in someone else’s topic. I have moved your question into its own topic and formatted your code as required.

Blynk - FTFC


#3

Read through this whole topic and experiment until you understand it better… the code section you have is for the seconds part, not the hours.