hello
I want get a value from function php da.php
<?php echo 10; ?>and the arduino code is:
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
const char* ssid = "MAURO"; //replace with your own wifi ssid
const char* password = "R000@2021"; //replace with your own wifi ssid password
const char* host = "192.168.0.100";
WiFiClient client;
void setup() {
Serial.begin(115200);
delay(10); // We start by connecting to a WiFi network Serial.println();
Serial.println();
WiFi.mode(WIFI_OFF);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop(){
HTTPClient http;
http.begin(client, "http://192.168.0.100/pr1/da.php");
int httpCode = http.GET();
String payload = http.getString();
Serial.println(httpCode);
Serial.println(payload);
http.end();
delay(5000);
}
but the line httpCode get -1 and payload recover empty.
please help