Best way to do?


Dear Sirs,
I have something to implement and I am looking for the best way to do it. What I want: Using a blynk slider I will pass an int to a variable like how many seconds a relay will be on, activated. If the user press a start button then using a blynk timer ( simpletimer ) will be activated this relay on for the specified time and then off.
I am in trouble how to setup and call the timer.
Can you help me?

Thanks and Best Regards,
Mike Kranidis


Hello, you can sent me PM here.


OK I remember now… I will visit your site.


Any idea or help regarding my question?


Hi Mike,
Check this idea, (it’s working on the ESP01):

BLYNK_WRITE(V10)//      slider  from 1 to 10 seconds 
 int timerelayon = param.asInt(); 
 Blynk.virtualWrite(V11, relay);

BLYNK_WRITE(V12)  // ON-OFF Switch mode
    if (param.asInt()==1) {
    digitalWrite(TestLED, HIGH); // set LED ON 
    int relaysec = relay * 1000;
    timer.setTimeout(relaysec, resetRELAY);

void resetRELAY(){
  digitalWrite(TestLED, LOW); // set LED OFF 
  Blynk.virtualWrite(V12, 0);;



come on, just read the SimpleTimer docs…
At the button press handling routine just put the timer.setTimeout(sliderReceivedValue, callMeAfter);
and it should go! I think… int sliderReceivedValue; declared globally off course

edit: …and @psoro was first … :stuck_out_tongue:


I even have a slightly more complicated example using a slider to adjust a timer for a variable speed servo… but same initial concept.


@psoro @marvin7 @Gunner
First of all I would like to thank you guys for the ideas and the guidance. I can implemented now, the code part, is not so hard to me, the only concerning that is left: how to have possible using a value display widget, the countdown indication in order to have visualized the starting time in seconds down to zero when the time expired… ?

Thanks and Best Regards,
Mike Kranidis


again BlynkTimer/SimpleTimer might help here:

Using the snippet provided by @psoro just add:

timer.setTimeout(relaysec, resetRELAY);
add this one:

timer.setTimer(1000, repeatUntilCountdown, relay);
countdown = relay;

and the routine:

int countdown; //globally

void repeatUntilCountdown () {
Blynk.virtualWrite (V11, countdown); //value widget from above

not tested, but now you have the idea :wink:


Thanks @marvin7 I will try it when at home. Just one observation, I think we need a way to decrease the relay value possible in your repeatUntilCountdown function. As I can see, without this, you passing always the same value ( countdown = relay ; ) to this function…
Anyway I got the idea!



Yes, sure! Simply forgot about it :wink: so it will be:

void repeatUntilCountdown () {
Blynk.virtualWrite (V11, countdown); //value widget from above