Go Down

Topic: no reconnection after WiFi.end() (Read 2227 times) previous topic - next topic

hku17

Hi,
I have a problem in my Arduino sketch when using Wifi.end() from the Arduino Wifi101 library and any feedback is appreciated.
I am not using the WiFi Shield but Adafruit Feather M0 with WINC1500.
The MCU usually sleeps and send data every 15 minutes to Adafruit IO via WiFi.
If I use WiFi.begin(_ssid, _pass) and WiFi.lowPowerMode()  I can regularly send data to the server via WiFi.
If I use WiFi.begin(_ssid, _pass)  and after the data transmittion I power off the WiFi with WiFi.end(), on the next data trasmission interval (after 15 minutes of MCU sleep) no data are sent to the server. I see the LED of the WiFi going on for a few seconds, as it should be.
Any idea? Below some extracts from the sketch.
I'm using latest libraries and firmware:
WINC1500 Model B,  FW 19.5.2.
WiFi101: 0.14.3
Adafruit IO: 2.6

Thanks in advance for any suggestion.

Code: [Select]

AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
const unsigned long AIO_TIMEOUT = 40000;

void AdafruitIO_WINC1500::_connect()  //this is io.connect()
{

  WiFi.setPins(WINC_CS, WINC_IRQ, WINC_RST, WINC_EN);

  // no shield? bail
  if(WiFi.status() == WL_NO_SHIELD)
    return;

  WiFi.begin(_ssid, _pass);
  _status = AIO_NET_DISCONNECTED;
  //WiFi.lowPowerMode();
}


void sendDataToIO(){

  unsigned long aioTimer = 0;
   io.connect();
  aioTimer = millis();
  while(io.status() < AIO_CONNECTED && millis() - aioTimer < AIO_TIMEOUT) { 
     io.connect();
      delay(500);
  }
 
  if(io.status() >= AIO_CONNECTED){
        io.run();
        humidityFeed->save(humExt);
  }
   delay(500); //allow wifi to finish
   WiFi.end();
   delay(5000); //allow wifi to poweroff
   
}





Go Up