Skip to content

Instantly share code, notes, and snippets.

@brulint
Last active September 20, 2024 15:13
Show Gist options
  • Save brulint/278ae1c8b7cd90cc5ea370beb55749a8 to your computer and use it in GitHub Desktop.
Save brulint/278ae1c8b7cd90cc5ea370beb55749a8 to your computer and use it in GitHub Desktop.
Send a simple HTTP request over Wifi with ESP32
#include <WiFi.h>
#include <HTTPClient.h>
void setup() {
Serial.begin(115200);
while (!Serial) continue;
WiFi.begin("your SSID", "p4sswOrd");
while (WiFi.status() != WL_CONNECTED) delay(500);
HTTPClient http;
http.begin("https://example.com");
int httpCode = http.GET();
if (httpCode == HTTP_CODE_OK) {
Serial.println(http.getString());
} else {
Serial.printf("failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
}
void loop() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment