Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Aster
#79866 hello,

if i go to the github library repo there are a lot of wireless library i could use.
For example now i am using the esp8266 to control a GoPro action camera with the ESP8266WiFi library and it works well, but I received a pull request to use the ESP8266HTTPClient.

Could someone explain me which is the difference between these two and maybe also all the other libs i see in the repo?
User avatar
By btidey
#79869 ESP8266Wifi gives raw access to wifi functions independent of the protocol you are going to use.

WifiClient can send and receive data to a server but you have to format the data yourself e.g. message headers and parsing the response.

ESP8266HTTPClient specifically knows how to communicate with a http web server and does all the formatting and parsing needed.

They are actually a hierarchy. ESP8266HTTPClient uses WifiClient uses the raw functions.

If you are making http requests like GET or POST then it is normally best to use the ESP8266HTTPClient to keep the application code simpler and to benefit from the tried and tested HTTP handling.
User avatar
By Aster
#79871
btidey wrote:ESP8266Wifi gives raw access to wifi functions independent of the protocol you are going to use.

WifiClient can send and receive data to a server but you have to format the data yourself e.g. message headers and parsing the response.

ESP8266HTTPClient specifically knows how to communicate with a http web server and does all the formatting and parsing needed.

They are actually a hierarchy. ESP8266HTTPClient uses WifiClient uses the raw functions.

If you are making http requests like GET or POST then it is normally best to use the ESP8266HTTPClient to keep the application code simpler and to benefit from the tried and tested HTTP handling.


@btidey thanks for the explanation it was exactly what i was looking for!
As a dump person i used the WifiClient and formatted all the request and responses on my own because i wasn't aware of this :lol: i will switch immediately to the HTTPClient :P

do you have any knowledge about esp32? I guess it is the same since i see both a wifi and a http client https://github.com/espressif/arduino-es ... /libraries could you confirm this? :D
User avatar
By btidey
#79874 Yes, same applies to ESP32. Use HTTPClient for normal web server access.

I started off using WifiClient and formatting stuff up as that what some examples showed. I then discovered the HTTPClient which has simplified things a lot. It is relatively easy to switch over as it normally means deleting excessive stuff and replacing with much simpler calls.