-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Connection keeps droping when ESP8266 set up as an access point #1615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I have installed Arduino version 1.6.5 just to make sure there wasn't any conflict with the IDE and I still have the same issues |
@vitorsilvalima
here a testing sketch to see the issue
|
Oh, sorry, forgot to mention doing an |
Ok, I've done some basic investigations, hoping some SDK's guru will be able to help us to understand. I've done a sketch that switch Wifi autoConnect parameter back and forth using NodeMCU board flash button, pushing button toggle on and off. But as changing autoConnect in loop does nothing (SDK says) so on each change I reboot the board. But there is a 2nd point, all I've just written is true only if you call Note also that ESP.eraseConfig() preserve autoConnect flag ;-) Here is the sktech used
|
Hi Hallard, I just tried to test your code here and it just says the following: WifiIssue:48: error: 'class ESP8266WiFiClass' has no member named 'getAutoConnect' Which version of the library are you using because mine has no getAtutoConnect function? |
I'm using IDE 1.6.7 + Latest git version of Arduino-Esp8266 getAutoConnect has been committed on Dec 29th |
I see. I just installed it but now I've got another problem. The code of your sketch somehow is making my NODEMCU 1.0 restart forever even when I upload any other sketch to the board. The following characters is what I'm getting and they don't stop coming through. |
Actually, this is what I'm getting from the board: |
Do you still have the same problem with other example sketch ? |
Yes, I still have this same error with any other sketch now. What may have caused this issue? I have never seen it before Sent from my Samsung device -------- Original message -------- Do you still have the same problem with other example sketch ? Reply to this email directly or view it on GitHubhttps://github.com//issues/1615#issuecomment-182400644. |
Corrupted SDK Config by certainly flashing same device with different flash size between two flash (or sometime just changing board type) |
I got my board working again by uploading the blink sketch using Arduino version 1.6.5 and ESP8266 version 2. And somehow the other loose connection issue seems to have gone away. void setup() |
I think all of this cleared the "wrong thing" stored in by the SDK. So my point point of view is, until you're not connecting your device to a Wifi network, it will continue working fine. |
Hi Hallard, I have just tested uploading an example that connects to the WIFI router and it worked fine and then I upload another example which configured the board as an AP and it also worked fine with pretty good ping results. It is hard to tell what was going on, we may have to read the SDK and try to see what is going on. However, I don't think SSID and PASSWORD are stored directly into the flash memory because it is only used at run time. Moreover, I believe nothing would change the flash memory in an explicit way. We really need to go over that sdk doc and check just to make sure. I will try with my other boards and see if they still have the connection issue and I will let you know. Nevertheless, thank you for your help. |
*implicit way |
@vitorsilvalima |
Okay, thank you. |
I see there is no activity on this topic since february. I am here via google because I was trying to figure out a series of anomalous events that sound a lot like what's happening here. In particular, I have had three different wierd situations where a sketch with no password and ssid still connected to the same AP that the device had previously been connected to. In another instance, the device was running code in STA mode with no mention of AP mode or a network name etc and yet I was able to connect to its AP (after discovering it unexpectedly in a netscan) - so in otherwords I first loaded a sketch that created an AP named "MyAP". I experimented some and decided to do some other experiments and the AP reappeared/remained remained even after I uploaded a new unrelated sketch (which was in fact simultaneously working correctly as a wifi client to my regular router) There is some really strange stuff going on with what gets saved by the SDK and I think sometimes stuff that was previously saved (silently by the SDK) then gets used accidentally when the parameters to the SDK information results in some subsequent error/failure to connect - even in independent, unrelated sketches. Anyone able to add anything or point to something useful now? TIA |
Hi GUys, I have ben asking on esp8266.com about this very same thing. Any answers yet? Mine is the same...in dual mode, when ,my home's router gets turned off, the AP mode becomes completely unreliable. Regds Paul |
@igrr can you maybe shed some light one this? Do you have example code of how we can run dual mode STA and AP ? The problem is that when the STA mode cant find a decent AP to connect to the system hangs terribly. .setAutoConnect(false) may be an option but then how would we code to restart the system? An example would be nice! Regds Paul |
Here what I do in every sketch that need AP mode and STA was unable to connect
|
HI @hallard Thanks for this, but this still does not mean that the ESP is operating in dual mode. It means you need to chose between AP or STA mode. Or have I got it wrong? I am trying to write a sketch that allows my Android app to connect to the ESP's AP every 30 secs , AND for the ESP to send out data via the internet every minute. It works fine whilst the router in my home is on, but the minute I turn the router off, the AP side of things hangs up with monotonous regularity. Somehow, somewhere, in the brains of the SDK there must be something that hangs up when it cannot find the router in STA mode. I have literally tried every means to disable/re enable, etc the WiFi, but there is absolutely nothing that is solving this. |
In my experience the AP is fairly unstable if the STA is trying to reconnect. If it had connection and then doesn't it will do a scan every second, and try to reconnect, which i assume causes too much time to be spent away from handling the main stuff / AP stuff. You can see if this is happening by enabling the WiFi debug. I think i've made it try to reconnect for 2 mins then disable it, then enable the AP, so that it can work properly. |
I believe this is because soft-AP and STA are using single hardware channel, If STA reconnects using another channel, then soft-AP has to adjust accordingly. ref. http://bbs.espressif.com/viewtopic.php?f=10&t=324, Case 2 |
Hi gents. Thanks for this. Yes. I think the only option is to have 2 esp's side by side. One acting as ap and another acting as a sta. Thanks again! |
I have been suffering this problem, too. I believe the reason is case 3 in http://bbs.espressif.com/viewtopic.php?f=10&t=324, Now I have found a (kind of ugly) way to partly solve it. At least now it can reconnect to the ap and the softAP is normal in most time. It is quite easy: turn off the "auto-reconnect" feature, and set up a timer to let it reconnect once in a proper() time. This is ugly, because when it is trying to connect, the softAP network TCP connection will still be broken. And it makes my web update aborted if the timer goes off when uploading, so I have to turn it off before upload. Now the ping result is like:
And the fake code is like: bool tryConnect = true;
void WiFiConnect(void *pArg)
{
tryConnect = true;
}
/*Warning: though I have disabled reconnect, it still auto-reconnect after calling WiFi.begin() once. So I have to set this event listener.*/
/*Maybe I don't need this. Please tell me :)*/
void eventListener(WiFiEvent_t event)
{
if (event == WIFI_EVENT_STAMODE_DISCONNECTED) {
WiFi.disconnect(); // Wipe the config saved
}
}
void connectWiFi()
{
if (!tryConnect) {
return;
}
tryConnect = false;
WiFi.begin(SSID, PASSWORD);
}
void setup()
{
/*others*/
WiFi.setAutoConnect(false);
WiFi.setAutoReconnect(false);
/*SDK functions. Include their head files first.*/
os_timer_setfn(&WiFiConnector, WiFiConnect, NULL);
os_timer_arm(&WiFiConnector, WIFI_INTERVAL, true);
WiFi.onEvent(eventListener);
/*others*/
}
void loop()
{
/*others*/
connectWiFi()
/*others*/
} |
I am new to this forum. I had this problem of esp8266 not connecting to access point. Here is the setup code:
|
I have the unstable connection with esp in AP mode when I connect to it via laptop or iPhone, but the connection is fine with my galaxy phone! Any suggestions how to resolve this? |
I am using Arduino 1.6.7 and downloaded the WiFi AP example (never used STA mode) and having same disconnect issues. |
I was have the same problem. I just realized the wifi module on esp8266 needs enough current to make it operates perfectly. Hope it will works.. Cheers from Indonesia... |
I noticed the same problem regardless of the power: I works fine if I remove the password for the AP. That let me to think WPA2 is to costly in computation and that the esp8266 may triggers a timout in the communication. I works if I switch the clock from 80MHz to 160MHz. Is there any problem with this clock frequency ? |
Arduino won't help to clear flash when programming, need to clear flash after several re-flash. I have download a blank files into flash for clear flash. |
@moycat if you are still around, THANKS! My solution uses a pin to determine boot mode. normalBootMode = digitalRead(bootModePin);
} |
Hi guys, I have been facing some issues when I program my ESP8266/NODEMCU board as an access point. I'm currently using the Arduino version 1.6.7 and esp8266 version 2.0.0. I have tested with different sketches of mine and even with the one provided as an example(WiFIAccessPoint). I don't know why but the connection is really loose and the phone takes a long time to be able to connect to it. I have used ping tools to test sending data to the board and there is a lot of packet loss and connection timeout. The board sometimes even restarts with no reason.
What is the most interesting is that when I use esp8266 version 1.6.5 there seems to have no issues and the connection never times out.
ps: I use Fedora 23 64 bits.
The text was updated successfully, but these errors were encountered: