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

Поделиться
HTML-код
  • Опубликовано: 13 июл 2024
  • • 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
  • НаукаНаука

Комментарии • 118

  • @afonsusmuralha
    @afonsusmuralha 5 лет назад +6

    Your content gets better every day! Keep up the good work!

    • @datasith
      @datasith  5 лет назад +1

      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 ...

  • @TheDarkitox
    @TheDarkitox 4 года назад

    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!!!!

  • @viperone1000
    @viperone1000 3 года назад

    Excellent work!! Thank you so much for this tutorial.

  • @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!

  • @arduinomaker7210
    @arduinomaker7210 4 года назад

    I just subscribed your channel. Great work!!!

  • @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!

  • @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 года назад +1

      I'm super glad that you found them helpful, thanks so much for letting me know!

  • @drummerclint
    @drummerclint 2 года назад

    Great video! Down and to the point! I appreciate that!

  • @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 года назад +1

      Thanks for the kind comment. I'm glad you found it useful!

  • @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!

  • @HappyFeetSalsa
    @HappyFeetSalsa 2 года назад

    Great work

  • @ManiKandan-hw6tj
    @ManiKandan-hw6tj 3 года назад

    Thanks you so much brother. your doing great

  • @joaquimrs13
    @joaquimrs13 3 года назад

    Well done!!!

  • @carlosaciegoit
    @carlosaciegoit 4 года назад +1

    You're great man!!! Thanks for this video!

    • @datasith
      @datasith  4 года назад +2

      Thanks so much for the kind comment. I'm glad you found the video useful!

  • @CraftyOldGit
    @CraftyOldGit 3 года назад

    Very helpful, thanks. It would have taken me days to work that all out for myself.

  • @neilvermeulen5283
    @neilvermeulen5283 5 лет назад +1

    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!).

  • @AndreaSantopietro
    @AndreaSantopietro 3 года назад

    Davvero complimenti. Bravo bravo bravo.

  • @budiirawan740
    @budiirawan740 4 года назад

    Awesome explanation... thanks bro !!

    • @datasith
      @datasith  4 года назад

      No worries, thanks for watching!

  • @rumitshah7136
    @rumitshah7136 3 года назад

    Awesome content.

  • @julianmedina9370
    @julianmedina9370 4 года назад

    i love you
    Greatings from Colombia! 🇨🇴🇨🇴

    • @datasith
      @datasith  4 года назад

      Aguante Colombia! I'm glad the content was useful to you!

  • @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!

  • @morpheuz2006
    @morpheuz2006 5 лет назад

    Nice work .. :) thanks for sharing

    • @datasith
      @datasith  5 лет назад

      Thank you, I'm glad you found it useful!

  • @mohammedalime647
    @mohammedalime647 5 лет назад

    Thank you for your supporting. bro

    • @datasith
      @datasith  5 лет назад +1

      Thank you for watching my vids, I'm glad your found them useful!

  • @naronghome1968
    @naronghome1968 5 лет назад

    This is what I looking for , Thank you from Thaialnd

    • @datasith
      @datasith  5 лет назад +1

      Awesome, Thailand! I'm glad you found it useful!

  • @darkovulin1114
    @darkovulin1114 4 года назад

    Greetings from Croatia. Thanks

    • @datasith
      @datasith  4 года назад +1

      Heya Darko from Croatia. Thanks so much for watching my vid!

  • @kesterbelgrove818
    @kesterbelgrove818 5 лет назад

    Thank you for this tutorial

    • @datasith
      @datasith  5 лет назад

      No worries, Kester. I'm happy you found it useful!

  • @BoranEngineering
    @BoranEngineering 4 года назад

    YOU PERFECT.

    • @datasith
      @datasith  4 года назад +1

      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.

  • @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 лет назад +1

      Yup, ESP32 rocks! Thanks so much for watching, and for sharing the info!

  • @agustinsida8877
    @agustinsida8877 3 года назад

    obviamente que el mejor video lo iba a hacer un argentino

  • @craigyoung6771
    @craigyoung6771 3 года назад

    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

  • @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  5 лет назад

      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!

  • @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

  • @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.

  • @phillipmaser132
    @phillipmaser132 4 года назад

    Programming the device looks good. How did you get started writing code for this device. examples

  • @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.

  • @loggerman247
    @loggerman247 4 года назад +1

    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...

  • @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!

  • @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.

  • @thetinytrader1564
    @thetinytrader1564 3 года назад

    Does it work on Generic ESP8266 board ? I want to use it on esp-01 board.

  • @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 года назад +1

      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!

  • @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.

  • @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

  • @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 лет назад +2

      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!

  • @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!

  • @hugobola
    @hugobola 5 лет назад +1

    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  5 лет назад

      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!

  • @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 года назад +1

      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

  • @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!

  • @electronic.knowledge
    @electronic.knowledge 2 месяца назад

    I need help to make a dongle with esp8266, if you know a suitable site or can guide me, I need help!

  • @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!

  • @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.

  • @ecoegg4608
    @ecoegg4608 5 лет назад

    How can we force the AP to automatically open the browser on that webpage. Thank you

    • @datasith
      @datasith  5 лет назад +2

      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 .

  • @Msultan48
    @Msultan48 4 года назад +1

    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!

  • @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!

  • @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 лет назад +1

      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 лет назад +1

      Si, me gusta dividir cada tarea en distintos videos para que no sean complicados y/o tediosos.
      Acceder por nombre: ruclips.net/video/ewrF1LzrxH8/видео.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.

  • @michaelrotter5143
    @michaelrotter5143 2 года назад

    horrible horrible audio :/ my ears exploded

    • @datasith
      @datasith  2 года назад

      sending thoughts and prayers to your ears.

  • @t.n.1056
    @t.n.1056 2 года назад

    I am sorry man, but your audio is really really horrible... it hurts my ears... no joke :/

    • @datasith
      @datasith  2 года назад

      Thank goodness this isn't the only video out there 🙏

    • @t.n.1056
      @t.n.1056 2 года назад

      @@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.