Set pin GP15 on/off at specific time and at specific days

Hi
I’m trying to set pin GP15 on/off at specific time and at specific days, for example: turn on at Sunday, Tuesday and Thursday at 0630AM to 0640AM
I have Huzzah feather board that based on ESP8266
Need help with what widget to select and the code
Many thanks
Eli

Use Eventor.
Eventor

In the widget you can set the days of the week and times.

thanks but i don’t have it on my application.
i have installed application on my iPhone . the blynk version is 2.10.1

Okay, but is your board setup to connect to the Blynk cloud and do you have the Blynk app on your phone talking to your board? If nothing else get that basic setup done. From there it’s just a matter of going into the Blynk app on your phone and adding that widget and setting the days/times you want. You would have to add any extra code either on the feather board. With Blynk you have to think of it of two ways to control your board. Either with the stand code to turn on/off pins or let the Blynk application settings. Of course you could do both depending on if you need need the code on your board to control it when it’s not connected to the network.

Eventor is not available yet for iOS.

Ahhh ok. That makes sense. Sorry about that. I haven’t looked to see if there is a library to handle that on the ESP8266 side. Which it sounds like what they will have to use.

1 Like

@elibt do a search for EziScheduler.

1 Like

When will it be available?

Any ideas when Eventor will be ready @Eugene?

No schedule for Eventor on iOS right now.
@elibt actually TimeInput Widget may better suit your needs - being able to see and change those time settings on the go.

See EziScheduler @elibt

Thanks but it will work with virtual pin only.right?

You should only be using virtual pins.

BLYNK_WRITE(V1){
  digitalWrite(15, param.asInt());
  // .. also do other functions at the same time
}

No but as @Jamin indicates virtual pins are so much more powerful than digital pins. Send a signal to a digital pin and you control a single digital pin / device, send the same signal to a virtual pin and you control up to 128 digital pins, if you have that many. There are other benefits to virtual pins too i.e. some widgets only work with virtual pins.

Thanks. How do I connect between virtual pin to physical pin(gp15)?

BCM, Physical, Wiring Pi or GPIO?

@Jamin already showed how in his code snippet, a couple of posts back :wink: V1 controlling GPIO 15 via digitalwrite.

Also…

http://help.blynk.cc/getting-started-library-auth-token-code-examples/blynk-basics/what-is-virtual-pins

etc…

Appreciate your help

Gpio. Want to toggle on and off GP15

@elibt I think I was confusing your post with an Rpi thread so BCM etc is not relevant.
GPIO’s 0, 2 and 15 are part of the boot sequence for ESP’s so should be avoided unless you have run out of regular pins.

Below is the code, EziScheduler, for use with the Time Input widget and including your GPIO 15 control. There is also a second scheduler included in the code, as a spare to control other pins:

/****************************************************************************** 
  EziScheduler.ino   by Costas, 7 Sept 2017
  Scheduler with Time Input and obligatory OTA update facility for ESP's
  RTC widget (no pin allocation)
  LED V0
  Time Input V1
  Time Input V2
  To add more schedules simply copy BLYNK_WRITE(V1) function and change V1 to V3
  and in activetoday() function add: Blynk.syncVirtual(V3); // sync scheduler #3 
*******************************************************************************/
#define BLYNK_PRINT Serial 
#include <ArduinoOTA.h>             
#include <ESP8266WiFi.h>        
#include <BlynkSimpleEsp8266.h> 
BlynkTimer timer;

#include <TimeLib.h>
#include <WidgetRTC.h>
WidgetRTC rtc;
char currentTime[9];

char auth[]   = "**************"; 
char ssid[]   = "GargoyleTest";                     
char pass[]   = "**************";                     
char server[] = "blynk-cloud.com"; 
bool clockSync = false;    

void setup() {
  Serial.begin(115200);
  Serial.println();
  Blynk.begin(auth, ssid, pass, server);
  ArduinoOTA.setHostname("EziScheduler");       
  ArduinoOTA.begin();    
  timer.setInterval(60000L, activetoday);  // check every 60s if ON / OFF trigger time has been reached
  timer.setInterval(1000L, clockDisplay);  // check every second if time has been obtained from the server
}

BLYNK_CONNECTED() {
  rtc.begin();
}

void activetoday(){         // check if schedule #1 or #2 should run today
  if(year() != 1970){
    Blynk.syncVirtual(V1);  // sync scheduler #1
    Blynk.syncVirtual(V2);  // sync scheduler #2   
  }
}

void clockDisplay(){  // only needs to be done once after time sync
  if((year() != 1970) && (clockSync == false)){ 
    sprintf(currentTime, "%02d:%02d:%02d", hour(), minute(), second());
    Serial.println(currentTime);
    clockSync = true;
  } 
}    

BLYNK_WRITE(V1) {   // Scheduler #1 Time Input widget  
  TimeInputParam t(param);
  unsigned int nowseconds = ((hour() * 3600) + (minute() * 60) + second());
  unsigned int startseconds = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);  
  unsigned int stopseconds = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
  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  
    //Schedule is ACTIVE today 
    if(nowseconds >= startseconds - 31 && nowseconds <= startseconds + 31 ){    // 62s on 60s timer ensures 1 trigger command is sent
      Blynk.virtualWrite(V0, 255);  // turn on virtual LED
      Serial.println("Schedule 1 started");
      digitalWrite(15, 1);
    }                  
    if(nowseconds >= stopseconds - 31 && nowseconds <= stopseconds + 31 ){   // 62s on 60s timer ensures 1 trigger command is sent
      Blynk.virtualWrite(V0, 0);   // turn OFF virtual LED
      Serial.println("Schedule 1 finished");
      digitalWrite(15, 0);
    }               
  }
}

BLYNK_WRITE(V2) {   // Scheduler #2 Time Input widget  
  TimeInputParam t(param);
  unsigned int nowseconds = ((hour() * 3600) + (minute() * 60) + second());
  unsigned int startseconds = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);  
  unsigned int stopseconds = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
  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  
    //Schedule is ACTIVE today 
    if(nowseconds >= startseconds - 31 && nowseconds <= startseconds + 31 ){    // 62s on 60s timer ensures 1 trigger command is sent
      Blynk.virtualWrite(V0, 255);  // turn on virtual LED
      Serial.println("Schedule 2 started");
    }                  
    if(nowseconds >= stopseconds - 31 && nowseconds <= stopseconds + 31 ){   // 62s on 60s timer ensures 1 trigger command is sent
      Blynk.virtualWrite(V0, 0);    // turn OFF virtual LED
      Serial.println("Schedule 2 finished");
    }              
  }
}

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