Page 1 of 1

Difference between wifi.h and esp_wifi.h

Posted: Mon Jun 27, 2022 11:04 am
by esp1979
Hi,

i'm using an ESP32 with the Arduino IDE and use the Wifi.h library actually.
Now i've seen, that there is also an esp_wifi.h library.

Does this library:
- provide additional functions, means can be used in parallel OR
- is an alternative library you can use instead of wifi.h? If yes: Is it better to use esp_wifi.h instead of wifi.h and why?

I hope to get an answer this time... last two posts are unanswerd ;-(

Best regards
Daniel

Re: Difference between wifi.h and esp_wifi.h

Posted: Mon Jun 27, 2022 2:38 pm
by lbernstone
TL;DR: WiFi.h uses the Arduino API and is much easier for noobs.
esp_wifi.h is part of the esp-idf. That is the primary framework for writing esp32 apps in C (it includes methods to compile on the command line). It does have additional functionality that is not exposed in arduino. WiFi.h is the arduino library. arduino-esp32 is a wrapper (HAL) around the esp-idf that provides the arduino API for use in C++/Arduino environments (Arduino IDE, platformio, eclipse, etc). WiFi.h is a much simpler interface, and has hundreds of examples out there in the public domain. WiFi.h is making calls to the underlying esp_wifi.h.
You can compare the examples for each library. Making a STA connection in arduino is essentially a single line of code.
https://github.com/espressif/esp-idf/bl ... ple_main.c
https://github.com/espressif/arduino-es ... Client.ino