ESP8266 atuomatically connects to a network even AT+CWAUTOCONN=0

tkutluz
Posts: 2
Joined: Mon Dec 17, 2018 3:32 pm

ESP8266 atuomatically connects to a network even AT+CWAUTOCONN=0

Postby tkutluz » Mon Dec 17, 2018 4:33 pm

Hello,
I am using ESP 8266 wifi modules in industrial product for floor shop data collection.
There are around 200 devices including ESP8266s in the floor shop.
Sometimes the wifi connection to the Access Points is lost for some devices.
I try to detect the connection loss by periodically calling AT+CIPSTATUS every 30 seconds.
If a connection loss is detected i issue the at command ATCWJAP_CUR="ssid,"password" command to reconnect.
However i see that ESP modules are trying to reconnect automatically without waiting for my AT+CWJAP_CUR command.
Below is an terminal output window showing the above case.Please note that there are two APs with same ssid and same password.
AT

OK
AT+GMR
AT version:1.4.0.0(May 5 2017 16:10:59)
SDK version:2.1.0(116b762)
compile time:May 5 2017 16:37:48
OK
WIFI DISCONNECT
AT+CWMODE_DEF=1

OK
AT+CWAUTOCONN=0 //AUTOCON is 0

OK

AT+CWJAP_CUR="efatech","efatech1435" //Connected to AP
WIFI CONNECTED
WIFI GOT IP

OK
WIFI DISCONNECT //AP is switched off from its web interface and ESP is disconnected


OK
WIFI DISCONNECT //AP is switched on from the web interface and ESP automatically connected to it.
WIFI CONNECTED
WIFI GOT IP


As you see above ESP automatically reconnects as soon as the AP is switched on again even though the ATOCONN is 0.
But i do not want this behaviour.Can someone please comment on the reason for automatic reconnection.How can i diasble it.?

Best regards,
Kutlu

Her Mary
Posts: 384
Joined: Mon Oct 27, 2014 11:09 am

Re: ESP8266 atuomatically connects to a network even AT+CWAUTOCONN=0

Postby Her Mary » Thu Dec 20, 2018 5:40 pm

That's true. The ESP8266 does try to reconnect to the AP if the connection broke unexpectly. Maybe you can use command "AT+CWQAP" when the connection broke ("WIFI DISCONNECT"), to let the ESP know that you want it disconnect, then it will not reconnect again.

tkutluz
Posts: 2
Joined: Mon Dec 17, 2018 3:32 pm

Re: ESP8266 atuomatically connects to a network even AT+CWAUTOCONN=0

Postby tkutluz » Thu Dec 20, 2018 5:50 pm

Hello,
Yes I used AT+CWQAP to disassociate the ESP8266 from the AP and now it acts as expected and does not try to connect to AP automatically.
But for this to happen I need to check WIFI DISCONNECT message and issue the AT+CWQAP as soon as I receive it.
I was checking AT+ CIPSTATUS reply every 30 seconds to detect disconnections and now it is useless.
A more proper way would be to close automatic connection feature during initializing ESP at startup through AT commands.
Thanks for the support and best regards,

Her Mary
Posts: 384
Joined: Mon Oct 27, 2014 11:09 am

Re: ESP8266 atuomatically connects to a network even AT+CWAUTOCONN=0

Postby Her Mary » Tue Jan 29, 2019 5:25 pm

Maybe you can try to register the WiFi event callback by wifi_set_event_handler_cb, and do what you want when receiving the disconnect event.

Who is online

Users browsing this forum: No registered users and 3 guests