Login Timeout with WidgetLED

I have a esp8266 running code to turn on light switches by using virtual pins
code for a button is
static WidgetLED* leds[16];

int state=param.asInt();
SwitchAndSignal(0, state);

void SwitchAndSignal(int channel, int state)
BLYNK_LOG(“Channel % d Got a value: %d”,channel,state);
SwitchPower(codes[channel] | state );
if (state>0)

void setup()
Blynk.begin( auth, “thuis_net”, “Alphubel4206”);
pinMode(12, OUTPUT); // use pin 7 to drive the data pin of the transmitter.
pinMode(13, OUTPUT);
while (Blynk.connect() == false) {
// Wait until connected

for (int i=0; i<16;i++)
leds[i]= new WidgetLED(i+16);

everything works fine when not updating the WidgetLED. However when updating the WidgelLED, it switches fine, but most of the time it shows Login timeout when updating the led. After a while it does update but on the android app I see that the esp8266 disconnects from the network for a short while.

What could be the cause?

ok ,I think I have it solved. The time spend in the SwitchPower was quite long. After reducing that it works a lot better

@alexlinno Hi! I have the same promlem.
Could you tell, please, how did you solve this trouble?


I just reduced the time spent in the BLYNK_WRITE.If you do something that takes some time it seems you should perfrom it outside the BLYNK_WRITE function. Instead of doing stuff in the BLYNK_WRITE, you can just set a flag and do the action required outside the BLYNK_WRITE function. You can either just a flag in the BLYNK_WRITE and then in a timer based function perform the action. Depends at how fast you want your app on the targetto react. But normally since time from your phone app to the code on the target not guaranteed anyway , you could just have a 1 second timer than does the job. It helped for me.

@alexlinno thanks a lot! I’ll try it.