Author Topic: Can OAK re-connect a lost wifi connection?  (Read 2801 times)

ScottM

  • Newbie
  • *
  • Posts: 41
Can OAK re-connect a lost wifi connection?
« on: January 08, 2017, 02:07:55 pm »
I have a couple of OAKs monitoring doors around the house. A problem that seems to come up is that the OAK will go offline, and I have to reset it manually (via Pin 1) and re-connect to the wifi signal. Is there any way to have OAK re-connect to wifi on its own? One of my boards is up in a ceiling and not fun to access. At this point, I cannot rely on my OAKs to always be working as I need them to be.

PeterF

  • Hero Member
  • *****
  • Posts: 881
Re: Can OAK re-connect a lost wifi connection?
« Reply #1 on: January 08, 2017, 04:25:46 pm »
So they actually forget the WiFi config... or do they lock up, and just need power cycling? I'm afraid I can't suggest anything if they are just randomly loosing the config. If they are just loosing the connection, it should be possible to add some monitoring code that automatically restarts the WiFi if the connection is lost, but the Oak should try to do that itself also depending on which SYSTEM_MODE it's in. I have two Oaks that are on 24x7, and they manage to reconnect every week when my WiFi reboots itself.

ScottM

  • Newbie
  • *
  • Posts: 41
Re: Can OAK re-connect a lost wifi connection?
« Reply #2 on: January 09, 2017, 05:32:18 pm »
Power cycling doesn't solve the problem. Is there any way an Oak can tell you what wifi network it's connected to?

PeterF

  • Hero Member
  • *****
  • Posts: 881
Re: Can OAK re-connect a lost wifi connection?
« Reply #3 on: January 09, 2017, 11:15:06 pm »
That doesn't sound good! So it shouldn't have gone into safe mode, as that is supposed to only trigger once IIRC... making it sound like it really has lost it's wifi config?  ???

I'm afraid I don't know if there is a way to make the Oak report it's currently configured AP... I've been able to get things out of it like IP, but not the connected/configured AP - other than via skimming the config blocks of the memory... but I don't know if that will give anything meaningful in this case?

PeterF

  • Hero Member
  • *****
  • Posts: 881
Re: Can OAK re-connect a lost wifi connection?
« Reply #4 on: January 18, 2017, 06:20:47 pm »
Hey Scott,

I don't know if you saw the discussion going on elsewhere in the forum, but digi_guy pointed out that WiFi.SSID() works on the Oak, so you can possibly do some code that displays the return from that, to see if the your Oaks are somehow completely forgetting what WiFi AP they are supposed to be connecting to.

I'm using code like this on a 2.2" TFT LCD connect to one of mine (borrowing heavily from what digi_guy wrote), so


Code: [Select]
   
    tft.setCursor(0,290);
    tft.setTextColor(ILI9341_WHITE);   tft.setTextSize(2);
    tft.println(WiFi.SSID());

    char myIpString[24];
    IPAddress myIp = WiFi.localIP();
    sprintf(myIpString, "%d.%d.%d.%d", myIp[0], myIp[1], myIp[2], myIp[3]);
    tft.print("IP: ");   
    tft.println(String(myIp[0])+"."+String(myIp[1])+"."+String(myIp[2])+"."+String(myIp[3]));

It wouldn't be to hard to modify that so it can be output via Serial, and see if the Oak even knows which WiFi network it is supposed to be connecting to, and if it is able to acquire an IP address.