I've created a code for ESP8266 12E with Arduino IDE, in which it'll operate as "Station Mode" or "Access Point Mode" on Wifi, depending on the situation. Everything works fine except when device was configured as Access Point, even when I turn off device and then turn on again and force the Wifi initialization as "Station Mode", the Access Point network keeps active.

Example: Let's suppose that I turned on the ESP8266 and initialized the Wifi as Access Point, and named the wifi network as "MY_WIFI_TEST". Let's assume now that I turned off the ESP8266 and forced it to turn on as "Station Mode". The ESP8266 typically connects to my network (the network of my gateway router, but keeps the network "MY_WIFI_TEST" active (the prior network as access point). You can not connect to this network, but it remains active.

How can I turn off or stop Access Point network?

My test code:

#include <ESP8266WiFi.h>

bool access_point_init(){
    // Access Point Mode

   IPAddress ip(192,168,1,254);
   IPAddress gateway(192,168,1,1);
   IPAddress subnet(255,255,255,0);
   char* ssid     = "myssidname";
   char* password = "12345678";

   WiFi.softAPConfig(ip, gateway, subnet);
   bool ret = WiFi.softAP(ssid, password);

   return ret;

void wifi_station_init(){

    // Station Mode

   WiFi.begin(net_ssid, net_pwd_ssid);

   IPAddress ip(192,168,1,10);
   IPAddress gateway(192,168,1,1);
   IPAddress subnet(255,255,255,0); 

    WiFi.config(ip, gateway, subnet);

   k = 0;
   while ((WiFi.status() != WL_CONNECTED) && (k < 80)){

   Serial.printf("IP address: ");

void setup() 
    bool my_condition = false;
    // my_condition = myLoadFunction();

   if (my_condition) { 
   } else {

2 Answers 2


I've already solved, by using a function of the library Wifi, specific for the connections in "Access Point" mode:

WiFi.softAPdisconnect (true);

Reference: softapdisconnect


I fixed this by adding below command before starting the accesspoint.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.