include wifi.h can't be resolved in VSCode

hape65
Posts: 8
Joined: Wed Apr 03, 2024 4:41 pm

include wifi.h can't be resolved in VSCode

Postby hape65 » Wed Apr 17, 2024 9:16 am

hi
i'm new to the ESP32 world. I have bought a few ESP32-C6-DevKitC-1.
I have managed to get the "helloworld" in VSCode to get build and flashed.
I have also managed to get the Hardware debugging to work.

But the simple

#include "wifi.h"

couldn't be resolved.

the includes:

#include <stdio.h>
#include <inttypes.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_chip_info.h"
#include "esp_flash.h"
#include "esp_system.h"
#include <esp_now.h>

work like a charm.

Astonishing for me also the

#include "C:/Users/"user"/esp/v5.2.1/esp-idf/components/esp_wifi/include/esp_private/wifi.h"

doesn't work.

What could be wrong or what should i do to get this to work.

thx for helping in advance

hape

ESP_Sprite
Posts: 9709
Joined: Thu Nov 26, 2015 4:08 am

Re: include wifi.h can't be resolved in VSCode

Postby ESP_Sprite » Thu Apr 18, 2024 3:01 am

Why would you need wifi.h in the first place? The 'normal' way to include wifi functions is by including esp_wifi.h.

hape65
Posts: 8
Joined: Wed Apr 03, 2024 4:41 pm

Re: include wifi.h can't be resolved in VSCode

Postby hape65 » Thu Apr 18, 2024 9:39 am

hi
thx for answering. I understood your point.
But for me (as a beginner in the ESP32 world) it seems to be easier to make
  1. #include <WiFi.h>
  2. Serial.begin(115200);
  3. Serial.println();
  4. Serial.print("ESP Board MAC Address:  ");
  5. Serial.println(WiFi.macAddress());
as to make this with the correct esp_wifi.h
  1. /*******************************************************************************************
  2.     ESP32: ESP-IDF code creted in VS Code to retrieve the MAC address of the Wifi controller
  3.             Code created by AI and OK1TK with support of the Espressive ESP32 forum
  4.  *******************************************************************************************/
  5. #include <stdio.h>
  6. #include "esp_wifi.h"
  7. #include "esp_log.h"
  8. #include "nvs_flash.h"
  9. void app_main()
  10. {
  11.     esp_err_t ret;
  12.     //Initialize the default NVS partition.
  13.     ret = nvs_flash_init();
  14.     if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
  15.         // If NVS initialization fails due to uncleaned pages or a new version, we clear NVS and try again
  16.         ESP_ERROR_CHECK(nvs_flash_erase());
  17.         ret = nvs_flash_init();
  18.     }
  19.     ESP_ERROR_CHECK(ret);
  20.     // TCP/IP stack initialization
  21.     esp_netif_init();
  22.     esp_event_loop_create_default();
  23.     // Initialization WiFi
  24.     wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
  25.     ret = esp_wifi_init(&cfg);
  26.     if (ret != ESP_OK) {
  27.         ESP_LOGE("WiFi", "WiFi initialization FAILED!: %s", esp_err_to_name(ret));
  28.         return;
  29.     }
  30.     // Retrieving the the MAC address of the WiFi interface
  31.     uint8_t mac[6];
  32.     ret = esp_wifi_get_mac(ESP_IF_WIFI_STA, mac);
  33.     if (ret != ESP_OK) {
  34.         ESP_LOGE("WiFi", "Unable to retrieve the MAC address of the WiFi interface: %s", esp_err_to_name(ret));
  35.         return;
  36.     }
  37.     // Writing the MAC address of the WiFi interface to the terminal
  38.     ESP_LOGI("WiFi", "The WiFi interface MAC address: %02x:%02x:%02x:%02x:%02x:%02x",
  39.              mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
  40. }C:/Users/hape/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/xtensa-esp-elf/include
it could be that i didn't understand the idea behind the esp_wifi.h . i found https://docs.espressif.com/projects/esp ... _wifi.html as documentation.

thx for clearing my confusionv in advance
hape

markkuk
Posts: 38
Joined: Wed Mar 27, 2019 11:50 am

Re: include wifi.h can't be resolved in VSCode

Postby markkuk » Sun Apr 21, 2024 9:43 am

Your first code sample is for the Arduino platform and the second is for ESP-IDF. The private wifi.h header in ESP-IDF isn't the same as the WiFi.h header in Arduino and including it won't provide any Arduino-like functionality for your code.

Who is online

Users browsing this forum: No registered users and 38 guests