Last active
April 9, 2020 18:46
-
-
Save ahmethakanbesel/29160f355e3d7415baf007aaf6ca44ab to your computer and use it in GitHub Desktop.
ESP8266 GET Request http://ahmethakanbesel.com.tr/esp8266-internetten-veri-cekme
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 <ESP8266WiFi.h> | |
#include <ESP8266HTTPClient.h> | |
const char* ssid = ""; | |
const char* password = ""; | |
const String url = "http://api.ipify.org"; | |
void setup() { | |
Serial.begin(115200); | |
Serial.println(""); | |
Serial.print("Bağlanılıyor "); | |
Serial.print(ssid); | |
WiFi.begin(ssid, password); | |
while (WiFi.status() != WL_CONNECTED) { | |
delay(500); | |
Serial.print("."); | |
} | |
Serial.println(""); | |
Serial.println("WiFi bağlantısı kuruldu."); | |
Serial.println("Yerel IP adresi: "); | |
Serial.print(WiFi.localIP()); | |
Serial.println(""); | |
} | |
void loop() { | |
if (WiFi.status() == WL_CONNECTED) { | |
HTTPClient http; | |
http.begin(url); | |
int httpCode = http.GET(); | |
if (httpCode > 0) { | |
String payload = http.getString(); | |
Serial.println("Sayfa yanıtı:"); | |
Serial.println(payload); | |
} | |
http.end(); | |
} | |
delay(30000); // 30 saniyede bir işlemi tekrarlayacak | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment