Same Code, Multiple Devices, Local Network Failure

Hey all,

I currently have about 20 particles that I am trying to connect to the same WLAN for a project installing next week. I have been developing the code on one device at a time and finally received enough to start doing larger scale tests.

I am running the exact same code on 7 boards (only difference being the ip address assigned) and only two of them are able to connect to the network.

In my main am running this to connect:

  networks.config_creds( SSID, PW );
  Serial.println("creds configured");
  networks.config_static_ip();
  Serial.println("static ip configured...connecting");
  networks.connect();

In the networks class I am running this:

  // Connect to WiFi Network
  WiFi.connect(WIFI_CONNECT_SKIP_LISTEN);
  delay(1000);

  while(!WiFi.ready())
  {
    Particle.process();
    Serial.println("Waiting on Network");
    WiFi.connect(WIFI_CONNECT_SKIP_LISTEN);
  }

  if(WiFi.ready())
  {
    Serial.println("Connected to:");
    Serial.println(WiFi.SSID());
  }

  Serial.println("---");
  Serial.print("deviceID: ");
  String myID = System.deviceID();
  Serial.println(myID);
  Serial.printlnf("System version: %s", System.version().c_str());
  uint32_t freemem = System.freeMemory();
  Serial.print("free memory: ");
  Serial.println(freemem);

}

I have tried two different routers, to no avail. I am able to open up a serial port and see it print statements showing it’s looking for the network, although if I try particle identify I get a serial timeout error.

Any advice or where to start troubleshooting would much appreciate!

Since you seem to be using static IP, double check that you really set unique IPs on the devices which are not overlapping the DHCP range of the router (or are reserved for a particular MAC each).

Also avoid setting IPs over and over in your code. This setting is sticky, so set it only once, till you actually want to change it.

And also don’t call WiFi.connect() over and over again in your while() rather add a waitUntil(WiFi.ready) or waitFor(WiFi.ready, 60000) after the one and only WiFi.connect() call.
Calling it repeatedly while connecting will actually knock back the ongoing attempts.

1 Like