Hello, I need your help... : smiley-confundir:
I want to reflect the temperature and humidity data on a web page
The localhost is created, I can access it from my PC and also from my cell phone to change the data by url(attached file).
but when I want to send dynamic values by programming (sensor), I can't access the request (second code).
I would be very grateful if you help me, in order to solve my error
P.S. excuse my writing
#include <ESP8266WiFi.h>
#include <DHT.h>
const char* ssid = "TP-Link";
const char* password = "tp-link";
const char* host ="192.168.0.135";
//definiendo el modelo de sensor y el pin al que estara conectado
#define DHTTYPE DHT11
#define DHTPIN 2 //GPI02
DHT dht (DHTPIN, DHTTYPE, 11);
float( temperatura);
float(humedad);
void setup() {
Serial.begin(115200);
Serial.println("");
dht.begin();
//estableciendo coneccion a wifi
WiFi.begin(ssid, password);
while(WiFi.status() !=WL_CONNECTED){
delay(500);
}
Serial.println(" conectado");
}
void loop() {
WiFiClient client;
Serial.printf("\n[conectando a %s...", host);
if (client.connect(host, 80)){
Serial.println("conectado]");
temperatura= dht.readTemperature();
humedad= dht.readHumidity();
//verificacion de lectura del sensor
Serial.println(temperatura);
Serial.println(humedad);
Serial.println("[envianndo una solicitud");
client.print(String("GET /proyectos_web/HTML/ejemplo2.php/?Temp=") + temperatura + "&Hum=" + humedad + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n" +
"\r\n"
);
Serial.println("[respuesta]");
while(client.connected()){
if(client.available()){
String line = client.readStringUntil('\n');
Serial.println(line);
}
}
client.stop();
Serial.println("\n[desconectando]");
}
else{
Serial.println("conexion fallida");
client.stop();
}
delay(5000);
}
.. conectado
[conectando a 192.168.0.135...conexion fallida
[conectando a 192.168.0.135...conexion fallida
[conectando a 192.168.0.135...conexion fallida
[conectando a 192.168.0.135...conectado]
24.20
64.00
[envianndo una solicitud
[respuesta]
[desconectando]
[conectando a 192.168.0.135...conectado]
23.90
65.00
[envianndo una solicitud
[respuesta]
[desconectando]
[conectando a 192.168.0.135...conectado]
23.90
65.00
[envianndo una solicitud
[respuesta]
[desconectando]