Photon with weak wifi signal struggles to reconnect after wifi router channel change

This is more of a bug report/issue people should be aware of.

I have several particle photons. The one furthest away from my wifi router sometimes disconnects and fails or struggles to reconnect. Sometimes it won't connect at all, or sometimes it will only connect for a couple minutes before failing for hours again. Sometimes this persists for days. And then it will magically start working again like there was never any issue. The wifi signal according to my phone was weak, -75db, but not faint.

I had attributed this to varying wifi signal strength due to weather etc. I was wrong.

This was happening because my router's automatic channel switching broke the wifi connection, and it was unable to reconnect (or unable to maintain a connection) until the router was rebooted, or the automatic channel switching landed back on the same channel it started from.

I learned of this issue from ESP8266 forums, apparently they struggle with the same issue. A strong wifi signal is fine, but if the wifi signal is weak AND the router automatically changes channels too often, it will fail to reconnect until the router is rebooted (or, in the ESP8266's case, code is added to force 802.11b mode instead of g/n).

To be clear this is not because the new wifi channel that is selected is too weak - in many cases the signal actually becomes stronger.

People should be aware of this. I had been struggling with this wifi issue for years until I told my router to stop automatically changing wifi channels, and just forced it on channel 1. Now the Photon is stable as ever.

I have had this issue through two routers - one was a Netgear WNDR3700, the other is an Asus AX58U, both decent routers.

1 Like

Hi there, I've also had issue with weak wifi signal and Photon and in some cases the Photon locks up and never returns (non breathing led). Off topic, but the solution to locks is to attach an external watchdog supervisor micro to reboot Photon is it doesn't pat the watchdog regularly.

On topic, I control the connection process completely manually using step logic, like this:

SYSTEM_MODE(MANUAL);
SYSTEM_THREAD(ENABLED);

uint32_t msStepTime = 1000; // timer used to for the connection step logic
Timer stepTimer(msStepTime, stepOK, FALSE);         // timer to step logic, was oneshot, now repeditive

//**********************************************
// Function to handle particle and Blynk connect
//
//
//**********************************************
void handleInternet(void)
{
  switch(iConnectStep)
  {
    case 0: // Switch off the WiFi
    {
      WiFi.off();
      bWifi_On = FALSE;
      bStepNow = FALSE;
      stepTimer.changePeriod(1000);
      stepTimer.start();
      iConnectStep++;
    } break;
    case 1: // wait for 2sec
    {
      if(bStepNow)
      {
        iConnectStep++;
      }
    } break;
    case 2: // Switch on the WiFi after the step timer delay
    {
      WiFi.on();
      bWifi_On = true;
      bStepNow = FALSE;
      stepTimer.changePeriod(1000);
      stepTimer.start();
      iConnectStep++;
    } break;
    case 3: // Wait one second then attempt connection
    {
      if(bStepNow)
      {
        bStepNow = FALSE;
        stepTimer.changePeriod(60000);
        stepTimer.start();
        iConnectStep++;
        WiFi.connect();
      }
    } break;
    case 4: // Wait for WiFi to be connected or 60sec timeout
    {
      if(WiFi.ready())
      {
        iConnectStep++;
      }
      if(bStepNow) // Has timed out
      {
        iConnectStep=0;
      }
    } break;
    case 5: // Connect to Particle server
    {
      bStepNow = FALSE;
      stepTimer.changePeriod(60000);
      stepTimer.start();
      iConnectStep++;
      Particle.connect();
    } break;
    case 6: // Wait for Particle connected
    {
      if(Particle.connected())
      {
        iConnectStep++;
      }
      if((bStepNow) || !WiFi.ready())// Has timed out or no wifi
      {
        iConnectStep=0;
      }
    } break;
    case 7: // Start the Blynk Authentication, with a timeout
    {
      bStepNow = FALSE;
      stepTimer.changePeriod(60000);
      stepTimer.start();
      iConnectStep++;
      Blynk.begin(auth); // Do this after we've started the timer
    } break;
    case 8: // Wait for Blynk connected or timeout
    {
      if(Blynk.connected())
      {
        iConnectStep++;
        stepTimer.stop();
      }
      if(bStepNow) // Has timed out
      {
        iConnectStep=0;
      }
    } break;
    case 9: // Process Blynk requests
    {
      Particle.process();
      Blynk.run();
      // If we lost connection to Blynk cloud or Particle then restart the process
      if((Blynk.connected() == false) || (Particle.connected() == false))
      {
        iConnectStep = 0;
      }
    } break;
    default:
    {
      iConnectStep = 0;
    } break;
  }
}

//**********************************************
// Function triggered via a timer interrupt
//
//**********************************************
void stepOK()
{
  bStepNow = TRUE;
}

I think powering down the wifi and back up again using the step logic above, might help. I don't know if the cause of my wifi issues are due to the router changing channels or not, but this might be worth a try?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.