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. 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.
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.
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.