So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By Seb123
#74296 Hey guys !
I used this library https://github.com/tzapu/WiFiManager on my node mcu .Actually the code goes something like this :
__________________________________________________________________________________________-
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
// set pin numbers:
#define D0 16 // USER LED Wake
#define ledPin D0 // the number of the LED pin
#define D1 5
#define ConfigWiFi_Pin D1
#define ESP_AP_NAME "ESP8266 Config AP"
#define password "12345678" //Password protect the configuration Access Point
void setup()
{
// initialize pin D0 as an output.
pinMode(ledPin, OUTPUT);
pinMode(ConfigWiFi_Pin,INPUT_PULLUP);

Serial.begin(115200);
digitalWrite(ledPin,LOW);//Turn on the LED
//WiFiManager
//Local intialization. Once its business is done, there is no need to keep it around
WiFiManager wifiManager;
if(digitalRead(ConfigWiFi_Pin) == LOW) // Press button
{
//reset saved settings
wifiManager.resetSettings(); // go to ip 192.168.4.1 to config
}
//fetches ssid and password from EEPROM and tries to connect
//if it does not connect, it starts an access point with the specified name
//and goes into a blocking loop awaiting configuration
wifiManager.autoConnect(ESP_AP_NAME,password);
while (WiFi.status() != WL_CONNECTED)
{
delay(250);
Serial.print(".");
}
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
digitalWrite(ledPin,HIGH);
}
void loop()
{
digitalWrite(D0, HIGH); // turn off the LED
delay(2000); // wait for two seconds
digitalWrite(D0, LOW); // turn on the LED
delay(2000); // wait for two seconds
}
------------------------------------------------------------------------------------------------------------------------------------------
This code is really cool it basically set's up an interface on the default ip that lets you enter your wifi credentials and connect to the network.It also magically picks up any ssid or password that you may have used earlier.
----------------------------------------------------------------------------------------------------------------------------------------------------------
1.when your ESP starts up, it sets it up in Station mode and tries to connect to a previously saved Access Point
2.if this is unsuccessful (or no previous network saved) it moves the ESP into Access Point mode and spins up a DNS and WebServer (default ip 192.168.4.1)
3.using any wifi enabled device with a browser (computer, phone, tablet) connect to the newly created Access Point
4.because of the Captive Portal and the DNS server you will either get a 'Join to network' type of popup or get any domain you try to access redirected to the configuration portal
5.choose one of the access points scanned, enter password, click save
6.ESP will try to connect. If successful, it relinquishes control back to your app. If not, reconnect to AP and reconfigure.
--------------------------------------------------------------------------------------------------copy pasted from the github page of lib.
My problem arises when I am uploading some other code that does not require this feature i.e. the node mcu goes into station mode even when the code I uploaded in it does not have the commands to do so .
Hope you can help me out :)
Thanks guys.....