fbpx

ESP8266 Mode

 ESP8266 works in Three modes.STA (Station Mode), AP (Access Point Mode), STA + AP.

Station Mode

Station Mode allows the esp8266 to connect with other networks over wifi.

Access Point

Access Point Mode allow the other device to connect and access the internet over wifi.

STA + AP

ESP Allow Both Station  Mode and Access Point at the same time. 

  Esp8266 –  Access point

In Access point mode esp8266 12e act as wifi modem, other devices can connect and access the data. The following program helps to create a wifi network with no internet access.

 Program

  #include <ESP8266WiFi.h>
   const char *UserName= "ESP_AP";
   const char *Password = "itsme";
   void setup()
   {
     WiFi.softAP(UserName, Password );
   }
  void loop()
   {
    } 

Esp8266 –  Station Mode

In Station Mode Esp8266 allow connecting with wifi network based on network username and password provided in code.The following program helps to connect with the wifi network and get the IP address of esp8266 and print it in the serial terminal.

Program

 #include <ESP8266WiFi.h>
 const char *Wifi_Name= "your__username";
 const char *Password = "your__password";
 void setup()
 {
   Serial.begin(115200);
   delay(10); // We start by connecting to a WiFi network
   Serial.println();
   Serial.println();
   Serial.print("Connecting to ");
   Serial.println(Wifi_Name);
   WiFi.begin(Wifi_Name, Password );
   while (WiFi.status() != WL_CONNECTED) 
    {
      delay(500);
      Serial.print(".");
    }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}
void loop()
  {
  }

 

Leave a Reply

Your email address will not be published. Required fields are marked *