WiFi Manager With ESP8266
Learn to build WiFi manager on your ESP8266 using Soft Access Point mode and Station mode.
Gather Reqired Components
List Of Hardware And Components:
- ESP8266 Nodemcu
- I2C 0.96" OLED Display
- Jumper Wire
- Breadboard
Assembling the Board
Wiring The OLED:
- SCL to pin D1
- SDA to pin D2
- VCC to 3V
- GND to Ground
Install Required Library
Library Required:
Please install the following library in the library manager.
#include <WiFiManager.h> #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h>
Upload the Sketch
//Library Involved #include <WiFiManager.h> #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); WiFiManager manager; void setup() { // put your setup code here, to run once: Serial.begin(115200); if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); for (;;); // Don't proceed, loop forever } // the library initializes this with an Adafruit splash screen. display.display(); delay(500); // Pause for 2 seconds // Clear the buffer display.clearDisplay(); //Clear previous stored data manager.resetSettings();// To reset the previous restored ssid and password data Text_Display("Disconnected", 2, 0, 20); manager.autoConnect("My-WiFi-Manager", "BobWithTech");// Format (ssid, password) Text_Display("Connected", 2, 0, 20); Serial.println("Connected..."); } void loop() { // put your main code here, to run repeatedly: } //Function for efficient text displayer in the OLED void Text_Display(String msg, int fontsz, int x, int y) { display.clearDisplay(); display.setTextSize(1.5); // Draw 2X-scale text display.setTextColor(WHITE); display.setCursor(0, 0); display.println("WiFi Status:") display.setTextSize(fontsz); display.setCursor(x, y); display.println(msg); display.display(); // Show initial text delay(20); }