Page 1 of 3

Setting wifi configuration

Posted: Mon Dec 24, 2018 7:29 pm
by burkulesomesh43
Hi all,
I want to connect to two wifi networks with the difference of some interval of time.
for example: network1 for 10 min and network2 for 10 minutes.
but for changing the configuration I want to stop the wifi then set the configuration and then start the wifi.
that is in idf like->>>

Code: Select all

ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &wifi_config1) );
ESP_ERROR_CHECK( esp_wifi_start() );
esp_wifi_stop();
ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &wifi_config2) );
ESP_ERROR_CHECK( esp_wifi_start() );
esp_wifi_stop();
ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &wifi_config1) );
ESP_ERROR_CHECK( esp_wifi_start() );
So does it affect the performance of esp32?
Or there is any another solutions to work this way?

Re: Setting wifi configuration

Posted: Tue Dec 25, 2018 4:04 am
by hoainguyen265
How about just disconnect wifi, set up new config and reconnect to wifi again?

Re: Setting wifi configuration

Posted: Tue Dec 25, 2018 5:03 am
by burkulesomesh43
hoainguyen265 wrote:
Tue Dec 25, 2018 4:04 am
How about just disconnect wifi, set up new config and reconnect to wifi again?
yes. It will also work.
but I want to ask you that it will affect the performance of esp32 or not.
because I want to do it for several times for whole life cycle of esp32.

Re: Setting wifi configuration

Posted: Tue Dec 25, 2018 7:11 am
by hoainguyen265
I think it just like using wifi on mobile phone. When use want to connect to another wifi, you just disconnect and reconnect. And calling

Code: Select all

esp_wifi_start();  esp_wifi_stop()
is the same with disable and enable wifi on mobile phone and doing this periodically is not good.

So in my opinion, if you just want change wifi ssid, just disconnect, set up new wifi ssid and reconnect is good choice.

Re: Setting wifi configuration

Posted: Tue Dec 25, 2018 7:41 am
by burkulesomesh43
hoainguyen265 wrote:
Tue Dec 25, 2018 7:11 am
I think it just like using wifi on mobile phone. When use want to connect to another wifi, you just disconnect and reconnect. And calling

Code: Select all

esp_wifi_start();  esp_wifi_stop()
is the same with disable and enable wifi on mobile phone and doing this periodically is not good.

So in my opinion, if you just want change wifi ssid, just disconnect, set up new wifi ssid and reconnect is good choice.
Ok. thank you for your response.

Re: Setting wifi configuration

Posted: Tue Dec 25, 2018 10:19 am
by ESP_igrr
Since by default Wi-Fi configuration is stored into flash, you may want to call esp_wifi_set_storage function with WIFI_STORAGE_RAM argument. In this case configuration will not be saved in flash, and flash lifetime will not be affected.

Re: Setting wifi configuration

Posted: Tue Dec 25, 2018 10:32 am
by burkulesomesh43
ESP_igrr wrote:
Tue Dec 25, 2018 10:19 am
Since by default Wi-Fi configuration is stored into flash, you may want to call esp_wifi_set_storage function with WIFI_STORAGE_RAM argument. In this case configuration will not be saved in flash, and flash lifetime will not be affected.
I am already using this.
thanks.

Re: Setting wifi configuration

Posted: Wed Dec 26, 2018 7:41 am
by burkulesomesh43
hoainguyen265 wrote:
Tue Dec 25, 2018 7:11 am
I think it just like using wifi on mobile phone. When use want to connect to another wifi, you just disconnect and reconnect. And calling

Code: Select all

esp_wifi_start();  esp_wifi_stop()
is the same with disable and enable wifi on mobile phone and doing this periodically is not good.

So in my opinion, if you just want change wifi ssid, just disconnect, set up new wifi ssid and reconnect is good choice.
Heyy, it works without wifi_disconnect. just changed ssid and reconnect.

Re: Setting wifi configuration

Posted: Wed Dec 26, 2018 8:37 am
by hoainguyen265
Nice :D

Re: Setting wifi configuration

Posted: Fri Dec 28, 2018 6:31 pm
by Ritesh
ESP_igrr wrote:
Tue Dec 25, 2018 10:19 am
Since by default Wi-Fi configuration is stored into flash, you may want to call esp_wifi_set_storage function with WIFI_STORAGE_RAM argument. In this case configuration will not be saved in flash, and flash lifetime will not be affected.
Hi,

We are storing WiFi configurations into flash memory as per our requirements. So, what will be the lifetime of flash operation for single device? Because we are also in same phase like many times WiFi configurations will be changed as per our project requirements.