I agree. The topic kind of lost momentum since it seems I was the only one really having this particular problem. Never could get it to work properly after a certain point in the day. Really frustrating. Lots of helpful advice on things to check by the other members so I defiantly appreciated that, but at the end of the day nothing really worked.
Below is the sketch that I used to test the problem. Basically a timer widget and a momentary push button widget. Both are also linked to LED widgets so that I know when they are on. When the timer goes off the LED illuminates, same for the push button so that I can check it anywhere. Also sends it out to the serial monitor too if needed. See if you can make anything of itā¦I kind of gave up on it and only using it in the morning for my particular application. All this was a couple of months ago so not sure if the current updates fixed anything or not. Let me know if you figure anything out.
> /*
> Timer test - (Last modified 4/23/16)
> Created to show the timer wasn't working properly on my system.
> Arduino 1.6.8
> ESP8266 package version: 2.2.0
> Board: Generic ESP8266 module
> Blynk version: 0.3.4
> Blynk App: 1.11.0
> */
> #define BLYNK_PRINT Serial // Enables Serial Monitor
> #include <ESP8266WiFi.h> // Library for ESP8266 WiFi
> #include <BlynkSimpleEsp8266.h> // Library for ESP8266
> char auth[] = "22*********************95"; // Blynk auth token
> int pinState4; // Declare global int variables
> int pinState5;
> int ledBright14;
> int ledBright15;
> WidgetLED led14(V14); // Define LED widget on Vrt. pin 14
> WidgetLED led15(V15); // Define LED widget on Vrt. pin 15
> //SETUP FUNCTION
> void setup()
> {
> pinMode(4, OUTPUT); // Phy. pin4 to output
> pinMode(5, OUTPUT); // Phy. pin5 to output
>
> Serial.begin(9600); // Serial monitor
> Blynk.begin(auth, "**********2", "7***********************C"); //SSID & Pass home
> }
> BLYNK_WRITE(V4)
> {
> pinState4 = param.asInt(); // Assign integer var to V.Pin value
> ledBright14 = pinState4*255; // Define LED brightness (1 or 0)*255
> BLYNK_LOG("(V4) value: %i", param.asInt()); // Send (V4) value to serial monitor
> digitalWrite(4, pinState4); // Write (V4) value to physical pin 4
> led14.setValue(ledBright14); // Send LED widget brightness value V14
> }
> BLYNK_WRITE(V5)
> {
> pinState5 = param.asInt(); // Assign int var to V.Pin value
> ledBright15 = pinState5*255; // Define LED brightness (1 or 0)*255
> BLYNK_LOG("(V5) value: %i", param.asInt()); // Send (V5) value to serial monitor
> digitalWrite(5, pinState5); // Write (V5) value to physical pin 5
> led15.setValue(ledBright15); // Send LED widget brightness value V15
> }
> //MAIN LOOP
> void loop()
> {
> Blynk.run(); // Main Blynk function
> }
Please see the first post. I believe that one posted is the example file? The code that I just posted added functionality to test some of the suggestions that the other members made. It allows you to see when the timer / button widgets go high with a LED widget, a physical pin, and the serial monitor if it is connected to the computer.
To summarize, the project consists of a timer widget, a push button (momentary) widget, and (2) LED widgets. The app is set up so that when either the timer widget or the push button widget go high a corresponding LED widget and a physical LED go high so that you can see what is going on. If the ESP8266 is connected directly to the computer it will show the values on the serial monitor.
When it is working properly the timer goes high and turns the LED widget on (or to 255 brightness) and simultaneously drives a physical LED on the board to high. At the end of the timer interval it goes off and as you would expect the LED widget goes off and the physical LED goes off. The push button works the sameā¦hold it down and both the LED widget and physical LED go on and off. It seems pretty responsive in that the delay between when things get switched on and off is probably less that 500ms at most. I generally test the timer by setting it for example to āonā at 6:00:00 AM and āoffā at 6:00:30 AM or some other short interval (usually 20 or 30 seconds).
Everything works fine up until 5:00:00 PM. (Iām in the Pacific time zone). It took me a couple days to figure it out, but I basically started testing in on the hour every hour until the timer stopped working. So when the timer is set to āonā at 4:59:00 PM and off at 4:59:30 PM it works fine. If I try the same thing at 5:00:00 PM and 5:00:30 it doesnāt. The weird thing is that the push button works fine all day no matter what the time. The timer widget will not work all evening until sometime early the next morning. I think it starts working sometime before 4:00 AM but I havenāt tried to figure it out for obvious reasons.
So to respond to your suggestions:
I did try the simplest example - see the first post. Added extra functionality to only to troubleshoot.
Not sure how to answer thatā¦it works fine most of the day so confused as to why it stops working precisely at 5:00 PM and will not work until early the next morning.
When you say local server, is that like sending the output to the serial monitor or do you mean using the Blynk debug set?
5:00:00 PM was just the time that I determined that the timer widget stopped working for me during testing. Same time every day. Not sure what the significance of that time is, although it seemed odd that it was right on the hour.
Iād be happy to answer any more questions or try and suggestions. Iāll try it again this evening after I send thisā¦havenāt played around with it in a couple of weeks because I sort of gave up on it.
@bhusum and @Dmitriy originally I missed the references to āPACIFICā time.
I guess there are 2 Pacific times relating to daylight saving time i.e PST and PDT.
Like many computer systems Blynk uses UTC which is the time in Greenwich, England without messing around with daylight saving time.
So what time is 5PM PST in UTC? It is 00:00 !!!
As an amateur coder Iām guessing the 00:00 UTC time is not being handled correctly somewhere along the lines.
Midnight is a strange time in computer coding terms as you pass from 23:59 to 00:00 (nothing). Presumably there is some check for when a new day starts but to be honest none of my timers straddle zero time.
To test zero time with the Blynkās Timer widget I believe Brits would currently be looking at a clock time of 1am and 3am for Russians in Moscow (and myself in the Eastern Med). When I previously tried to check for the ā5PM bugā I was using local time not Pacific time.
The rollover of time probably also explains why the Timer stops working until ābreakfast timeā on the Pacific Coast i.e. when a new day starts in UTC / GMT.
Thanks for the example @bhusum. Itās pretty much what Iāve been using to test as well. And it does sound like itās a roll-over issue with the GMT time flipping. Itās currently 9:00am here and the timer widget is working great. Iām sure once 5:00pm hits it will stop working. I was planning on using this as an easy way to turn off a relay/light at night so hoping this can be resolved.
No problem. Looks like @Costas is starting to shed some light on this issue. I kind of figured it was something like that since it was happening every day at exactly the same time, but I couldnāt wrap my head around the significance of 5:00 PM in my time zone (Pacific - West Coast). The UTC explanation does seem to make sense, but Iām not really sure how all that works behind the scenes.
The other thing that I still am not comfortable with is, if it was a roll-over issue dealing with time, would it be affecting more people with their projects? Iām not sure how many people are using this widget but it would seem like there should be more people complaining if it wasnāt working right. I donāt really know, but at a minimum I will be testing the timer a little different in the future to make sure that it works over the day change in UTC. Thanks everyone for the suggestions and hopefully there will be some progress on this issue.
@bhusum I think most people are using the Timer āwithin the dayā so it would only affect people significantly West of Greenwich.
When you use the Timer Widget it doesnāt take any notice of your time (5PM), it converts it to UTCNOW as generally it is much easier to handle. The server will then be coded to turn something ON at UTCNOW + X and OFF at UTCNOW + Y.
@Dmitriy I set a Timer schedule for a virtual pin to be switched on at 3.00am (00:00 UTC) and off at 3.02am hoping it would confirm the UTC midnight rollover issue.
My logs confirm the pin did go high and low at the requested times so maybe Iām barking up the wrong tree.
Maybe the problem only occurs for Blynkers behind GMT but Iām struggling to work out what sort of coding error could cause the problem as every system rolls over to a new day based on UTC as some point during the day.
I have moved to Pacific Time now and my Android shows 14:18 on the 24 hour clock.
I have set 4 timers for 16:00, 17:00, 20:00 and 00:01. Will let you know in the morning how the timers perform.
I have an Android and itās set to 12 hour clock. Iām in Central time. (-0600)
Itās currently 4:31pm here and my timer is working fine. I need to leave for the evening but set timers for 5:01pm and 6:01pm. Iāll report back the results later tonight.
@Dmitriy when your timer failed was your system set as Pacific Time, UTC - X or UTC + X?
It is 4.24am here now but with my system set as Pacific Time the time has passed for 2 of the 4 timers I set.
4pm fine
5pm failed
So it looks like the issue has the potential to affect everyoneās system.
@ClayTonzo with your timers of 5.01pm and 6.01pm they might work ok because we are guessing the issue relates to precisely 00:00 UTC (6.00pm Central Time).
Yes, both my 5:01pm and 6:01pm timers worked fine, and my 9:00pm timer did not. I can test 7:00pm and 8:00pm tomorrow but Iām assuming they will not work since 7:00pm is 00:00 UTC. (GMT-5 since we are in daylight savings)
My 0:01 timer failed which was a little unexpected.
Set 2 new timers for 01:01 and 02:01 and they both activated.
So for Pacific Time, and probably all UTC - X locations, the timers appear to be dead between 5PM and 1AM Pacific Time (00:00 and 08:00 UTC time).
@Dmitriy I tried to search for the Timer widget code on github but couldnāt find it. Can you please provide a link so I can look through the code.
Edit: for the very observant, based on the original timing of this post it was written before 02.01 as I intended to wait until 02.02 to be sure the timer activated correctly before clicking the send / post button. I can confirm 02:01 on with 02:02 off worked as per Blynk specification.