Time input - code time

Hey.
I some help with the time input widget, i really cant figure out hos to set to time to fx 4:15 am and stop at 4:50 am

Must be simple but cant find out how plz help :pray:

There is already a heap of topics for time input. Search the forum I’m sure you’ll find what you need.

Trust me i tried, just need to understand how i set the time

Like this:
image

Pete.

What about the code

Blynk.virtualWrite(Vx, startAt, stopAt, tz);

Pete.

That dossent help much :eyes:

It’s all you really need to know, but you’d have discovered that if you did a bit of searching as @GG07 suggested. You’ve currently spent a grand total of 1 hour reading topics on the forum!

If you want more then try the Sketch Builder Advanced example:
https://examples.blynk.cc/?board=ESP8266&shield=ESP8266%20WiFi&example=Widgets%2FTimeInput%2FAdvancedTimeInput

Pete.

#define timeinpin       V14 // set to the pin you use

const char*  daystrings[7]  =  {"Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat"};
const char*   monthstrings[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
String  SThour;
String  STmin;
String  SPhour;
String  SPmin;
int     days[7];

BLYNK_WRITE(timeinpin) {
  TimeInputParam t(param);

  if (t.hasStartTime())   // Process start time
  {
    SThour = String(t.getStartHour());
    STmin = String(t.getStartMinute());
  }


  if (t.hasStopTime())    // Process stop time
  {
    SPhour = String(t.getStopHour());
    SPmin = String(t.getStopMinute());
  }

  // Process weekdays (1. Mon, 2. Tue, 3. Wed, ...)
  days[0] =  t.isWeekdaySelected(1);
  days[1] =  t.isWeekdaySelected(2);
  days[2] =  t.isWeekdaySelected(3);
  days[3] =  t.isWeekdaySelected(4);
  days[4] =  t.isWeekdaySelected(5);
  days[5] =  t.isWeekdaySelected(6);
  days[6] =  t.isWeekdaySelected(7);

  Serial.println(SThour + ":" + STmin);
  Serial.println(SPhour + ":" + SPmin);
  for (int i = 0; i++; i < 7) {
    //    if (days[i]) {
    Serial.print(String(i) + " ");
    //    }
    Serial.println(" ");
  }
  Serial.flush();
}

Добавить Real-Time-Clock и этот код

#include <TimeLib.h>
#include <WidgetRTC.h>

long startsecondswd;            
long stopsecondswd;
long nowseconds;                // время в секундах
WidgetRTC rtc;
void activetoday() {      

  if (year() != 1970) {   // Если подключились к Серверу Реального Времени то тут точно не 1970 год
    // значит можно проверить код дальше


    Blynk.syncVirtual(V23); // синхронизируем виджет timeinput
  }
}

BLYNK_WRITE(V23) {
    TimeInputParam t(param);

      nowseconds = ((hour() * 3600) + (minute() * 60) + second());
      startsecondswd = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);
      //Serial.println(startsecondswd);  // used for debugging
      if (nowseconds >= startsecondswd) {

        if (nowseconds <= startsecondswd + 90) {  //код для того что бы точно отправить сигнал на реле (90s on 60s timer ensures 1 trigger command is sent)
          digitalWrite (relay2, HIGH); // код что бы переключить реле в ON          
        }
      }

      stopsecondswd = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
      //Serial.println(stopsecondswd);  // used for debugging
      if (nowseconds >= stopsecondswd) {
        digitalWrite (relay2, LOW); // OFF реле        

        if (nowseconds <= stopsecondswd + 90) { //код для того что бы точно отправить сигнал на реле (90s on 60s timer ensures 1 trigger command is sent)
         digitalWrite (relay2, LOW); // код что бы переключить реле в OFF
        }
      }
      else {
        if (nowseconds >= startsecondswd) {
          digitalWrite (relay2, HIGH); // ON реле          
        }
      }
}

void setup()
{
  rtc.begin();
  timer.setInterval(10000L, activetoday);  
}