Skip to content

Instantly share code, notes, and snippets.

@ryanbekabe
Forked from yakutozcan/phpNodeMCU.ino
Created August 23, 2022 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanbekabe/f43177c449c15cc8900ee29dfaeca1cc to your computer and use it in GitHub Desktop.
Save ryanbekabe/f43177c449c15cc8900ee29dfaeca1cc to your computer and use it in GitHub Desktop.
#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