Timer Widget Acting Strangly

I’m having a strange issue with the Timer Widget that I can’t wrap my head around. I have a project that I’m running on an ESP8266 at my office with a several buttons widgets, LED widgets and a timer widget that all work like they should.

The problem that I’m having is that when I unplug and bring my ESP8266 home and re-upload the sketch with my home router SSID and password to work on it I can’t get the timer widget to work no matter what I do. I’m using the most simple sketch at this point to try and isolate the problem and I’m still baffled.

Basically I first test the sketch with a button widget using virtual pin 5 and watch the serial monitor connect to the network and display the 0’s and 1’s. See output [63349] & [63817] below the sketch. These are from button widget - not the timer widget. Once this is working I remove the button widget and replace it with the timer widget, set the virtual pin to 5, set the start and stop time, hit play, and nothing happens. If I do this same procedure on my office computer (only changing the SSID and password) it seems to work fine. What is going on?

Arduino 1.6.8
ESP8266 package version: 2.2.0
Board: Adafruit Huzzah as a generic ESP8266 module
Blynk version: 0.3.4
Last modified 4/23/16

#define BLYNK_PRINT Serial                         // Enables Serial Monitor
#include <ESP8266WiFi.h>                           // Library for ESP8266 WiFi
#include <BlynkSimpleEsp8266.h>                    // Library for ESP8266

char auth[] = "22865xxxxxxxxxxxxxxx797b95";  // Blynk auth token

void setup()
  Serial.begin(9600);                                 // Serial monitor
  Blynk.begin(auth, "Hxxxxxxx2", "7ADxxxxxxxxxEEC"); //SSID & Pass home

    BLYNK_LOG("(V5) value: %s", param.asStr());  // Send (V5)to SM.

void loop()

Output from serial monitor:

[53586] Connecting to HOME-C702
[55586] Connected to WiFi
[55586] My IP:
[55586] Blynk v0.3.4
[55587] Connecting to blynk-cloud.com:8442
[55788] Ready (ping: 1ms).
[63349] (V5) value: 1
[63817] (V5) value: 0

Some of the things I’ve tried are:

  1. Remove timer widget and replace several times.
  2. Create a new projects.
  3. Try different different Blynk versions…even the 0.3.5-beta
  4. Copy all the Arduino libraries from the office to home computer
  5. Reinstall Arduino IDE.
  6. Played around with different board setting in Arduino IDE etc.
  7. Only thing that I didn’t try was switching out another board…only because I don’t have another one yet, and it seems to work fine at my office.

Not sure really where to go from here. I’m a newbie with all this stuff so maybe I’m missing something really obvious but it is driving me crazy that it works sometime and not other times. Any advice would be much appreciated.

Timer is working. It, really strange. Do you have the latest app?

Hi Pavel-
Thank you for getting back with me. I’m running 1.11.0 on the Android app so I think that is the most current. I’ve got another ESP8266 arriving this weeks so I’ll be able to try a couple more things. Thought there might be something obvious that I was missing about how it worked so at least that makes me feel a little better. I’ll play around with it some more this week.

Re-uploaded the sketch this morning a few minutes ago (just after I wrote that reply) with no changes from last night and it works fine…happy and confused. Not sure if something was reset overnight but it seems to work now. It didn’t work for me the last couple of days so not really sure what happened. I’ll keep an eye on it to see if it happens again.

Hi Pavel-
The problem with the timer still seems to persist. I’ve been watching it for the last couple of days and seem to have found a pattern of when it works and when it doesn’t…at least on my end.

For example on 4/26/16 I checked the timer widget every hour on (or within a few minutes) of the hour starting from 6:00 AM (Pacific Time) until about 11:00 PM. Everything worked fine though out the day until sometime after 4:00 PM and before 5:00 PM where it stopped working. It did not work the rest of the evening or until about 11:00 PM when I went to sleep. I reset the timer for a start time of 4:00:00 AM and a stop time of 4:00:20 AM at it worked fine. No changes to the software of the app. Something seems to change between 11:00 PM and 4:00 AM…or maybe between the 4:00 AM/PM and 5:00 AM/PM hours of the day?

Looking back on my previous issues that I was having with the timer widget and they coincide with what I have observed the last couple of days. I.e. it seems to work in the mornings on the weekends and doesn’t seem to work when I’m checking it in the evening after work. In one of your previous posts you mentioned that you checked it and it was working…what time of day was it? Do you have any suggestions? Thanks for your patience.

Any chance your hardware was offline at timer time?

@bhusum another reason it appears not to work when you are checking the Timer as opposed to the Timer working correctly when you don’t check it occurs when your Smartphone doesn’t have accurate internet time.

Some older versions of Android don’t allow you to select internet time but as long as you manually set the time to match internet time you will be ok.

This might not be your problem but when we first tested it we got all sorts of results on our various devices when the time was wrong by just a few minutes.

With the incorrect time set on your Smartphone the Timer will trigger ‘before’ your test even begins or several minutes after you expect it to trigger and you will assume it has failed. With Timer events at 4.00 am you are generally not monitoring it so it may trigger at 3.57am or 4.05am per the time on your fast or slow Smartphone but you wouldn’t notice it.

Maybe…I do live in a pretty noisy WiFi environment. I guess that I didn’t really think it was a dropout issues because the other widgets work fine and the all seem pretty responsive. To improve my testing I added another simple button set up on the same system on a different virtual pin and it works fine the whole day even when the timer isn’t. I checked it probably 10 times yesterday evening after it stopped working with various delays and couldn’t make it trigger. I’ll try again. Thank you for the response.

Hi Costas-
Thank you for responding. That makes sense although I don’t really fully understand all the timing of cell phones works and such. I do have a pretty new mobile phone (Galaxy S7) so I would think that is not an issue with old Android software.

To respond to that last paragraph in your post, I did consider that. Since my first post, I’ve added a LED widget so that I know what state the Vpin attached to the timer is in so I know when it is triggered or not. Code snippet for that pin is below.

When the timer is working correctly I can set a trigger time of 4:00:00 PM (for example) in the 3:59:00 PM minute without any issues so I’m not sure the times are off if I’m understanding you correctly. I also tried different times before the event too…1 min, 5, min. and even 1 hr. etc too.

This is an addition to the code that I originally posted to give feedback to try and figure out what was going on. Basically it allows me to watch the state of the pin connected to the timer widget with a physical LED on the board, LED widget on the app and an integer value on the serial monitor. Works great until 5:00 PM? I can post the rest of the sketch if you want, but I didn’t want to distract anyone form the original code posted which is what I’m struggling with.

  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

With the S7 I believe your time will be ‘wrong’ unless you have specifically set it to ‘automatic’ (internet) time.

Head into Settings > Date and Time. Tap the slider to the right of “Automatic Date and Time”.

Blynk send the on / off signals based on internet time, not the time on your phone.

That is what it has been set on. I guess I ruled that out as a possibility because it works most of the day using the time displayed on my phone. Watching the time on the phone compared to when it was supposed to trigger I can’t really observe much lag time when it is working. Hardly even noticeable under most of the time…never more that a few seconds.

What is the behavior of the timer widget under the following conditions for example:

  1. Timer widget on a virtual pin is set to trigger at 3:00:00 PM and remain on until 3:01:00 PM. (Assume that the widget has been set previously and is triggering each day at that interval).
  2. For some reason the the physical device (ESP8266, UNO, etc) goes off line at 3:00:30 PM and reconnects at 3:00:45 PM.
  3. Does the virtual pin still still remain triggered when the physical device reconnects and will the app reflect that state?

The ESP / Arduino has to be online at precisely the time the on / off signal is sent. That is one reason why I recently suggested the widget be extended to be a scheduler i.e. if time is before on time do x, if it is between on and off do y and if it is after off time do z.

You would be quite unlucky to be offline during all your tests but in real life then some on and off signals will be missed with the current widget. There is a way to parse json data to turn the Timer widget into a scheduler but it is messy and many of the old Arduino’s probably couldn’t cope with the memory requirements of parsing 5000 character json streams.

I thought the same thing that eventually if the device was going on and offline you would at some point “get lucky” and catch it when it was connected. Frustrating this is that for example right now “literally as I am tying this” it works fine. I’m at the office and I can set the timer only giving it a 15-20 seconds “heads up” that I’m changing the time values and I can watch it cycle on and off flawlessly.

I’ve read some of the other posts about the ESP8266 and that sometimes using a yeild() somewhere in the code might help since there are a lot of things running in that chip at the same time. Also on the external side adding a few caps on the power/gnd pins to help stabilize things might also work.

I guess you will need to check Serial Monitor whilst at home, possibly with Blynk debug set, too see if you are being regularly disconnected from the Blynk server. Is your home internet connection a lot different (more unreliable) to your office internet connection?

I’m not sure how to quantify the reliability of the WiFi’s to compare them. Both experience disconnects from time to time. Probably more so at home but nothing that I would say is unusual. I probably should play around with that Blynk debug set before I make any more observations. I’ve never really done that… always just used the BLYNK_LOG() to sent out to the serial monitor to see if everything was working. I’ll play around with it this evening and see if I can see anything. Thanks for the suggestion.

Serial Monitor alone should be ok to see disconnections but if it is the same sketch and reliability of the WiFi is similar I’m not sure that is the problem.

I’m clutching at straws a bit here especially as you indicate the early morning Timer at home works ok. My home router has a timezone setting and obtains the actual time based on the timezone setting from global NTP servers. If I had set the wrong timezone settings my router would certainly show the wrong time but I’m not sure if it would affect my Samsung smartphone. Might be worth you checking.

1 Like

Ya me too. Usually the app indicates “ESP8266 not connected” or something of that nature at the bottom of the app when I’m disconnected. Usually see it when I flash the chip with a new sketch. Don’t see that displayed very often otherwise. Not sure if that is really a good indicator of anything or not. I’ll double check the time zone on router, although my laptop which is on the same WiFi seems to have the right time last time I checked. Other than that I’m clueless.

Hello, I’m having the same problem, I had posted a topic reporting staff tried to help but could not. the operation of my age, 10:00 to 22:00 and another from 11:00 to 21:00. Thus the timer only liagava the relay, never funcinou to shut down, tested at other times and it worked, thought to be the size range (12 hours), I moved but had no effect, only worked when I changed the end time to 20:00 one was 10:00 to the 20:59 and another from 11:00 to 20:00. is not ideal, but it was the only way to work, tested always changing minute, 20:58, 20:57, 20:59:59 (even seconds), runs after 21:00, no schedule works.

Mine stops running at precisely 5:00:00 PM. Any time after that it does not function until some point in the middle of the night. I haven’t bothered to figure out when it starts working again, but it works fine at 5:00:00 AM. There have been a couple good suggestions on things to check in this post so I would do that if you haven’t done so already.

How is this consider solved? I am experience the same problem as @bhusum. My timer for my esp8266 works fine before 5:00:00PM, but after that it won’t send any signals at all. (at least I’m assuming it’s 5:00pm. I haven’t tested the exact time but it doesn’t work at night, and works fine in the morning or afternoon). @Costas, any insight???