Last active
August 23, 2022 07:30
-
-
Save yakutozcan/0cade4d98efca1c3fe2c37bdc85dd404 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <Arduino.h> | |
#include <ESP8266WiFi.h> | |
#include <ESP8266WiFiMulti.h> | |
#include <ESP8266HTTPClient.h> | |
#define USE_SERIAL Serial | |
ESP8266WiFiMulti WiFiMulti; | |
int randTemp; | |
String url; | |
void setup() { | |
USE_SERIAL.begin(115200); | |
USE_SERIAL.println(); | |
USE_SERIAL.println(); | |
USE_SERIAL.println(); | |
for(uint8_t t = 4; t > 0; t--) { | |
USE_SERIAL.printf("[SETUP] WAIT %d...\n", t); | |
USE_SERIAL.flush(); | |
delay(1000); | |
} | |
WiFiMulti.addAP("wifiadi", "wifisifre"); | |
} | |
void loop() { | |
if((WiFiMulti.run() == WL_CONNECTED)) { | |
HTTPClient http; | |
USE_SERIAL.print("[HTTP] begin...\n"); | |
randTemp = random(15, 35); | |
//get isteği yapilan adres lokal ağda bilgisayarınızın ip adresini yazın | |
url = String("http://192.168.2.100/arduyaz.php?deger=yakut"); | |
http.begin(url); //HTTP | |
USE_SERIAL.println(url); | |
USE_SERIAL.print("[HTTP] GET...\n"); | |
int httpCode = http.GET(); | |
if(httpCode > 0) { | |
USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode); | |
if(httpCode == HTTP_CODE_OK) { | |
String payload = http.getString(); | |
//Basarili sekilde gonderilir ise Serial ekrana ok:yakut yazaktır | |
USE_SERIAL.println(payload); | |
} | |
} else { | |
USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str()); | |
} | |
http.end(); | |
} | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment