0
votes

I'm using an ESP8266 in access point mode to send it some data (wifi credentials) from a mobile app via HTTP. The access point init code is very simple:

IPAddress apIP(10, 10, 10, 1);                      
IPAddress subnet(255,255,255,0);                   
WiFi.softAPConfig(apIP, apIP, subnet);
WiFi.softAP(ACCESS_POINT_NAME);     // No password requird

What I find is that sometimes the mobile phone connects to the ESP's network seamlessly, and other times seriously struggles (rejects the connection, or takes > 3 mins to connect).

Questions are:

  1. Are there issues with this code that could make a connection to the ESP by a client temperamental (sometimes fine, other times not)? Like should I change the WiFi channel from 1? Are the static IP/Subnet mask creating issues?
  2. Is the issue likely hardware related - i.e. sometimes the client gets a good wifi signal from the ESP, sometimes not?
1

1 Answers

0
votes

If anyone else faces this, I found a large performance improvement from doing the following:

  • Removing DNS
  • Reseting the WiFi config
  • Explicitly setting the module to AP mode - this is referenced by this Github issue comment. This seems to be the primary driver of improvement.

So the code is now:

// Set up WiFi mode [Improve AP stability - no dual STA mode]
ESP.eraseConfig();
WiFi.mode(WIFI_AP);

IPAddress apIP(10, 10, 10, 1);                      
IPAddress subnet(255,255,255,0);              
WiFi.softAPConfig(apIP, apIP, subnet);
WiFi.softAP(ACCESS_POINT_NAME);     // No password
WiFi.printDiag(Serial);

The reasoning is that while in STA mode, the ESP may channel hop (depending on the environment), and the AP gets pulled with it. So any client connected before the channel hop will have to reconnect.