Time input as Alarm Clock

Hello, my name is Rafael Borges, I am trying to set the time input widget as an alarm clock, but I have read some topics here and still having some trouble.

I wish I could turn relays on pins Digital 2 and 4 on when the time hits the time I’ve set on time input widget V0.

Is it possible to do that?

This is the code I’m trying to use, provided by COSTAS


/**************************************************************
 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social networks:            http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 *
 * This example shows how to use Arduino Ethernet shield (W5100)
 * to connect your project to Blynk.
 * Feel free to apply it to any other example. It's simple!
 *
 * NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
 *       DON'T use them in your sketch directly!
 *
 * WARNING: If you have an SD card, you may need to disable it
 *       by setting pin 4 to HIGH. Read more here:
 *       https://www.arduino.cc/en/Main/ArduinoEthernetShield
 *
 **************************************************************/

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>
#include <Thermistor.h>
#include  <Time.h>
#include <TimeLib.h>
#include <WidgetRTC.h>

char auth[] = "XXXX";
char Date[2];
char Time[2];

#define W5100_CS  10
#define SDCARD_CS 4
Thermistor temp(0);
SimpleTimer timer;

long startseconds;            // start time in seconds
long stopseconds;             // stop  time in seconds
long nowseconds;              // time now in seconds

int btnpin;
WidgetRTC rtc;

BLYNK_ATTACH_WIDGET(rtc, V0); 
 
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
    int temperature = temp.getTemp();
  Blynk.virtualWrite(3, temperature);
}

void setup(){
    Serial.begin(115200);         // COSTAS
    Serial.println("\nStarted");  // COSTAS
    pinMode(2, OUTPUT);
    Blynk.begin(auth);
    while (Blynk.connect() == false) {     // COSTAS
      // Wait until connected              // COSTAS
    }                                      // COSTAS
    Blynk.notify("Connected successfully");
    Serial.println("Done");
    rtc.begin();
    timer.setInterval(60000L, activetoday);     // check every minute if schedule should run today
    timer.setInterval(30000L, reconnectBlynk);  // check every 30s if still connected to server
    timer.setInterval(1000L, myTimerEvent);     // check room temperature every second
}

 void activetoday(){        // check if schedule should run today   
     if(year() != 1970){
        Blynk.syncVirtual(V1); // sync timeinput widget
        sprintf(Date, "%02d/%02d/%04d",  day(), month(), year());     // COSTAS
        sprintf(Time, "%02d:%02d:%02d", hour(), minute(), second());  // COSTAS
     }
}

BLYNK_WRITE(V1) {  

    TimeInputParam t(param);
    Serial.print("Checked schedule at: ");
    Serial.println(Time);
    int dayadjustment = -1;
    
    if(weekday() == 1){
        dayadjustment =  6; // needed for Sunday, Time library is day 1 and Blynk is day 7
    }

    if(t.isWeekdaySelected((weekday() + dayadjustment))){ //Time library starts week on Sunday, Blynk on Monday
         Serial.println("Schedule ACTIVE today");

         
          nowseconds = ((hour() * 3600) + (minute() * 60) + second());
          
          startseconds = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);
          
          if(nowseconds >= startseconds){
                   
                   if(nowseconds <= startseconds + 90){    // 90s on 60s timer ensures 1 trigger command is sent
                            // code here to switch the relay ON
                            digitalWrite(2, HIGH); // set Relay ON
                            Blynk.virtualWrite(V2, 1);              
                    }
          }

          else{
              Serial.println("Relay not on");
              // nothing more to do here, waiting for relay to be turned on later today
          }
         
          stopseconds = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
          if(nowseconds >= stopseconds){                
                  // 90s on 60s timer ensures 1 trigger command is sent
                  if(nowseconds <= stopseconds + 90){   
                          // code here to switch the relay OFF
                          digitalWrite(2, LOW); // set Relay OFF
                          Blynk.virtualWrite(V2, 0);
                   }
          }
          else{
                  if(nowseconds >= startseconds){  // only show if motor has already started today
                              Serial.println("Relay is still ON");
                              // nothing more to do here, waiting for motor to be turned off later today
                  }
          }
    }
    else{
        Serial.println("Schedule INACTIVE today");
        // nothing to do today, check again in 1 minutes time
    }
    Serial.println();
}

void reconnectBlynk() {
    if (!Blynk.connected()) {
      if(Blynk.connect()) {
          BLYNK_LOG("Reconnected");
      }
      else {
          BLYNK_LOG("Not reconnected");
      }
 }
}

BLYNK_WRITE(V2) {
     btnpin = param.asInt();
     digitalWrite(2, btnpin);
}

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

But i’m not getting the serial print to see if the time input is set for today, also I can’t see the time the wigdet is set after the correction, so I don’t know if it is correct for my timezone

@borges_rafa as per the other thread the RTC widget has recently changed so the code you have will need to be modified. See the latest RTC example provided by Blynk and if you are still struggling let me know and I will look through your revised sketch.