Esp8266 connect WIFI without hard coding credentials (SSID, Password)
Suppose you have built an excellent and innovative IOT device using node MCU or esp8266 but you have hard-coded the credential such as a SSID or password it will work fine if the hard-coded network is available but if for some reason you take your project to somewhere else and the hard-coded network is not available then your IOT device will be useless then you will have to change the SSID and password in the code that means you will have to upload the code again but remember the credentials are case sensitive so you have to be very careful if you want to save some extra time as the uploading and the changing of the code is already going to take some time so that can make you frustrated but wait I have a solution for you so in this video.
I am going to explain how to program an IOT device in such a way that can run anywhere and you will not have to worry if the network credentials are changing because you will not have to change the credentials in the code precisely we will be writing code for two types of portal first will open whenever network is not available and hence called auto-connect portal and the another is on-demand which you can use and put this on any button function so you can push the button and the config portal will be there and you can change the password or SSID easily before starting I want you to subscribe and press the bell icon so you can get update whenever I upload a new video and I want you to write in comments that how you are going to use this project let's get started the first thing you have to do is go to tools and then in library manager we are going to download the Wi-Fi manager library by Tpzau au so we can get a nice and beautiful HTML config portal.
So, let's do it by finding it and once you have found it click install once installed close the library manager now let's write the code for auto connect config portal we will start by importing the libraries we will be using these four libraries and then serial.
Begin line will help us to see the values on the console we will make an object of the library Wi-Fi manager so we can use it and then we will use auto connect command to open the portal if the network is not connected we will have to give the access point name so you can connect with Node MCU and then we can print anything to check if we are connected with the Internet and that's it these few lines of code can help you a lot upload and save the file and uploading will take some time let me fast forward it once you have uploaded the code you will have to go into wi-fi's and you will have to search for your access point for us the access point was high voltages.
We will have to connect it and once you are connected you can see on serial monitor that a browser will be opened and it will direct us to the config portal we can click on configure Wi-Fi and we can scan the available networks we can select any and we will enter the password and we will press save and that will be saved and in seconds you will be connected to the Internet you can verify this by serial console this is the second part of this video now we are going to program on-demand config portal all you have to do is to connect a push-button on pin D2 as we will be using a push button to open a config portal we will start similarly by importing four libraries and then we will define the push-button serial.
Begin line will help us to use the console we will define the button as an input please note.
That the push-button will be connected in pull up configuration then in the loop body we will put a condition that if a button is pushed that means there will be a zero value (LOW) then we will make the object of the Wi-Fi manager class.
And then we will put this code for the on-demand config portal now save the file and upload the code once uploaded open this serial monitor and you will observe that when you push the button the conflict portal will be opened you can see this on the serial monitor and then you can connect the access point and open the config portal and change the credential as many times as you want just push the button and config portal will be ready and you can change the password or SSID so that's it for now thank you for watching and please like share and subscribe for more such videos.
Course Creation Warrior
https://warriorplus.com/o2/a/dhlwv0j/0
Download $597. of Pro Marketing Software Free!
https://www.coolmarketingsoftware.com/a/aff/go/betonzi54



