WiFi.begin(ssid,password);//--> Connect to your WiFi router
Serial.println("");
pinMode(ON_Board_LED,OUTPUT);//--> On Board LED port Direction output
digitalWrite(ON_Board_LED,HIGH);//--> Turn off Led On Board
pinMode(LED_D8,OUTPUT);//--> LED port Direction output
digitalWrite(LED_D8,LOW);//--> Turn off Led
//----------------------------------------Wait for connection
Serial.print("Connecting");
while(WiFi.status()!=WL_CONNECTED){
Serial.print(".");
//----------------------------------------Make the On Board Flashing LED on the process of connecting to the wifi router.
digitalWrite(ON_Board_LED,LOW);
delay(250);
digitalWrite(ON_Board_LED,HIGH);
delay(250);
//----------------------------------------
}
//----------------------------------------
digitalWrite(ON_Board_LED,HIGH);//--> Turn off the On Board LED when it is connected to the wifi router.
//----------------------------------------If successfully connected to the wifi router, the IP Address that will be visited is displayed in the serial monitor
Serial.println("");
Serial.print("Successfully connected to : ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
Serial.println();
//----------------------------------------
}
voidloop(){
// put your main code here, to run repeatedly:
HTTPClienthttp;//--> Declare object of class HTTPClient
//----------------------------------------Getting Data from MySQL Database
StringGetAddress,LinkGet,getData;
intid=0;//--> ID in Database
GetAddress="dbread.php";
LinkGet=host+GetAddress;//--> Make a Specify request destination
getData="ID="+String(id);
Serial.println("----------------Connect to Server-----------------");
Serial.println("Get LED Status from Server or Database");
inthttpCodeGet=http.POST(getData);//--> Send the request
StringpayloadGet=http.getString();//--> Get the response payload from server
Serial.print("Response Code : ");//--> If Response Code = 200 means Successful connection, if -1 means connection failed. For more information see here : https://en.wikipedia.org/wiki/List_of_HTTP_status_codes