Garden Project

What I mean is that time input is the only one when you press play and you’re in test mode. lets you choose when it starts and ends, days, etc.

with the other wigets you have to have programming knowledge and you can not change it when the app is running (play)

That is what it’s purpose is for… INPUTTING time (in UI format) into a RUNNING sketch… and it it REQUIRES programming knowledge for that sketch to do something with that time :wink:

It does NOT simply toggle the vPIN ON and OFF (But timer does - however, yes, you need to stop and start the App to set it)

It (Time Input) loads the vPin with the UI timestamp based on the choices you make in the widgets interface, then as soon as you press OK, it sends that data to the server/device so your code can break it down into the separate components (seconds, minutes… etc) and your code processes it to determine WHEN to do whatever you programmed it to do.

These days I was reading and looking for examples that could be useful for my nodeMCU. I can not find any code that serves me. if someone can help me set the time input to turn on a relay every day in a selectable period I will be very grateful

Read through the thread.

This may be more than you need and it isn’t set up for BLYNK but there may be parts of it you can use.

This sketch uses internet time to control on/off time for two strings of Christmas lights.
The time reverences in the sketch are for GMT-8 (West coast US)
Also contains OTA (over the air) programming since it is hard to get to.

/* Time functions - use this link for format http://www.cplusplus.com/reference/ctime/mktime/
 *  Uses wifi time instead of RTC.
    Set-up for OTA updates
    only works on ESP-12 or ESP-01 with 4MB memory chip
    voidloop() -> ArduinoOTA.handle(); makes it work other stuff comes after that line
    other variables can be set-up in setup()
    this program blinks two strands of lights with defined start and end times
    This ESP8266 address is 111.123.1.145
*/
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <time.h>

const char* ssid = "XXXXXXXXX";
const char* password = "YYYYYYYYYY";
const int timezone = -8;
int timer = 1000;
const char* host = "XMAS_OTA-Lights";


void setup() {
  Serial.begin(115200);
  Serial.setDebugOutput(true);
  Serial.println("Booting");
  WiFi.mode(WIFI_STA);
  WiFi.hostname("XMAS_OTA-Lights");
  WiFi.begin(ssid, password);
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("Connection Failed! Rebooting...");
    delay(5000);
    ESP.restart();
  }
  ArduinoOTA.onStart([]() {
    Serial.println("Start");
  });
  ArduinoOTA.onEnd([]() {
    Serial.println("\nEnd");
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.onError([](ota_error_t error) {
    Serial.printf("Error[%u]: ", error);
    if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
    else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
    else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
    else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
    else if (error == OTA_END_ERROR) Serial.println("End Failed");
  });
  ArduinoOTA.begin();
  Serial.println("Ready");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  pinMode (0,OUTPUT); 
  pinMode (1,OUTPUT);
  pinMode (2,OUTPUT); 

  digitalWrite (1,HIGH); // Blue LED off

#define PST (0)
#define UTC (+8)
Serial.println("\nConnecting to WiFi");
  while (WiFi.status() != WL_CONNECTED) {
    //Serial.print(".");
    delay(1000);
    }
      
  configTime(timezone * 3600, 0, "pool.ntp.org", "time.nist.gov");
  //Serial.println("\nWaiting for time");
  while (!time(nullptr)) {
    Serial.print(".");
    delay(1000);
  }
}

void loop() {
  ArduinoOTA.handle();
  time_t rawtime;
  struct tm * timeinfo;

  time ( &rawtime );

  timeinfo = localtime ( &rawtime );

  // turn the lights on at a specific time (and day)
  Serial.printf (asctime(timeinfo)); //Jan=0, Dec = 11
  if ((timeinfo->tm_mon == 0) && 
     (timeinfo->tm_mday >= 7) && (timeinfo->tm_mday <= 12)&&
     (timeinfo->tm_hour >= 12) && 
     (timeinfo->tm_hour < 22 )){    // mon, mday, hour, min, sec
     
    //Serial.printf (asctime(timeinfo));
    digitalWrite(0, HIGH); // turn the pin on:
    delay(timer);
    
    digitalWrite(0, LOW);// turn the pin off:
    //delay(timer);

    digitalWrite(2, HIGH); // turn the pin on:
    delay(timer);
    
    digitalWrite(2, LOW);// turn the pin off:
    //delay(timer);
    }
}

@randobi99 - Please properly format posted code!

EDIT - posting a 2nd, unformatted code, post doesn’t count :stuck_out_tongue_winking_eye:

I have deleted your 2nd post and edited your last one as per the proper methods… that have been mentioned throughout this forum many, many, times :wink:

Blynk - FTFC

good after reading well and looking good. Test the izis Scheduler and it works well (thanks for the patience coasts) but I have 2 questions.
1 Can I change the gpio?
2 is it necessary that this the rtc widget in the project?

Yes and yes.

I do not know if it will be my nodemcu problem but I change the digitalWrite (16, 1) for the pin that I want but do not turn it on. It also happens to me that 1 is off and 0 is on. that is normal?

Do you really need to use special pin 16?

Some on board LED’s and most relays are ACTIVE LOW. Just switch 0 and 1.

I have plenty of pins but the 16 starts on and I can not turn it off. It costs me that the 4 channels light and turn off well

What operating system is on your phone? Is it Android phone or an Apple iPhone?