Last active
September 20, 2024 15:13
-
-
Save brulint/278ae1c8b7cd90cc5ea370beb55749a8 to your computer and use it in GitHub Desktop.
Send a simple HTTP request over Wifi with ESP32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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