esp_wifi_init() returning an error

Mark1tus
Posts: 1
Joined: Tue Jan 31, 2023 11:42 am

esp_wifi_init() returning an error

Postby Mark1tus » Sat Feb 11, 2023 9:30 am

Hi all,
I'm pretty new using ESP boards and I have some problems using the esp_wifi library. I will show you how I wrote the code:
  1. static void Wifi_inicialitzation(void){
  2.     wifi_init_config_t wifiInitConfig = WIFI_INIT_CONFIG_DEFAULT();
  3.     if (esp_wifi_init(wifiInitConfig) != ESP_OK){
  4.         printf("Can't run esp_wifi_init()...\n");
  5.         return;
  6.     else {
  7.         printf("esp_wifi_init() running...\n");
  8.     }
  9.     esp_wifi_set_mode(WIFI_MODE_STA);
  10.     esp_wifi_start();
  11.     esp_wifi_connect();
  12. }
The problem comes when I monitorize the board and I see that the inicialitzation of esp_wifi_init() is returning the printf from the else part. Do you know how to resolve this problem?

User avatar
mbratch
Posts: 300
Joined: Fri Jun 11, 2021 1:51 pm

Re: esp_wifi_init() returning an error

Postby mbratch » Wed Feb 15, 2023 11:18 pm

Mark1tus wrote:
Sat Feb 11, 2023 9:30 am
The problem comes when I monitorize the board and I see that the inicialitzation of esp_wifi_init() is returning the printf from the else part. Do you know how to resolve this problem?
The `else` part of the `if` statement is the success return of `esp_wifi_init()`. Did you actually mean the first leg of the `if`?

If you're getting an error, check the actual error code to see if that provides more information.

Who is online

Users browsing this forum: No registered users and 228 guests