Doing something at a specific time using RTC

Hi I am building a project that turns on an led when the time is 7PM. Fow hardware I have a Wemos D1 Mini. I have edited the RTC code but cant get the led to turn on. I just have the RTC widget and two value widget to display the time and date which are on V16 and V17. I also have an led connected to D2. When I open the serial monitor the time and date are correct. Can someone check my code and tell me what am I doing wrong?

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

#define led 4

#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <TimeLib.h>
#include <WidgetRTC.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "5eaf67aaedc94220947d3908bff4b094";

char ssid[] = "Clayton Camilleri Wi-Fi";
  char pass[] = "clayton13";

BlynkTimer timer;

WidgetRTC rtc;

// Digital clock display of the time
void clockDisplay()
{
  
if (hour() > 19)
  {
     digitalWrite(led, HIGH);
  }
  else if (hour() < 19);
  {
   digitalWrite(led, LOW);
  }
  
  // You can call hour(), minute(), ... at any time
  // Please see Time library examples for details

  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(day()) + " " + month() + " " + year();
  Serial.print("Current time: ");
  Serial.print(currentTime);
  Serial.print(" ");
  Serial.print(currentDate);
  Serial.println();

  // Send time to the App
  Blynk.virtualWrite(V16, currentTime);
  // Send date to the App
  Blynk.virtualWrite(V17, currentDate);
}

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

   Blynk.begin(auth, ssid, pass);


  // Begin synchronizing time
  rtc.begin();

  // Other Time library functions can be used, like:
  //   timeStatus(), setSyncInterval(interval)...
  // Read more: http://www.pjrc.com/teensy/td_libs_Time.html

  // Display digital clock every 10 seconds
  timer.setInterval(1000L, clockDisplay);
}

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

You have > and < 19 but no >= or <= so LED will only trigger up to 18:59 and after 20:00 (1 hour missing).

Is your timezone GMT + 1?

1 Like

No it`s GMT +2

What time were you doing the tests?

1 Like

The time was 19:30 approximetly

As I thought > and < are no good, you missed the 1 hour that you were doing the tests.

1 Like

Oh you are right I couldn`t understand the comparison operators. I always mix them up. One question. If I want to schedule an led to come on using the time input widget. How can I do that and is it even possible.

Thanks

Yes it’s possible, learn to use the Sketch Builder https://examples.blynk.cc/?board=ESP8266&shield=ESP8266%20WiFi&example=Widgets%2FTimeInput%2FAdvancedTimeInput