ESP8266 Storing Wi-Fi Settings In Flash Auto-Switch AP/Station Modes | Arduino (Mac OSX and Windows)

  Переглядів 42,473

datasith

datasith

День тому

• Your support helps me post videos more frequently:
/ acrobotic
www.paypal.me/acrobotic
buymeacoff.ee/acrobotic
BTC: 1ZpLvgETofMuzCaKoq5XJZKSwe5UNkwLM
==========
• Find me on:
/ acrobotic
/ acrobotic
/ acrobotic
==========
• My shops:
acrobotic.com/shop
amazon.com/shops/acrobotic
==========
• Description:
Another fantastic feature of WiFi-capable microcontrollers is the ability to either connect to a wireless network (Station mode) or creating their own (Access Point mode). In a previous video ( • ESP8266 Wi-Fi Modes: S... ) we saw how both modes work.
In this tutorial I show how to build an application that switches between the two. I give the user the option-via a web interface- of inputting her or his Wi-Fi credentials, storing them in flash memory (using the SPI Flash File System), and using them to access a network.
If no Wi-Fi credentials are given, or if the network is not available, the ESP8266 creates its own that we can access to enter the web interface.
==========
• Related vids:
Getting started with the WeMos ESP8266 Development Board using Arduino: • Getting Started | ESP8...
==========
• Project parts:
ACROBOTIC WeMos Development Kit for ESP8266:
acrobotic.com/products/acr-00027
amzn.to/2PBK2KE (affiliate)
ACROBOTIC WeMos D1 Mini V2 Development Board for ESP8266:
acrobotic.com/products/acr-00017
amzn.to/2D3KiA6 (affiliate)
==========
• Project code:
Firmware for the Arduino IDE:
File → Examples → ArduinoOTA → BasicOTA
github.com/acrobotic/Ai_Tips_...
As mentioned during the video, there's an excellent library that makes to configure Wi-Fi settings on the ESP8266.:
github.com/tzapu/WiFiManager library
==========
• Tutorials:
Detailed guide for getting started with the ESP8266 Development Board:
learn.acrobotic.com/tutorials...
==========
• Music:
andyclassical (audiojungle.net/user/andyclas.... Envato's Music Standard License.
==========
#ESP8266 #Arduino #Tutorial

КОМЕНТАРІ: 117
@afonsusmuralha
@afonsusmuralha 5 років тому
Your content gets better every day! Keep up the good work!
@datasith
@datasith 5 років тому
Afonso, thanks for the kind words! As people say, practice does make things easier :)
@mmusa2022
@mmusa2022 3 роки тому
I'm learning this from one month and today I got the correct detailed and step by step explained video thank so much ...
@Gerrit4A
@Gerrit4A 4 роки тому
Thanks for being so thorough. You are the easiest to follow along. Great Job.
@datasith
@datasith 4 роки тому
thanks for the kind words, gerrit! i'm glad you found the info useful!
@ibraheemmehar5647
@ibraheemmehar5647 3 роки тому
I have just started learning about hardware programming and Arduino and your tutorials are very helpful, thank you for making these tutorials
@datasith
@datasith 3 роки тому
I'm super glad that you found them helpful, thanks so much for letting me know!
@viperone1000
@viperone1000 3 роки тому
Excellent work!! Thank you so much for this tutorial.
@TheDarkitox
@TheDarkitox 3 роки тому
I thank you greatly for this video, it was exactly what I needed to adapt to my project, since I see you're form latin America too: Muchas Gracias!!!!
@heylookatusproductions6671
@heylookatusproductions6671 4 роки тому
Your video is by far the best I have seen. I love this. Thanks for your hard work.
@datasith
@datasith 4 роки тому
Thanks so much, it's been a learning process for me as well to produce video content. It makes me happy you found it useful!
@neilvermeulen5283
@neilvermeulen5283 5 років тому
Thanks mate. You answered a question that's been bugging me for a while.
@datasith
@datasith 5 років тому
Hey, Neil. Glad to have you back! I'm glad it helped you out, but remember if you get stuck to either shoot me an email or ping me on Social Media (Twitter or the YT community tab, preferably!).
@arduinomaker7210
@arduinomaker7210 3 роки тому
I just subscribed your channel. Great work!!!
@drummerclint
@drummerclint 2 роки тому
Great video! Down and to the point! I appreciate that!
@CraftyOldGit
@CraftyOldGit 3 роки тому
Very helpful, thanks. It would have taken me days to work that all out for myself.
@rodinsuniga5549
@rodinsuniga5549 5 років тому
thank you for this video! this is what I've been looking. For my Capstone project. thank again. already liked and subscribed to your channel.
@datasith
@datasith 5 років тому
Oh, awesome! Thanks for the sub, I'm glad you found the content useful!
@carlosaciegoit
@carlosaciegoit 4 роки тому
You're great man!!! Thanks for this video!
@datasith
@datasith 4 роки тому
Thanks so much for the kind comment. I'm glad you found the video useful!
@ManiKandan-hw6tj
@ManiKandan-hw6tj 3 роки тому
Thanks you so much brother. your doing great
@AndreaSantopietro
@AndreaSantopietro 3 роки тому
Davvero complimenti. Bravo bravo bravo.
@joaquimrs13
@joaquimrs13 3 роки тому
Well done!!!
@samsoft_dz
@samsoft_dz 4 роки тому
Thank's for all what you are doing ... I am looking for this tutorial for a will ... thank's again
@datasith
@datasith 4 роки тому
Thanks for the kind comment. I'm glad you found it useful!
@HappyFeetSalsa
@HappyFeetSalsa 2 роки тому
Great work
@budiirawan740
@budiirawan740 4 роки тому
Awesome explanation... thanks bro !!
@datasith
@datasith 4 роки тому
No worries, thanks for watching!
@julianmedina9370
@julianmedina9370 4 роки тому
i love you Greatings from Colombia! 🇨🇴🇨🇴
@datasith
@datasith 4 роки тому
Aguante Colombia! I'm glad the content was useful to you!
@mohammedalime647
@mohammedalime647 5 років тому
Thank you for your supporting. bro
@datasith
@datasith 5 років тому
Thank you for watching my vids, I'm glad your found them useful!
@morpheuz2006
@morpheuz2006 5 років тому
Nice work .. :) thanks for sharing
@datasith
@datasith 5 років тому
Thank you, I'm glad you found it useful!
@mgiza692
@mgiza692 4 роки тому
It's very helpful. Thank you very much :)
@datasith
@datasith 4 роки тому
I'm glad you found the content useful, thanks for watching!
@naronghome1968
@naronghome1968 4 роки тому
This is what I looking for , Thank you from Thaialnd
@datasith
@datasith 4 роки тому
Awesome, Thailand! I'm glad you found it useful!
@rumitshah7136
@rumitshah7136 3 роки тому
Awesome content.
@kesterbelgrove818
@kesterbelgrove818 5 років тому
Thank you for this tutorial
@datasith
@datasith 5 років тому
No worries, Kester. I'm happy you found it useful!
@darkovulin1114
@darkovulin1114 4 роки тому
Greetings from Croatia. Thanks
@datasith
@datasith 3 роки тому
Heya Darko from Croatia. Thanks so much for watching my vid!
@BoranEngineering
@BoranEngineering 4 роки тому
YOU PERFECT.
@datasith
@datasith 4 роки тому
Thank you, you perfect too!
@Mreto17
@Mreto17 3 роки тому
Hello thanks for the comprehensive tutorial. Is there any other way to set initial ssid and password without switching esp8266 as an AP first? I wonder why it's so easy to do this on plug and play devices on the market like Tuya smart devices.
@muhammadbilal2000
@muhammadbilal2000 2 роки тому
Hello, thank you for the video and excellent work. I want to implement the same thing on ESP-Wroom-32 board. Would it work for it? The could won't compile for this board because the two library i.e. ESP8266WiFi.h and server library are not meant for this board. Can I use alternative libraries to achieve the same result? Thank you
@elchiqui10
@elchiqui10 5 років тому
ESP32 provides a very convenient core library (Preferences.h) which uses ESP32's NVS (non-Volatile Storage). It is even easier than accessing SPIFFs, and of course there is no need to reserve SPIFFs space. Unfortunately that is not available in the ESP8266
@datasith
@datasith 5 років тому
Yup, ESP32 rocks! Thanks so much for watching, and for sharing the info!
@craigyoung6771
@craigyoung6771 2 роки тому
Great videos :) I have a question related to the end of your video. If the user is connected to the AP on a phone and enters incorrect WIFI credentials on the given web page, how can the user be informed if they have entered something wrong. In my setup, I see the ESP8266 trying to connect to the WIFI but client dies before I see the status that e.g. the SSID cannot be found or the password is incorrect. Any advice would be appreciated... thanks
@MrManu2468
@MrManu2468 3 роки тому
I was wondering how you set the Server up as an access point beforehand. Looking through your code, it doesn't seem obvious how you made the ESP enter station mode firs before even entering the function.
@agustinsida8877
@agustinsida8877 3 роки тому
obviamente que el mejor video lo iba a hacer un argentino
@rgmtb
@rgmtb 5 років тому
Do we have to update the Wemos to allow storing in the flash? I thought I saw that we need to add in a jar file to update the Wemos. I really appreciate your videos, they are a huge help to me👍👍👍
@datasith
@datasith 4 роки тому
You don't have to. The .jar is to modify the Arduino IDE to have an option to send data to flash. However, you can also do it as shown in this video! Thanks for watching!
@phillipmaser132
@phillipmaser132 3 роки тому
Programming the device looks good. How did you get started writing code for this device. examples
@loggerman247
@loggerman247 4 роки тому
Thanks for a great video, it was just what I was looking for, except I'm using an ESP32. Do you have a similar video for that? Best regards, AB
@datasith
@datasith 4 роки тому
not quite yet, although i'm assuming the process is quite similar. i'll try to put it on top of my to-do list. thanks so much for watching, and for leaving a comment!
@deraid712
@deraid712 Рік тому
But if you reboot ESP it will not reconnect to STA and will create AP as on first boot...
@user-cq4yd7mi1b
@user-cq4yd7mi1b 3 роки тому
Thanks a lot for your awesome video, and would like to ask you about if you can make video about how to connect to nodemcu or esp8266 by both Wi-Fi and internet, i mean if you can to make video how to develop mobile app to control loads connected to esp8266 and we can control these loads by internet and Wi-Fi in the same app and the same code. I hope I explain what i want correctly.
@thetinytrader1564
@thetinytrader1564 3 роки тому
Does it work on Generic ESP8266 board ? I want to use it on esp-01 board.
@Schatti1994
@Schatti1994 5 років тому
Nice video .. there is a way to scan all the networks on the esp .. How is it possible to access this list with available networks on the webserver. (eg . in a dropdown list)
@datasith
@datasith 5 років тому
Thanks! A way to do this is using the HTML+JavScript code in this example. Once you get the networks, you put inside the string that's sent from the server (replace the "{status: ok" in this example}. Then, on the JavaScript side, you receive the data in the "xhr.responseText" attribute, and you can use additional JavaScript code to run a *for* loop, and create the elements on the page. HTH!
@snorklesnorkle6434
@snorklesnorkle6434 4 роки тому
provide example of arduino esp8266 to use on the go wifi forwarded from home LAN router.
@datasith
@datasith 4 роки тому
i'll add it to my to-do list. thanks for watching!
@snorklesnorkle6434
@snorklesnorkle6434 4 роки тому
@@datasith to stream Amazon prime video from Arduino to public IP in Arduino with home router port forward, ommiting port 80, to direct TCP off grid
@grasi5846
@grasi5846 4 роки тому
hi great content ACRO that's what i'm searching for a while for my project. I tried it on my NodeMCU but it won't change to STA mode. I debugged it a bit and found that the "/config.json" doens't exist. Do i need to create it in the filesystem?
@datasith
@datasith 4 роки тому
hey, grasi. thanks for the kind words! the file should be created when you access your ESP8266's "/settings" path. once the file is created, then you can access the "/" path to do the update. the code can be changed so that the file is created even if you visit "/" first. hth!
@gazzcomm
@gazzcomm 5 років тому
Hi Acrobiotic ! Very intresting your videos... i'm trying to use httpupdate, but it downloads correctly, but after auto-restart i see trash on serial monitor. maybe some problems with programming flags and fuses ? any ideas ?
@datasith
@datasith 5 років тому
Hi, I'm glad you found the videos interesting. Remember to set the "baud rate" to the correct number in the Serial Monitor.
@williamponraj3637
@williamponraj3637 4 роки тому
The soft AP is not turning off while I use on demand portal even when i set timeout. It happens only when I don't connect to that AP after I press that switch
@datasith
@datasith 4 роки тому
can you send me the code to support@acrobotic.com? i'll try to see what's the problem when i get a chance!
@williamponraj3637
@williamponraj3637 4 роки тому
@@datasith i just sent. Kindly check
@digihz_data
@digihz_data 4 роки тому
Some additional info, because my AP did not show up on my network. (I had only 7 charachters in my password.) char* password = "YOUR_AP_PASSWORD"; (minimum of 8 characters. If not specified, the access point will be open (maximum 63 characters)) char* mySsid = "YOUR_AP_SSID"; (maximum of 31 characters) I find that using only 5 seconds might be a to low value, sometimes the nodeMCU connects to the STA and sometimes to the AP. if ((unsigned long)(millis() - startTime) >= 5000) break; Changing the value from 5000 to 10000 solved this problem for me. And if you dont want to be confused by what the WiFi.printDiag(Serial); spits out i added a new line: WiFi.disconnect();//Dissconnect from STA. (So that we not get the STA _ssid and _pass when displaying info from WiFi.printDiag(Serial); in AP mode). ACROBOTIC code: { WiFi.mode(WIFI_AP); WiFi.softAPConfig(local_ip, gateway, netmask); WiFi.softAP(mySsid, password); digitalWrite(pin_led,LOW); } MODIFIED code: { WiFi.disconnect(); //delay(1000);//Wait a bit for the nodeMCU to dissconnect from STA. (If needed). WiFi.mode(WIFI_AP); WiFi.softAPConfig(local_ip, gateway, netmask); WiFi.softAP(mySsid, password); digitalWrite(pin_led,LOW); }
@datasith
@datasith 4 роки тому
Oh, thanks so much for sharing that info. I wouldn't have thought about that issue, I simply use 8+ character passwords by default. I'm glad you figured it out!
@TheAlibigdeli
@TheAlibigdeli 5 років тому
well, i am not sure about others but this time it was a bit confusing but at the end i totally got the idea i usually use the eeprom writing and readying another way like the stock example but this one was great too BTW this time reminds of something, can ya teach how to use dynamic urls to control each pin like 192.168.4.1/pin/"pin number"/state/"state 0 or 1" its bugging me for long time how to do this
@datasith
@datasith 5 років тому
I agree. When I was editing the video I realized that longer code examples like this one are harder to explain, and become confusing. I will add graphics next time to show better what each step of the code does! Thanks for your feedback as always!
@tin2001
@tin2001 5 років тому
On the dynamic URLs bit, remember to never trust user supplied data... You'd never intentionally send it bad data, of course, but mistakes happen. Also, if you were to put the web interface on the public internet for some reason, even stuff like search engines crawling the page could send busted data.
@TheAlibigdeli
@TheAlibigdeli 5 років тому
@@tin2001 well nice suggests My goal is for local and just testing purpose and all i need a sample script to figure out
@datasith
@datasith 5 років тому
Good tips, thanks for sharing!
@hugobola
@hugobola 5 років тому
Arduino IDE is asking for a JSON V.6 is there any update available to solve this?
@rgmtb
@rgmtb 5 років тому
Hugo Valente Yes, could this video please be updated using v6? It’s a great video and having it current would be a huge help. I’m having a bit of trouble learning v6 at the moment.
@datasith
@datasith 4 роки тому
You can choose version 5 from the drop down list. Unfortunately, version 6 is not compatible with version 5, so I'll need to remake the video using version 6. Thanks for watching!
@premprem-yu2bp
@premprem-yu2bp 5 років тому
Hi, After few hours station mode automatically disconnect moves to AP mode and again after few minutes switched to station mode automatically. u have any idea why?
@datasith
@datasith 5 років тому
Not sure why. Try using Serial.print() statements to try and figure out where in the code the problems are occurring. The ESP8266 might be running out of memory and resetting itself after the code can no longer run.
@tin2001
@tin2001 5 років тому
Trying to do something similar on a ESP32... It'll connect fine with wifi details set by a hard coded string, but fails when using the JSON code presented here. But here's where it gets bizarre.... I assumed I'd done something wrong with the JSON data, so I stored the JSON results in different variables, and did a strcmp... JSON set variable is exactly the same as the hard coded string according to strcmp. But something about it is stopping the ESP32 from connecting.
@tin2001
@tin2001 5 років тому
I shoehorned your JSON code into my existing project... My guess is a did something wrong. I should try your entire code on my ESP32 and see how it reacts. Edit: Works fine with the Acrobotic example code. Obviously I've done something stupid in my code.
@datasith
@datasith 5 років тому
Thanks for the follow-up. Glad it worked out! If you send me the original code, I can have a look (support@acrobotic.com)
@tin2001
@tin2001 5 років тому
@@datasith It's fine... I'll learn more if I try to find the problem myself.
@I_am_smooth_as_butter
@I_am_smooth_as_butter 4 роки тому
Hey how to connect it with blynk please reply as fast as possible...god bless you sir..i mean after this switching mode
@datasith
@datasith 4 роки тому
I bet there are good guides that can be found by using Google. HTH!
@ManuelCastillo-kq3xy
@ManuelCastillo-kq3xy 5 років тому
Hola, cual seria la pagina que se mostraria o la funcionalidad que logramos, una vez que configuramos en forma correcta los datos del wifi? O faltaria codificar la opcion de una pagina para ese caso? Porque si no estoy conectado a la red del wemos, si ingreso a la IP 192.168.0.11 me muestra nuevamente la opcion de configurar los datos?
@datasith
@datasith 5 років тому
Buena pregunta, Manuel! Si, como viste el root path ("/") esta configurado para solo mostrar la opcion de introducir los datos. Tendriamos que agregar otro path para mostrar los que estan guardados. Yo lo haria, por ejemplo, agregando: server.on("/settings", HTTP_GET, handleSettingsDisplay); Solo por preferencia reutilizo el path "/settings" pero con un metodo distinto (HTTP_GET), que es el que usa el navegador por default. Tendria que definir tambien la funcion handleSettingsDisplay, por ejemplo: void handleSettingsDispla(){ ... server.send(200, "text/plain", STRING_CON_DATOS_GUARDADOS); } Ahora, cuando acceda con el navegador 192.168.0.11/settings voy a ver los datos guardados, y cuando acceda 192.168.0.11 voy a poder cambiarlos.
@ManuelCastillo-kq3xy
@ManuelCastillo-kq3xy 5 років тому
ACROBOTIC también podría ser una opción el detectar si estamos con wifi conectado y ahí mostrar otra página. Estoy ahora en algo así, pero con la finalidad de mostrar los datos capturados de sensores y mostrar el estado de los mismos. Uniendo un par de tus tutoriales
@ManuelCastillo-kq3xy
@ManuelCastillo-kq3xy 5 років тому
ACROBOTIC faltaría manejar el poder acceder por nombre y no ip, es más fácil pensando en un usuario final
@datasith
@datasith 5 років тому
Si, me gusta dividir cada tarea en distintos videos para que no sean complicados y/o tediosos. Acceder por nombre: ukposts.info/have/v-deo/naejemeDsaipqWw.html Y para mostrar otra pagina, en la funcion llamada cuando se accede al root path ("/") podes usar "if (WiFi.status() == WL_CONNECTED)" y en cada caso hacer un server.send() con paginas distintas.
@ManuelCastillo-kq3xy
@ManuelCastillo-kq3xy 5 років тому
ACROBOTIC excelente Cisco. Muchas gracias.
@ecoegg4608
@ecoegg4608 5 років тому
How can we force the AP to automatically open the browser on that webpage. Thank you
@datasith
@datasith 5 років тому
This is called "captive portal". You can do it yourself by issuing a server.send() after a client has connected to the AP. There's a built-in example that shows one way of doing it: github.com/esp8266/Arduino/blob/master/libraries/DNSServer/examples/CaptivePortalAdvanced/CaptivePortalAdvanced.ino HTH!
@alimorawej4386
@alimorawej4386 5 років тому
use mata in top of your webpage .
@JenishJain6
@JenishJain6 4 роки тому
I am using a similar code along with wifi-manager for my use case, but I find my esp access point to be very unstable and it continuously gets disconnected in mobile or desktop even after multiple attempts of connecting it, can someone please help @acrobotic
@datasith
@datasith 4 роки тому
Check my reply to your other comment. Thanks for watching!
@Msultan48
@Msultan48 4 роки тому
How can i save Ip subnet or other things...
@datasith
@datasith 4 роки тому
Same way. Convert it to a string, and put it in a file. HTH!
@joseguatume8477
@joseguatume8477 5 років тому
hi acrobotic, i have a issue, i did a project with this video and it worked well but when the esp8266 reset, it can't open the file that i create
@datasith
@datasith 4 роки тому
Make sure you're not formatting SPIFFS on reset (which can be done with SPIFFS.begin(true) for example). HTH!
@michaelrotter5143
@michaelrotter5143 Рік тому
horrible horrible audio :/ my ears exploded
@datasith
@datasith Рік тому
sending thoughts and prayers to your ears.
@t.n.1056
@t.n.1056 Рік тому
I am sorry man, but your audio is really really horrible... it hurts my ears... no joke :/
@datasith
@datasith Рік тому
Thank goodness this isn't the only video out there 🙏
@t.n.1056
@t.n.1056 Рік тому
@@datasith yeah, indeed. The other ones Audios are great. But let me say this: overall, your videos are absolutely absolutely great. Thanks for that. It has helped me tooo much.
WiFiManager - An Essential ESP32 library!
12:50
Brian Lough
Переглядів 29 тис.
Что будет с кроссовком?
00:35
Аришнев
Переглядів 2,5 млн
"Поховали поруч": у Луцьку попрощались із ДВОМА Героями 🕯🥀 #герої #втрати
00:15
Телеканал Конкурент TV - новини Луцька та Волині
Переглядів 302 тис.
BMW просто издевается над нами! Силы на исходе…
1:34:41
ИЛЬДАР АВТО-ПОДБОР
Переглядів 3,6 млн
Піхотинець - про рутину на фронті
00:46
Суспільне Новини
Переглядів 293 тис.
ESP8266 in 5 minutes
5:50
MrDIY
Переглядів 113 тис.
#232 How to secure our devices using SSL (ESP8266, ESP32, Tutorial)
17:27
Andreas Spiess
Переглядів 113 тис.
ESP32 Web Server using AJAX
8:03
Anas Kuzechie
Переглядів 20 тис.
Esp8266 connect WIFI without hard coding credentials (SSID, Password)
6:02
Распаковал Xiaomi SU7
0:59
Wylsacom
Переглядів 477 тис.
Subscribe for more!! #procreate #logoanimation #roblox
0:11
Animations by danny
Переглядів 3,9 млн
Лучший Смартфон До 149 Баксов!!!??? itel s24
20:25
РасПаковка ДваПаковка
Переглядів 24 тис.