Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

ESP32 static IP not saved after restarting the device #19

Closed
krupis opened this issue Nov 12, 2020 · 6 comments
Closed

ESP32 static IP not saved after restarting the device #19

krupis opened this issue Nov 12, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@krupis
Copy link

krupis commented Nov 12, 2020

Hello. I am learning about esp32 and trying your library. I am using the example program:
Async_ESP32_FSWebServer_DRD

I have not modified the code yet. When I run the program. A new network appeared
image

I am able to connect to my device by typing the ip address :
192.168.1.100
and change some configurataion:

image

Now I can see that the device connects with the new parameters: (I have set a new static ip 192.168.4.210)

image

However, the thing that I do not fully understand, when i restart my esp32 device, it goes changes my static ip (192.168.4.210) to:
192.168.2.232
image

Is that normal? Should it not save my configuration even after I restart the device?

Also, I am unsure about:
Open http://async-esp32fs.local/edit to see the file browser
Using username = admin and password = admin

Opening this webpage in a browswer fails everytime. How do i use it?
image

Appreciate any sort of advice. Thanks in advance.

@khoih-prog
Copy link
Owner

Hi @krupis

Thanks for using the library.

Is that normal? Should it not save my configuration even after I restart the device?

Currently, the example still is not perfect, with the bug as you experienced (Static IP input in CP is not persistent).
You can hard-code staticIP in the sketch as follows:

#ifdef ESP32
    IPAddress stationIP   = IPAddress(192, 168, 4, 210);     // Change this to persistent Static IP
  #else
    IPAddress stationIP   = IPAddress(192, 168, 4, 186);
  #endif

Opening this webpage in a browswer fails everytime. How do i use it?

If the ESP32 MDNS is somehow not working perfectly (depending on your network, OS, etc.), and you can use IP address directly to access the Server, for example: http://192.168.4.210/edit instead of http://async-esp32fs.local/edit .

@khoih-prog khoih-prog added the bug Something isn't working label Nov 12, 2020
@krupis
Copy link
Author

krupis commented Nov 12, 2020 via email

@khoih-prog
Copy link
Owner

I really advise you against the use of staticIP unless you have good reason to do so. StaticIP will create lots of problem if being used not correctly, especially for normal users, and users certainly have to know more about the network to set it correctly, without errors and conflicts.

It's better for you to use DHCP now, by modifying the code as follows:

// Use USE_DHCP_IP == true for dynamic DHCP IP, false to use static IP which you have to change accordingly to your network
#if (defined(USE_STATIC_IP_CONFIG_IN_CP) && !USE_STATIC_IP_CONFIG_IN_CP)
// Force DHCP to be true
  #if defined(USE_DHCP_IP)
    #undef USE_DHCP_IP
  #endif
  #define USE_DHCP_IP     true
#else
  // You can select DHCP or Static IP here
  #define USE_DHCP_IP     true                      // Always using DHCP  <=====================
  //#define USE_DHCP_IP     false
#endif

The CP is now as simple as this and much better for users

image

and you can see MDNS will work correctly with DHCP

image

image

@krupis
Copy link
Author

krupis commented Nov 12, 2020 via email

@khoih-prog
Copy link
Owner

If you use DHCP, you can easily assign every device a unique MDNS name so that MODBUS TCP can reach to xfer data.

If staticIP is selected, that fastest way to do now for you, before the feature is fixed, is to use dynamic parameter (ESPAsync_WMParameter) to input from CP/ store staticIP, then replacing staticIP, from Line 486 with the dynamic param (staticIP) got from CP.

#if !USE_DHCP_IP
  #if USE_CONFIGURABLE_DNS
    // Set static IP, Gateway, Subnetmask, DNS1 and DNS2.
    ESPAsync_wifiManager.setSTAStaticIPConfig(stationIP, gatewayIP, netMask, dns1IP, dns2IP);
  #else
    // Set static IP, Gateway, Subnetmask, Use auto DNS1 and DNS2.
    ESPAsync_wifiManager.setSTAStaticIPConfig(stationIP, gatewayIP, netMask);
  #endif
#endif

Have a look at other examples about how to use dynamic parameters ESPAsync_WMParameter.

You have to understand that these are just examples to demonstrate the basic operation of the library, and there is no one-size-fit-all solution for every use case.

If you can find a quick solution, please post here to help other library's users.

khoih-prog added a commit that referenced this issue Dec 21, 2020
### Major Releases v1.4.0

1. Fix staticIP not saved in examples. See [ESP32 static IP not saved after restarting the device](#19)
2. Add structures and functions to handle AP and STA IPs.
3. Add complex examples 
  * [Async_ConfigOnDRD_FS_MQTT_Ptr_Complex](examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Complex) to demo usage of std::map
  * [Async_ConfigOnDRD_FS_MQTT_Ptr_Medium](examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Medium).
4. Add simple minimal examples 
  * [Async_ConfigOnDRD_ESP32_minimal](examples/Async_ConfigOnDRD_ESP32_minimal)
  * [Async_ConfigOnDRD_ESP8266_minimal](examples/Async_ConfigOnDRD_ESP8266_minimal)
  * [Async_AutoConnect_ESP32_minimal](examples/Async_AutoConnect_ESP32_minimal)
  * [Async_AutoConnect_ESP8266_minimal](examples/Async_AutoConnect_ESP8266_minimal)
5. Modify Version String
6. Add Table of Contents
khoih-prog added a commit that referenced this issue Dec 21, 2020
### Major Releases v1.4.0

1. Fix staticIP not saved in examples. See [ESP32 static IP not saved after restarting the device](#19)
2. Add structures and functions to handle AP and STA IPs.
3. Add complex examples 
  * [Async_ConfigOnDRD_FS_MQTT_Ptr_Complex](examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Complex) to demo usage of std::map
  * [Async_ConfigOnDRD_FS_MQTT_Ptr_Medium](examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Medium).
4. Add simple minimal examples 
  * [Async_ConfigOnDRD_ESP32_minimal](examples/Async_ConfigOnDRD_ESP32_minimal)
  * [Async_ConfigOnDRD_ESP8266_minimal](examples/Async_ConfigOnDRD_ESP8266_minimal)
  * [Async_AutoConnect_ESP32_minimal](examples/Async_AutoConnect_ESP32_minimal)
  * [Async_AutoConnect_ESP8266_minimal](examples/Async_AutoConnect_ESP8266_minimal)
5. Modify Version String
6. Add Table of Contents
khoih-prog added a commit that referenced this issue Dec 21, 2020
### Major Releases v1.4.0

1. Fix staticIP not saved in examples. See [ESP32 static IP not saved after restarting the device](#19)
2. Add structures and functions to handle AP and STA IPs.
3. Add complex examples 
  * [Async_ConfigOnDRD_FS_MQTT_Ptr_Complex](examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Complex) to demo usage of std::map
  * [Async_ConfigOnDRD_FS_MQTT_Ptr_Medium](examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Medium).
4. Add simple minimal examples 
  * [Async_ConfigOnDRD_ESP32_minimal](examples/Async_ConfigOnDRD_ESP32_minimal)
  * [Async_ConfigOnDRD_ESP8266_minimal](examples/Async_ConfigOnDRD_ESP8266_minimal)
  * [Async_AutoConnect_ESP32_minimal](examples/Async_AutoConnect_ESP32_minimal)
  * [Async_AutoConnect_ESP8266_minimal](examples/Async_AutoConnect_ESP8266_minimal)
5. Modify Version String
6. Add Table of Contents
@khoih-prog
Copy link
Owner

khoih-prog commented Dec 21, 2020

This has been fixed in ESPAsync_WiFiManager v1.4.0


Major Releases v1.4.0

  1. Fix staticIP not saved in examples. See ESP32 static IP not saved after restarting the device
  2. Add structures and functions to handle AP and STA IPs.
  3. Add complex examples
  1. Add simple minimal examples
  1. Modify Version String
  2. Add Table of Contents

Your contribution has been noted in Contributions and Thanks

khoih-prog added a commit that referenced this issue Dec 21, 2020
### Major Releases v1.4.0

1. Fix staticIP not saved in examples. See [ESP32 static IP not saved after restarting the device](#19)
2. Add structures and functions to handle AP and STA IPs.
3. Add complex examples 
  * [Async_ConfigOnDRD_FS_MQTT_Ptr_Complex](examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Complex) to demo usage of std::map
  * [Async_ConfigOnDRD_FS_MQTT_Ptr_Medium](examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Medium).
4. Add simple minimal examples 
  * [Async_ConfigOnDRD_ESP32_minimal](examples/Async_ConfigOnDRD_ESP32_minimal)
  * [Async_ConfigOnDRD_ESP8266_minimal](examples/Async_ConfigOnDRD_ESP8266_minimal)
  * [Async_AutoConnect_ESP32_minimal](examples/Async_AutoConnect_ESP32_minimal)
  * [Async_AutoConnect_ESP8266_minimal](examples/Async_AutoConnect_ESP8266_minimal)
5. Modify Version String
6. Add Table of Contents
khoih-prog added a commit that referenced this issue Dec 21, 2020
### Major Releases v1.4.0

1. Fix staticIP not saved in examples. See [ESP32 static IP not saved after restarting the device](#19)
2. Add structures and functions to handle AP and STA IPs.
3. Add complex examples 
  * [Async_ConfigOnDRD_FS_MQTT_Ptr_Complex](examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Complex) to demo usage of std::map
  * [Async_ConfigOnDRD_FS_MQTT_Ptr_Medium](examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Medium).
4. Add simple minimal examples 
  * [Async_ConfigOnDRD_ESP32_minimal](examples/Async_ConfigOnDRD_ESP32_minimal)
  * [Async_ConfigOnDRD_ESP8266_minimal](examples/Async_ConfigOnDRD_ESP8266_minimal)
  * [Async_AutoConnect_ESP32_minimal](examples/Async_AutoConnect_ESP32_minimal)
  * [Async_AutoConnect_ESP8266_minimal](examples/Async_AutoConnect_ESP8266_minimal)
5. Modify Version String
6. Add Table of Contents
khoih-prog added a commit to khoih-prog/ESP_WiFiManager that referenced this issue Dec 22, 2020
### Major Releases v1.4.1

1. Fix staticIP not saved in examples. See [ESP32 static IP not saved after restarting the device](khoih-prog/ESPAsync_WiFiManager#19)
2. Add structures and functions to handle AP and STA IPs.
3. Add complex examples 
  * [ConfigOnDRD_FS_MQTT_Ptr_Complex](examples/ConfigOnDRD_FS_MQTT_Ptr_Complex) to demo usage of std::map
  * [ConfigOnDRD_FS_MQTT_Ptr_Medium](examples/ConfigOnDRD_FS_MQTT_Ptr_Medium).
4. Add simple minimal examples 
  * [ConfigOnDRD_ESP32_minimal](examples/ConfigOnDRD_ESP32_minimal)
  * [ConfigOnDRD_ESP8266_minimal](examples/ConfigOnDRD_ESP8266_minimal)
  * [AutoConnect_ESP32_minimal](examples/AutoConnect_ESP32_minimal)
  * [AutoConnect_ESP8266_minimal](examples/AutoConnect_ESP8266_minimal)
5. Fix bug.
6. Fix compiler warnings.
7. Modify Version String
8. Add Table of Contents
khoih-prog added a commit to khoih-prog/ESP_WiFiManager that referenced this issue Dec 22, 2020
### Major Releases v1.4.1

1. Fix staticIP not saved in examples. See [ESP32 static IP not saved after restarting the device](khoih-prog/ESPAsync_WiFiManager#19)
2. Add structures and functions to handle AP and STA IPs.
3. Add complex examples 
  * [ConfigOnDRD_FS_MQTT_Ptr_Complex](examples/ConfigOnDRD_FS_MQTT_Ptr_Complex) to demo usage of std::map
  * [ConfigOnDRD_FS_MQTT_Ptr_Medium](examples/ConfigOnDRD_FS_MQTT_Ptr_Medium).
4. Add simple minimal examples 
  * [ConfigOnDRD_ESP32_minimal](examples/ConfigOnDRD_ESP32_minimal)
  * [ConfigOnDRD_ESP8266_minimal](examples/ConfigOnDRD_ESP8266_minimal)
  * [AutoConnect_ESP32_minimal](examples/AutoConnect_ESP32_minimal)
  * [AutoConnect_ESP8266_minimal](examples/AutoConnect_ESP8266_minimal)
5. Fix bug.
6. Fix compiler warnings.
7. Modify Version String
8. Add Table of Contents
khoih-prog added a commit to khoih-prog/ESP_WiFiManager that referenced this issue Dec 22, 2020
### Major Releases v1.4.1

1. Fix staticIP not saved in examples. See [ESP32 static IP not saved after restarting the device](khoih-prog/ESPAsync_WiFiManager#19)
2. Add structures and functions to handle AP and STA IPs.
3. Add complex examples 
  * [ConfigOnDRD_FS_MQTT_Ptr_Complex](examples/ConfigOnDRD_FS_MQTT_Ptr_Complex) to demo usage of std::map
  * [ConfigOnDRD_FS_MQTT_Ptr_Medium](examples/ConfigOnDRD_FS_MQTT_Ptr_Medium).
4. Add simple minimal examples 
  * [ConfigOnDRD_ESP32_minimal](examples/ConfigOnDRD_ESP32_minimal)
  * [ConfigOnDRD_ESP8266_minimal](examples/ConfigOnDRD_ESP8266_minimal)
  * [AutoConnect_ESP32_minimal](examples/AutoConnect_ESP32_minimal)
  * [AutoConnect_ESP8266_minimal](examples/AutoConnect_ESP8266_minimal)
5. Fix bug.
6. Fix compiler warnings.
7. Modify Version String
8. Add Table of Contents
khoih-prog added a commit to khoih-prog/ESP_WiFiManager that referenced this issue Dec 22, 2020
### Major Releases v1.4.1

1. Fix staticIP not saved in examples. See [ESP32 static IP not saved after restarting the device](khoih-prog/ESPAsync_WiFiManager#19)
2. Add structures and functions to handle AP and STA IPs.
3. Add complex examples 
  * [ConfigOnDRD_FS_MQTT_Ptr_Complex](examples/ConfigOnDRD_FS_MQTT_Ptr_Complex) to demo usage of std::map
  * [ConfigOnDRD_FS_MQTT_Ptr_Medium](examples/ConfigOnDRD_FS_MQTT_Ptr_Medium).
4. Add simple minimal examples 
  * [ConfigOnDRD_ESP32_minimal](examples/ConfigOnDRD_ESP32_minimal)
  * [ConfigOnDRD_ESP8266_minimal](examples/ConfigOnDRD_ESP8266_minimal)
  * [AutoConnect_ESP32_minimal](examples/AutoConnect_ESP32_minimal)
  * [AutoConnect_ESP8266_minimal](examples/AutoConnect_ESP8266_minimal)
5. Fix bug.
6. Fix compiler warnings.
7. Modify Version String
8. Add Table of Contents
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants