NOTICE: If you encountered problems in compiling the code, see this updated video.
ESP8226: https://youtu.be/NLRuqjhArg8
ESP32-CAM: https://youtu.be/TTdMKW6HhXM
Have you met this problem before? You were making an fantastic Arduino IoT project. However, in the code, Wi-Fi SSID and Password were hard-coded and the only way to change these is to edit the code and re-upload the code to Arduino. At home, this is okay, since you were experimenting things here and there anyway.
Let’s say you bring this project to a friend place or a venue to demo. And you didn’t know the Wi-Fi SSID nor the password beforehand. Then, you need to bring your computer to change SSID and password and re-upload to Arduino.
Is there a way to get rid this problem? Yes. The answer is use Arduino Wifimanager library.
Start
Open Arduino IDE. From Tools and select Manager Library
in space here type Wi-Fi Manager to search
Arduino IDE will filter keywords with Wi-Fi manager. Scroll down until you find a Wi-Fi manager by author Zabu. The current version 0.14 just click and install. Ok, install completed. Click close.
Upload "Auto Connect" sketch to NodeMCU
Next, let's get a Wi-Fi Manager code. example from Files-> Example, scroll down and find Wi-Fi manager. Let's open "Auto Connect" in a new window.
In the "Auto Connect" code., let's not make any change and upload this code directly to NODEMCU to understand how it worked.
Now, let me compile the code and upload this code to my NODEMCU Compiled sketch.
This will take a while depending on your computer configuration. You can see the progress bar is showing here it's uploading the flashing LED indicates the program is uploading. Let's wait until upload complete. Okay.
Set it up on your smartphone
Upload completed. Let's look at the Arduino Serial port right now. It says: using last saved values, should be faster. Since this is a new NODEMCU and I haven't set anything to it in the program code. There's neither Wi-Fi SSID nor password setting. The "AutoConnectAP" is AP name that you could define yourself.
Let's see the serial monitor NODEMCU now acts as Wi-Fi AP named AutoConnectAP and waiting for Wi-Fi client connection. As I said this NODEMCU is now in Wi-Fi AP mode with IP address 192.168.4.1 What I need to do now is to input this IP address in a browser either smartphone or a computer. Let me enter this IP address into my smartphone browser.
Type IP here 192.168.4.1
Remember to connect the phone to NODEMCU Wi-Fi AutoConnectAP first.
Swipe down and click Wi-Fi symbol and then click AutoConnectAP from available Wi-Fi list. It's connected to AutoConnectAP.
it shows Credential saved. Let's look here NODEMCU you will now connect tostonez24 AP automatically.
Ready to go!
Okay, connection result shows connected. Great!! We have connected NODEMCU to Stonez24 AP. In the future when you visit a new place or venue, there's no need to Hard-Code SSID or password in Arduino code let Wifimanager do the hard work for you!
No comments:
Post a Comment