BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Check connection status in loop and reconect

I’m thinking Blynk.connected will result in true, but I"m not sure, it’s easy enough to turn around, right :wink:

nope, this causes loop. as soon it connects, it disconnects and so on ;(

if(!Blynk.connected() )
{
  Blynk.connect();
}

How about this instead of using Blynk.run?

Yes, this also causes the same outout

[1150041] Connecting to blynk-cloud.com:8442```
1 Like

Weird, because I’m using it as we speak and it works like it should, with this simple piece of code:

void loop() 
{
  if(!Blynk.connected())
  {
    Serial.println("Reconnecting ... ");
    Blynk.connect();
  }
  
  Blynk.run();
  timer.run();
}

When I stop my local server it says “reconnecting”.

-edit

It’s possible to use SimpleTimer logic to build your own time-out sequence I’d reckon.

Do you have any alternative hardware?

I guess I will use a clean sketch and will add bits of code and see what causing this issue

That usually is a very good idea. I start from scratch when I make my stuff. My programs grow like a tree and sometimes you just can’t see the forest through the trees any more :wink:

1 Like

Ok, so what was done:

  • updated blynk library
  • disconnected every wire from boards
  • uploaded example sketch from blynk library to wemos d1 - no reconnection
  • uploaded example sketch frim blynk lib to arduino uno with ethernet shield - no reconnection

Everyother device reconnects to wifi router without problems.

Any ideas?

That is really weird. I’m not sure how to explain this, especially if it connects succesfully the first time, but not reconnect.

Maybe @vshymanskyy or @Dmitriy has an idea, because I’m running out. Both @Costas and myself have been using the Wemos with awesome succes. It’s the one Wifi thing which I haven’t cursed (yet … :wink: ). With latest lib and cloud service running fine for everyone else, I’m afraid I’m looking at the problem close to your home.

Can I ask what type of router you own? Maybe there’s a firmware update available? Sometimes it helps to update it.

sure, im using mi router mini with latest software for it

Hmm, that looks like a normal router, can’t seem to find any issues with it. You are probably running the original firmware for it, not some stuff like DDWRT?

If it’s possible, I’d try another router and see if that works, at least we know where your problem is that way. Maybe try the Wemos at a friends place with another router?

Yes, just switched the router - wemos reconnects. i have no idea whats going on, but the bottleneck at this point Mi router Mini. Will try to investigate whats wrong

Well, at least we got one step further :slight_smile:

Maybe the Mi can be downgraded to a previous version of the firmware? There could always be bugs of course.

yes, restoring to factory setting doesnt solve issue. will try to figure out

Hi Kongol,
in my opinion, you cannot solve the problem of the router restart dealing with Blynk. You have to deal with the router but only if the router firmware offers the possibility to reboot the router itself. In this case, as suggested by Costas, you can write a simple procedure (simple if you have a windows PC on the same router) that performs this action.
If the router firmware doesn’t have this possibility, I think that you can:

  • change the router firmaware (see gargoyle firmware on Google)
  • buy a smart switch for router (www.resetplug.com) - very expensive
  • realize the system that I suggested you at the beginning of this topic
    My system is a bit complicated because I use a pocket 3G switch with an internal battery and so I cannot interrupt the power line. But if your router is AC powered, you can use the relay to switch off and on the main line when Blynk.connected() is false.
    Ciao, Giancarlo
1 Like

@Gianca I use Gargoyle on all my routers, nice clean firmware.

https://www.wireboot.com/ have just finished their Kickstarter campaign https://www.kickstarter.com/projects/786298545/wireboot-keep-your-wifi-on-24-7-automatically-rebo/description $14 for the router reboot device.

Thanks. I know that the bottleneck is router, as I mentioned before, so I will try to set it up properly (router)

@ Costas
Wonderful !!
Any suggestion for my TP Link 3G router M5250 with internal battery?

@Gianca mine are all TP Link 3G routers but not battery powered. Have you tried to telnet into the router?

I am more of a software guy than a hardware type.

Maybe @psoro, @Lichtsignaal or others could advise a hardware solution to restart this http://www.tp-link.com/en/products/details/M5250.html battery powered router when it crashes?