TimeInput for IrrigationWater

Hi, I’m trying to create an irrigation control unit with Blynk. I did it and it works very well but I would like to use “Time Input” for each relay and then automate everything on the virtual pins: from V1 to V8 connected to digital pins: from 2 to 9. I also inserted a humidity sensor for humidity and temperature and also that works well … including the led widgets that light up showing me the status of the relay when you activate them through a simple button widget.

It would be good even though, but I can not always switch on and off the relays manually so I would need to use the Time Input function, to turn on in days I want at the time I want the relay. Unfortunately, I do not know how to add this feature now. Can you help me? Even for the virtual pin 1 … for the remaining 7 then I’ll take care of it.

I hope you can help me and give clarifications.

I apologize if my English is not correct … I speak Italian and I helped with google translator.



/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  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
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************
  =>
  =>          USB HOWTO: http://tiny.cc/BlynkUSB
  =>

  Feel free to apply it to any other example. It's simple!
 *************************************************************/

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

// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(0, 1); // RX, TX
#include <DHT.h>
#include <BlynkSimpleStream.h>

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

//inisialisasi port relay
const int relay1 =  2; const int relay2 =  3;
const int relay3 =  4; const int relay4 =  5;
const int relay5 =  6; const int relay6 =  7;
const int relay7 =  8; const int relay8 =  9;

#define DHTPIN 10
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    //SwSerial.println("Failed to read from DHT sensor!");
    return;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V22, h);
  Blynk.virtualWrite(V23, t);
}

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

  // Blynk will work through Serial
  // Do not read or write this serial manually in your sketch
  Serial.begin(9600);
  Blynk.begin(Serial, auth);

  dht.begin();
  timer.setInterval(1000L, sendSensor);
  
  pinMode(relay1, OUTPUT); 
  pinMode(relay2, OUTPUT);
  pinMode(relay3, OUTPUT);
  pinMode(relay4, OUTPUT);
  pinMode(relay5, OUTPUT); 
  pinMode(relay6, OUTPUT);
  pinMode(relay7, OUTPUT);
  pinMode(relay8, OUTPUT);
  
  digitalWrite(relay1,HIGH);
  digitalWrite(relay2,HIGH);
  digitalWrite(relay3,HIGH);
  digitalWrite(relay4,HIGH);
  digitalWrite(relay5,HIGH);
  digitalWrite(relay6,HIGH);
  digitalWrite(relay7,HIGH);
  digitalWrite(relay8,HIGH);

}

WidgetLED led1(V12); WidgetLED led2(V13);
WidgetLED led3(V14); WidgetLED led4(V15); 
WidgetLED led5(V16); WidgetLED led6(V17);
WidgetLED led7(V18); WidgetLED led8(V19);

BLYNK_WRITE (V1){
    if(param.asInt()==0){
      digitalWrite(relay1,LOW);
      led1.on();
      }
    else{
       digitalWrite(relay1,HIGH);
       led1.off();
       }
  }
BLYNK_WRITE (V2){
    if(param.asInt()==0){
      digitalWrite(relay2,LOW);
      led2.on();
      }
    else{
       digitalWrite(relay2,HIGH);
       led2.off();
       }
  }
BLYNK_WRITE (V3){
    if(param.asInt()==0){
      digitalWrite(relay3,LOW);
      led3.on();
      }
    else{
       digitalWrite(relay3,HIGH);
       led3.off();
       }
  }
BLYNK_WRITE (V4){
    if(param.asInt()==0){
      digitalWrite(relay4,LOW);
      led4.on();
      }
    else{
       digitalWrite(relay4,HIGH);
       led4.off();
       }
  }
BLYNK_WRITE (V5){
    if(param.asInt()==0){
      digitalWrite(relay5,LOW);
      led5.on();
      }
    else{
       digitalWrite(relay5,HIGH);
       led5.off();
       }
  }
BLYNK_WRITE (V6){
    if(param.asInt()==0){
      digitalWrite(relay6,LOW);
      led6.on();
      }
    else{
       digitalWrite(relay6,HIGH);
       led6.off();
       }
  }
BLYNK_WRITE (V7){
    if(param.asInt()==0){
      digitalWrite(relay7,LOW);
      led7.on();
      }
    else{
       digitalWrite(relay7,HIGH);
       led7.off();
       }
  }
BLYNK_WRITE (V8){
    if(param.asInt()==0){
      digitalWrite(relay8,LOW);
      led8.on();
      }
    else{
       digitalWrite(relay8,HIGH);
       led8.off();
       }
  }


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


1 Like

I recommend you read through all of this to better understand how the Time Input Widget works.