Introduction
Connecting devices to the internet wirelessly can be tricky, especially for small gadgets. ESP8266 and ESP32 chips solve this by offering built-in WiFi, making it easier to add internet access to many projects.
Imagine a walkie-talkie that can either join a big group chat or start its own chat room for friends nearby. The ESP8266 is like a simple walkie-talkie that connects to one group, while the ESP32 is a more advanced one that can also talk to other devices using Bluetooth and handle more complex conversations.
┌─────────────┐ ┌─────────────┐ │ ESP8266 │ │ ESP32 │ │─────────────│ │─────────────│ │ WiFi 2.4GHz│ │ WiFi 2.4GHz │ │ Station/AP │ │ Station/AP │ │ Basic Sec. │ │ Enhanced Sec│ │ │ │ Bluetooth │ └─────┬──────┘ └─────┬───────┘ │ │ │ │ └───────WiFi Modes───┘
WiFi.begin() function on ESP8266 and ESP32 devices?WiFi.begin() is used to initiate the connection process to a WiFi network by providing the network credentials.WiFi.status() checks connection status, WiFi.localIP() gets IP, and disconnecting uses WiFi.disconnect().WiFi.status() returns the connection status, and WL_CONNECTED means connected.WiFi.connected() does not exist, WiFi.begin() starts connection but doesn't return boolean, and WiFi.localIP() returns IP object, not a number.WiFi.begin("MySSID", "MyPass");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
Serial.println(WiFi.localIP());WiFi.status() returns WL_CONNECTED, meaning connection is successful.WiFi.localIP()Serial.println().WiFi.begin("HomeNetwork", "password123");
if (WiFi.status() = WL_CONNECTED) {
Serial.println("Connected!");
}WiFi.status() == WL_CONNECTED after retry loop, meeting requirements.Pass the test and this pattern moves unknown