Hi is anyone to know how set Slider widget to set a minutes

@tzo_mats I’m not familiar with LUA but it looks like you are connecting to the Blynk server OK.

Have you connected the slider to digital pin 13 or virtual pin V0?

It needs to be V0 and then make a couple of changes in the sketch to actually send ON / OFF to your relay.

Make the change for V0 at your side and I will do a quick mod of the sketch for your relay and post it here.

Edit: if you have version 2 of the D1 then I don’t think you should be looking at pin13. D5 on the rev2 and the Mini is GPIO 14. So my sketch mod will use 14 not 13. Are the relays active HIGH or LOW (I’ll assume active HIGH for now).

Something like this:

// thirtysecondtimer.ino by Costas 12 Dec 2016
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>      // library for SimpleTimer       

SimpleTimer timer;            // define a timer for use by SimpleTimer library
int Countdown;                // Global variable used in Slider widget and runEveryMinute()
bool ONstatus  = false;       // variable to switch device ON and OFF
char auth[] = "YourAuthToken";
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

BLYNK_WRITE(V0){   // add a slider to your project on V0 range 0 to 30 (minutes)
  Countdown = param.asInt();  // set variable as Slider value
}

void runEveryMinute(){ // runs every 60s, will do noting when Slider is at zero
  
  if((Countdown > 0)&& (ONstatus == true)){
    Countdown--;    //  reduce Countdown by 1 minute every 60s
    Serial.print(F("Device will switch OFF in "));
    Serial.print(Countdown);
    Serial.println(F(" minute(s)"));    
  }  
  
  if((Countdown > 0) && (ONstatus == false)){
    Serial.println(F("Device was switched ON"));
    ONstatus = true;   // to ensure device is only turned ON once
    // code here to turn your device ON
    digitalWrite(14, HIGH); // send ON signal to relay     
  }

  if((Countdown == 0) && (ONstatus == true)){
    Serial.println(F("Device is now OFF"));
    ONstatus = false;    // to ensure device is only turned OFF once
    // code here to turn your device OFF
    digitalWrite(14, LOW); // send OFF signal to relay
  }
}

void setup()
{
  pinMode(14, OUTPUT);  // think D5 WeMos is GPIO 14
  digitalWrite(14, LOW); // ensure relay is OFF on reboot
  Serial.begin(115200); 
  Blynk.begin(auth, ssid, pass);  // this is now a blocking function - more on this later
  timer.setInterval(60000L, runEveryMinute);  // start the 60s timer function  
}

void loop()
{
  Blynk.run();
  timer.run(); // Initiates SimpleTimer to ensure the 60s timer keeps running 
}

To test your relays you can add a Blynk button in Switch mode to digital pin 14 and it should turn the relays on and off, irrespective of the Slider position.

befor i change something i put a multimeter οn my gpio to D7 and i get 0.106v when the slider is on and 0v when is of
this is means it works ?

It is working in a fashion but you should be looking to use the super powerful virtual pins for the slider not the digital pins. Then inside the slider function you have the code to control the digital pins. Virtual pins have a lot of features that digital pins don’t have, for example their state can be saved to and from the server which you can’t do with digital pins.

You have now mentioned D5 and D7. If your relay is connected to D7 then you will need to change the 3 entries of 14 in the sketch to 13.

It would be normal to define the relay pin with your other variables with something like:
#define relayPin 13

and then use relayPin in place of 13 throughout your sketch. this way you only have to change the define line if you move your relay to another pin.

i m not change anything to gpio you have right…
i little comfuse that did you seed about the virtual pins!
if i use the v pins i get more power ?

With Blynk the Virtual pins are more flexible (powerful) than digital pins. Actually the virtual pins have “no power” as they are not real pins but they work alongside the digital pins, which obviously do have power.

ok let change the code to virtual pins because i need it this power

Code is using virtual pin (V0) and then it sends high and low to digital pin. You just need to ensure your slider is connected to V0 in the Blynk app. Also change 14 to 13 in the sketch if your relay is connected to D7 on the WeMos.

if i change the slider to V0 wich pin on the board i use ? right now i use GND + D5
after ?

No change required on the board and none in the sketch either.

In the sketch above I have (GPIO) 14 entered 3 times and tied to V0. The 14 is D5 on your WeMos so the hardware and sketch are good to go as they are.

ok, but i have couple second delay

50 second delay to close and 30sec to open actually

Are you saying it is all working with Blynk but that there is a delay between moving the slider and the relay turning on?

The delay is “coded” into the sketch and covered by the following text in the thread for the Slider sketch.

“We have tried to keep the sketch as basic as possible and as such it has some limitations. For example when you move the Slider it will take up to 60 seconds for “Device was switched ON” to appear in Serial Monitor.
There are many ways to remove this limitation and guidance can be found by studying SimpleTimer in detail at http://playground.arduino.cc/Code/SimpleTimer

If you don’t want to wait up to 60 seconds, simply add a Blynk button in Switch mode and tie it to digital pin 14. With the Blynk button you don’t need any extra lines of code in the sketch, it just works!

ok cool works
you are the best
i have many many of questions but for now all i wan to know if i took life report with sirial monitor like to see countdowning?

with button ho just add if the slide is alredy on and the button is off when i swich the button to on its start countdown 30sec?

if my connection is down works without internet ?

how i get how many hours it’s worked ?

Serial Monitor is already showing the countdown and you can add the countdown easily to your Smartphone (Blynk Display widget etc).

Not sure what you mean about the 30 seconds but what I will say is that the existing code has a 60s (60000ms) loop that is processed even if you do nothing in the app. The if statements look to see if you have moved the slider etc. With the 60s loop it can be anywhere within this 60s period when you move the slider and that is why I say it will take 0 to 60s to respond.

For most real life situations this is fine as it doesn’t matter if your Sprinkler, Central Heating, Washing Machine etc starts now or some time in the next 60 seconds. It is just important that it does start within 1 minute of you making the request.

Obviously there are some applications (emergency breaking etc) when the action must be processed immediately and SimpleTimer has many ways to handle this.

If you need the project to work without an internet connection you need a local Blynk server at your location. Depends how reliable your internet connection is but most users don’t need a local server.

To get the total hours that the sprinkler has been running you have a second variable alongside Countdown (perhaps called TotalTime) and you increment it every time Countdown is reset and send it to a Blynk display widget on a virtual pin. Blynk then has a function called Blynk.syncVirtual(Vx) which can be called at any time to retrieve the total Sprinkler time from their server.

ah my god I have so many questions and not know if i must dey because I have a fatigue much already and I feel bad for this:expressionless:

however, to know i dont need for sprinkler its most about the job!!!

if you were holding my questions and not tired, tell me continue???

Sent you a message @tzo_mats

How can I manage many esp8266 together ?
and what other board I can use with this sketch?

That depends on specific project. Read cloning, sharing and bridge in the documentation.[quote=“tzo_mats, post:39, topic:9997”]
and what other board I can use with this sketch?
[/quote]

Blynk supoorts a huge list of hardware and the sketch should work on all supported hardware.