Download – NodeMCU mengambil data dari web server

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
 
const char* ssid = "WIFI KAMU";
const char* password = "PASSWORDNYA";


void setup () {
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  Serial.println("==================================================");
  Serial.println("Hello World!");
  Serial.println("IoT Project - Laurensius Dede Suhardiman!");
  Serial.println("http://laurensius-dede-suhardiman.com/");
  Serial.println("==================================================");
  Serial.println("Setting NodeMCU");
  delay(1000);
  wifiConnecting();
}
 
void loop() {
  String url = "http://api.laurensius-dede-suhardiman.com/index.php/wisatacigugur/get_obyekwisata/";
  if (WiFi.status() == WL_CONNECTED) { 
    HTTPClient http;  
    http.begin(url);  
    int httpCode = http.GET();                                                       
    if (httpCode > 0) { 
      String payload = http.getString();
      Serial.println("HTTP Response Code : ");
      Serial.println(httpCode);
      Serial.println("HTTP Response Payload : ");
      Serial.println(payload);
    }
    http.end();   
  }else
  if (WiFi.status() != WL_CONNECTED) {
    Serial.println("NodeMCU tidak terhubung ke Access Point");
    wifiConnecting();
  }
  delay(5000);
}

void wifiConnecting(){
  while (WiFi.status() != WL_CONNECTED) {
    Serial.println("Menghubungkan ke Access Point");
    for(int c=0;c<3;c++){
      Serial.print(" .");
      delay(1000);  
    }
    Serial.println();
  }
}