#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "Wokwi-GUEST"; // Wifi
const char* password = ""; //Password Wifi
const char* serverName = "http://we.ngarduino.com/sendMessage.php";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.println("Connecting");
while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to WiFi network with IP Address: ");
Serial.println(WiFi.localIP());
}
void loop() {
if(WiFi.status()== WL_CONNECTED){
HTTPClient http;
http.begin(serverName);
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
String key = "B9T7shSBQSUbLLB0MeqkeJHZ2ePDzzJq"; //your key
String message ="hello from ngarduino";
String requestData = "key="+key+"&message="+message;
int httpResponseCode = http.POST(requestData);
String payload = http.getString();
Serial.println(payload);
http.end();
}
else {
Serial.println("WiFi Disconnected");
}
delay(30000);
}