Difference between wifi.h and esp_wifi.h

esp1979
Posts: 21
Joined: Sun Dec 12, 2021 8:55 pm

Difference between wifi.h and esp_wifi.h

Postby esp1979 » Mon Jun 27, 2022 11:04 am

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

lbernstone
Posts: 635
Joined: Mon Jul 22, 2019 3:20 pm

Re: Difference between wifi.h and esp_wifi.h

Postby lbernstone » Mon Jun 27, 2022 2:38 pm

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

Who is online

Users browsing this forum: No registered users and 56 guests