I’m having trouble in timer widget, must trigger two relays at different times,
Relay 1 - 14:00 to 22:00
Relay 2 - 15:00 to 21:00
I wrote the code based on information found here in the community, but it does not work with the timer to test, I added a button to trigger the same virtual pin the timer with the button works but with no timer.
version 0.3.1 blynk
Android phone
ARDUINO + ETHERNETSHIELD
an important observation, funcinou code to the last update of APP, which was yesterday afternoon (PLAY STORE), after upgrading, the relays that were linked not turned off at the scheduled time, and after reseted the ARDUINO, the timer does not work anymore .
I’ve looked all topics on the subject tested all codes, and still does not work.
@psoro the L is for long. I have 5 SimpleTimers (as opposed to the Timer widget that @lucasAlexey is referring to) and I have L with 4 and 1 without. They all work fine. You would only need to use L if the number of milliseconds falls outside the integer range for your device.
tested tips that have been passed, but it did not work. the timer has not called digital or analog port just setting in APP, or remove and add the timer worked. as stated in each other topic, I think the problem is the timer send signal to the Arduino, remembering that I by a button on the app, the code works perfect, the pins that need to be driven work, but in "manual "I need to leave on automatic.
tested tips that have been passed, but it did not work. the timer has not called digital or analog port just setting in APP, or remove and add the timer worked. as stated in each other topic, I think the problem is the timer send signal to the Arduino, remembering that I by a button on the app, the code works perfect, the pins that need to be driven work, but in "manual "I need to leave on automatic.
@lucasAlexey modified your original sketch to work on my WeMos D1 mini and an existing dashboard I have set up. All works fine, please take a look at the sketch below including the notes.
/* test timer widget - LED on WeMos D1 mini for lucasAlexey
sketch modified to tie up with an existing dashboard I have set up
LED is on at boot up, timer on time set 11.40 and off 11.41
at 11.40 LED goes out and comes back on at 11.41, all working fine
NOTE SimpleTimer is not required and it would work with the following for V7
I don't really use digital pins in my dashboard but if you are using them you wouldn't need any code
except the ON time would give you a high on the pin and OFF would be low
BLYNK_WRITE (V7) // virtual pin 7
{
i1 = param.asInt();
if (i1 == 1)
{
digitalWrite(LA, LOW);
}
else
{
digitalWrite(LA, HIGH);
}
}
*/
#include <SimpleTimer.h>
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
//#include <SPI.h>
//#include <Ethernet.h>
//#include <BlynkSimpleEthernet.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
//#define LA 2
#define LA 4 // GPIO 4 is D2 for WeMos
//#define LB 3
int i1 = LOW;
//int i2 = LOW;
SimpleTimer timer;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "518430403ce640ef8ec1b5caae3e21d2";
void checkTimer()
{
if (i1 == 1)
{
digitalWrite(LA, LOW);
}
else
{
digitalWrite(LA, HIGH);
}
/*
if (i2 == 1)
{
digitalWrite(LB, LOW);
}
else
{
digitalWrite(LB, HIGH);
}
*/
}
void setup()
{
//Serial.begin(9600);
Serial.begin(115200);
//Blynk.begin(auth);
Blynk.begin(auth, "Office", "19651965AB");
digitalWrite(LA, HIGH);
//digitalWrite(LB, HIGH);
pinMode(LA, OUTPUT);
//pinMode(LB, OUTPUT);
timer.setInterval(2000, checkTimer);
}
//BLYNK_WRITE (2) // digital pin 2
BLYNK_WRITE (V7) // virtual pin 7
{
i1 = param.asInt();
}
/*
BLYNK_WRITE (3)
{
i2 = param.asInt();
}
*/
void loop()
{
Blynk.run();
timer.run();
}