Open beicnet opened 4 years ago
Unfortunately this issue #111 [minimal example for ESP32] was locked. I could find no solution till now and opend a thread at https://forum.arduino.cc/t/using-arduinohttpclient-lib-with-esp32/902455
I tried this ...
#include <ArduinoHttpClient.h>
#include <WiFi.h>
#include <WiFiMulti.h>
WiFiMulti wifiMulti;
WiFiClient wifi;
HttpClient http(wifi,"arduino.cc",80);
void setup() {
Serial.begin(115200);
wifiMulti.addAP("your-ssid","your-pw");
// attempt to connect to WiFi
Serial.print("Connecting to Wifi ... ");
while (wifiMulti.run() != WL_CONNECTED) {
// unsuccessful, retry in 4 seconds
Serial.print("failed ... ");
delay(4000);
Serial.print("retrying ... ");
}
Serial.println("WiFi connected");
}
void loop() {
Serial.println("making GET request");
http.get("/asciilogo.txt");
// read the status code and body of the response
int statusCode = http.responseStatusCode();
String response = http.responseBody();
Serial.print("Status code: ");
Serial.println(statusCode);
Serial.print("Response: ");
Serial.println(response);
Serial.println("Wait five seconds");
delay(5000);
}
but it stalls after
Connecting to Wifi ... WiFi connected
making GET request
Status code: -3
Response:
Wait five seconds
Is the Arduino - WiFiClient used in the ArduinoHttpClient lib not compatible with the ESP32 implementaton (e.g. used in https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/examples/WiFiClient/WiFiClient.ino)?
WiFiClient client;
is called in loop()
in the ESP32 / espressif example while WiFiClient wifi;
is called already before setup()
in https://github.com/arduino-libraries/ArduinoHttpClient/blob/master/examples/SimpleGet/SimpleGet.ino ?? Is it perhaps the same syntax but different functions?
How can I get working the ArduinoHttpClient library with an ESP32? Any chance?
Hi there,
Can someone give me for this library the simplest GET example sketch?
Thank you!
Kind regards, Viktor