logo elektroda
logo elektroda
X
logo elektroda

How do I set the ESP8266 to AP mode for WiFi network selection on first startup?

Rigardo5033 3480 14
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 18029793
    Rigardo5033
    Level 6  
    Hello, I have a problem. I have created my own weather station with a temperature sensor and a particulate matter sensor, the data is sent to a ThingSpeak server and to a web server where the data is displayed. But I am looking for a way to make the module work in AP mode when I first start it up and to be able to select the WiFi network. Unfortunately the tutorials and examples from the internet are very complicated, I need the simplest one that exists. I used this guide:


    .

    Everything here works but I am having a hard time linking it to my application. Maybe someone can explain it to me "in a spatial manner".

    Greetings
  • ADVERTISEMENT
  • #2 18029811
    Anonymous
    Level 1  
  • #3 18029826
    Rigardo5033
    Level 6  
    This is how I would like the network scan to be performed. I would like the selection to be at the beginning and then my page to be done. I know it's a mess out there, I'm a beginner. Please advise

    Code: C / C++
    Log in, to see the code
    .
  • Helpful post
    #4 18029861
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #5 18029965
    Rigardo5033
    Level 6  
    I will try to play with this feature tomorrow. Thanks for the advice tomorrow I will share what I manage to create

    Added after 10 [hours] 36 [minutes]:

    I have reviewed this scan function, and it is great only I have one question. I search for a network and it finds me a network xxx I want to connect to it and after connecting it starts the web server. And how to do a simple network selection and password.
  • Helpful post
    #6 18030457
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • Helpful post
    #7 18030459
    kaczakat
    Level 34  
    Here is a tutorial on how to use the WIFI MANAGER library for ESP Link .
    Alternatively there is the FSBrowser NG project Link . The HTML local page is saved in regular HTML files. You need to have a file system upload plugin added to the ESP, this makes sense for flash larger than 1MB. Example you compile for FS (SPIFFS) at least 128kB (no larger than the contents of the DATA directory), upload firmware, upload web page files separately:
    How do I set the ESP8266 to AP mode for WiFi network selection on first startup? .
    Within the example is a set of sample files, if you save the example AS, there is a DATA folder added in its directory, inside are sample HTML files - WIFI configuration, adding a password, updating firmware from a browser, etc. bits and pieces:
    How do I set the ESP8266 to AP mode for WiFi network selection on first startup? .
    The first time you start up, you connect to the module set to AP+ST mode, go to 192.168.4.1/admin, then from the network settings menu and select the network parameters as if you were using a smartphone:
    How do I set the ESP8266 to AP mode for WiFi network selection on first startup? .
    Edit: 192.168.4.1 of course.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • Helpful post
    #8 18030484
    Anonymous
    Level 1  
  • #9 18030664
    Rigardo5033
    Level 6  
    Esp8266 nodemcu v3 . I'll be back from work trying to get something working.

    Added after 6 [hours] 28 [minutes]: .

    I succeeded with the help of WiFi manager. Only I have 2 problems still :) Well, in the program code in setup() I use the following settings:
    ..
    Code: C / C++
    Log in, to see the code
    .

    And unfortunately after every unplugging it loses the given network. How do I solve this? The second thing I would like to do is to impose a fixed ip on the device after connecting to the network, e.g. : 192.168.1.10 , I seem to have this defined at the beginning but it takes a different ip:

    Code: C / C++
    Log in, to see the code
    .

    Please advise and thank you already for any help.
  • #11 18031445
    Rigardo5033
    Level 6  
    But if it is not there then automatically when I leave the "known network" then my device will be the AP? Do I understand this correctly?
  • #12 18031458
    kaczakat
    Level 34  
    In the example it is commented out, this is used to reset the settings. If, for example, you change the wifi password and the program goes dumb, or for some other reason you want to connect to another network you can assign this function to a button - e.g. you press the button after IO13 for 5s, as a reaction you call the function wifiManager.resetSettings(); and reset the WIFI settings - it starts up again as an AP and no network is entered.
    As you've added it to setup it does a cleanup of your WIFI settings after each reset, as expected.
    And you can let go of those manual settings for IP, Gate, etc., from the library description it appears that this is configured and stored in EEPROM (emulated).
    Helpful post? Buy me a coffee.
  • #13 18031467
    Rigardo5033
    Level 6  
    Ok. But how can I no longer connect the button? Any idea how to use this function?
  • #14 18031516
    kaczakat
    Level 34  
    If it doesn't find the network or you change the password it starts up in AP mode and you can log in from your smartphone to change the SSID and password. That's probably enough for you, but there are many other options, I haven't tested them, there are quite a few descriptions in the examples and on the library page.
    Helpful post? Buy me a coffee.
  • #15 18031544
    Anonymous
    Level 1  

Topic summary

The discussion revolves around configuring the ESP8266 to operate in Access Point (AP) mode for WiFi network selection during initial startup. The user seeks a straightforward method to implement this functionality for their weather station project, which utilizes sensors and uploads data to ThingSpeak. Responses suggest using the WiFiScan example code to perform network scanning before configuring WiFi settings. The WiFiManager library is recommended for simplifying network selection and management, allowing the device to revert to AP mode if it cannot connect to a known network. Issues regarding static IP assignment and the use of reset settings are also addressed, with advice on how to manage these configurations effectively.
Summary generated by the language model.
ADVERTISEMENT