Blynk Timer is not working

Hello,
I have troubles with timer widget on iOS using ESP32. I set the timer to virtual pin V6. It should give 1 or 0 and if it gives 0 it LED’s should be off and when it gives 1 they should be on. Due to difference of time between server and my time I set the timer from 24:01 to 23:59 to make sure that they will be on. And they were off. :frowning: So I added slider widget and set it to 0 - LED’s were off, then I set it to 1 - LED’s were on. Here’s my code

#define BLYNK_PRINT Serial
#include <analogWrite.h>

#define RED_LED 14
#define BLUE_LED 19
#define GREEN_LED 27
int gBright = 0;
int rBright = 213;
int bBright = 42;
int newValue = 0;
#include <LiquidCrystal_I2C.h> // Driver Library for the LCD Module
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
float wateringAmount = 0;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "auth";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "ssid";
char pass[] = "pass";
BLYNK_WRITE(V6) {
}
void setup() {
  // put your setup code here, to run once:
  Blynk.begin(auth, ssid, pass);
}

void loop() {
  // put your main code here, to run repeatedly:
Blynk.run();
if(wateringAmount == 1){
  analogWrite(GREEN_LED, gBright);
  analogWrite(RED_LED, rBright);
  analogWrite(BLUE_LED, bBright);
  
}
if(wateringAmount == 0){
  analogWrite(GREEN_LED, 0);
  analogWrite(RED_LED, 0);
  analogWrite(BLUE_LED, 0);
}
}

First of all, your void loop is a mess and you need to sort it out if you want this sketch to work well with Blynk in the long term…

Secondly, I don’t think you understand how the Blynk timer widget works.
The “1” or “0” is sent once, at the point when the transition from on to off, or off to on, occurs.

If you wish to force the current on or off value to be sent to your device at startup then you’ll need to add a Blynk.syncVirtual(vPin) command, preferably within a BLYNK_CONNECTED callback function.

Pete.

So should it be like this?

#define BLYNK_PRINT Serial
#include <analogWrite.h>

#define RED_LED 14
#define BLUE_LED 19
#define GREEN_LED 27
int gBright = 0;
int rBright = 213;
int bBright = 42;
int newValue = 0;
#include <LiquidCrystal_I2C.h> // Driver Library for the LCD Module
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
float wateringAmount = 0;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";
BLYNK_WRITE(V6) {
 
}
void setup() {
  // put your setup code here, to run once:
  Blynk.begin(auth, ssid, pass);
}

void loop() {
  // put your main code here, to run repeatedly:
Blynk.run();
BLYNK_CONNECTED();
if(wateringAmount == 1){
 ledON();
  
}
if(wateringAmount == 0){
 ledOFF();
}
}

void ledON(){analogWrite(GREEN_LED, gBright);
  analogWrite(RED_LED, rBright);
  analogWrite(BLUE_LED, bBright);
}
void ledOFF() {
   analogWrite(GREEN_LED, 0);
  analogWrite(RED_LED, 0);
  analogWrite(BLUE_LED, 0);
}
BLYNK_CONNECTED() {
// Your code goes here

Blynk.syncVirtual(V6);
}

No, remove the BLYNK_CONNECTED command from your void loop.

Pete.

So where should I put it?

Nowhere!
The BLYNK_CONNECTED callback function is triggered automatically by the Blynk library when the device connects or re-connects to the Blynk server.
You shouldn’t be calling the function directly.

Pete.

So what do I want to do to make it work?
please help

Delete this line from your void loop…

Pete.

still doesn’t work

What are you doing to test this, and what results are you seeing?

Pete.

Wait it may work but I set wrong time. What’s the server’s time?

Setting time and seeing if LED’s are on but not sure if the time is right.

If it’s +1 GMT then something is not OK and i think it is +1 GMT

If you want to be able to set the time zone then you need to use the Time Input widget.

Pete.

But zone is ok

So why isn’t this working?

I have no idea what is and is not working for you, as you’ve not shared your testing methodology or results, all you’ve done is ask one line questions.

Pete.

Well, I did

That’s not really a methodology is it?

Pete.

So what is?