NodeMCU V3 ESP8266: Difference between revisions
Jump to navigation
Jump to search
Line 39: | Line 39: | ||
#include "ESP8266WiFi.h" | #include "ESP8266WiFi.h" | ||
const char* ssid = " | const char* ssid = "ChorkeMCU_2.4GHz"; | ||
const char* pass = " | const char* pass = "123456"; | ||
IPAddress local_IP(10, 19, 83, 10); | IPAddress local_IP(10, 19, 83, 10); | ||
Line 67: | Line 67: | ||
delay(1000); | delay(1000); | ||
} | } | ||
</source> | </source> | ||
Revision as of 09:59, 17 March 2020
WiFi Modes of Operation of ESP8266: There are three modes of WiFi Operation in the ESP8266 WiFi Module. Those are:
- Station Mode (STA)
- Soft Access Point (AP)
- Soft AP + Station
Station Mode
#include "ESP8266WiFi.h"
const char* ssid = "ChorkeOrg_2.4GHz";
const char* password = "academia";
void setup(void) {
pinMode(D4, OUTPUT);
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print("*");
}
Serial.println("");
Serial.println("WiFi connection Successful");
Serial.print("The IP Address of ESP8266 Module is: ");
Serial.print(WiFi.localIP());
}
void loop() {
digitalWrite(D4, LOW);
delay(1000);
digitalWrite(D4, HIGH);
delay(1000);
}
Soft Access Point
#include "ESP8266WiFi.h"
const char* ssid = "ChorkeMCU_2.4GHz";
const char* pass = "123456";
IPAddress local_IP(10, 19, 83, 10);
IPAddress subnet(255, 255, 255, 0);
IPAddress gateway(10, 19, 83, 1);
void setup(void) {
pinMode(D4, OUTPUT);
Serial.begin(115200);
Serial.println();
Serial.print("WNC Config: ");
Serial.print(WiFi.softAPConfig(local_IP, gateway, subnet) ? "Ready" : "Failed!");
Serial.println("SID Config: ");
Serial.print(WiFi.softAP(ssid, pass) ? "Ready" : "Failed!");
Serial.println("WAN Config: ");
Serial.print(WiFi.softAPIP());
}
void loop() {
digitalWrite(D4, LOW);
delay(1000);
digitalWrite(D4, HIGH);
delay(1000);
}