Chat freely about anything...

User avatar
By tplindley
#71208 I have a sketch that simply looks for events on GPIO2. I connect to a wireless network in station only mode and all that plus the outbound communications is working fine. My plan is to have a number of these devices (20-50) all reporting activity. The issue I am having is that they all lose connectivity at regular intervals, something just over 18 minutes. At this point I cannot just run the logic to connect back to the wireless network as that always fails. If I reboot the device, then all things are fine for another 18 minutes.

This is happening with development boards as well as the 01 chips.

Not a big deal, but I am worried about losing an event when a device has to reboot.

Thanks.
User avatar
By tplindley
#71278 Looks like the problem is the DHCP lease time. Extended that from 120 minutes, to 480 minutes and now the chips reboot every 4hrs and 15 minutes. This is an acceptable solution for me, but is there a reason that the chips can't just get a new lease without losing connectivity?

My connect logic is here, the error I get when I try and reconnect is WL_CONNECT_FAILED, I guess I could add a WiFi.Disconnect?

bool ConnectWiFi()
{
if(WiFi.status()!=WL_CONNECTED)
{
int count=0;
char temp[500];
sprintf(temp,"Connecting to WiFi [%s,%s]", ssid, password);
Log(temp,true);
WiFi.begin(ssid,password);
int retries=0;
while(WiFi.status()!=WL_CONNECTED && retries<10)
{
delay(500);
retries++;
Log(".",true);
}
if(WiFi.status()==WL_CONNECTED)
{
Log("Connected.");
Log("IP Address: ",true);
IPAddress localAddress = WiFi.localIP();
sprintf(localIpAddress,"%d.%d.%d.%d", localAddress[0], localAddress[1], localAddress[2], localAddress[3]);
Log(localIpAddress);
broadcastAddress = IPAddress(WiFi.localIP());
broadcastAddress[3]=255;
Log("Broadcast Address: ",true);
Serial.println(broadcastAddress);
udpConnected = connectUDP();
if(udpConnected)
{
getMACAddress(macAddress);
}
return true;
}
else
{
Log("NOT Connected. Resetting...");
ku_reset();
return false;
}
}
}

And this routine gets called each time I want to transmit data.
User avatar
By tplindley
#71394 Thanks for the help, will do on marking the code. Just missed that.

Will just increase the DHCP times and that should not cause an issue. I should not have more devices than what I have in the scope.

Thanks again!