Go Down

Topic: Wemos get data from MYSQL (Read 1 time) previous topic - next topic

Tvojmuc

I wondering way this code is not working when I try to connect to my home server?

Code: [Select]
void getWeatherHome() //client function to send/receive GET request data.
//http://tvojmuc.com/WemosData.php
{
  Serial.println("PHP");
  if (client.connect(server, 80)) {  //starts client connection, checks for connection
    client.println("GET /WemosData.php HTTP/1.1");
    client.println("Host: tvojmuc.com");
    client.println("Connection: close");
    client.println();
  }

  else {
    Serial.println("connection failed on PHP"); //error message if no client connect
    Serial.println();
  }
  while(client.connected() && !client.available()) delay(5); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
     
    result = result+c;
    }
    Serial.println(result);
  client.stop(); //stop client
  start=false;
  Serial.println(start);
  Serial.println(result);

int indexA=100;
int indexB=100;
String resuD[4];

indexA = result.indexOf("Date",indexB);
indexB = result.indexOf(")",indexA);
String a = result.substring(indexA + 5, indexB);
resuD[0]= a;// String(day(t)) + "." + mesec[month(t)] + "." + year(t);//datum

indexA = result.indexOf("v",indexB);
indexB = result.indexOf("}",indexA);
resuD[1] = result.substring(indexA + 2, indexB);//Temperatura

indexA = result.indexOf("v",indexB);
indexB = result.indexOf("}",indexA);
resuD[2] = result.substring(indexA + 2, indexB);//Vlaga

indexA = result.indexOf("v",indexB);
indexB = result.indexOf("}",indexA);
resuD[3] = result.substring(indexA + 2, indexB);//napetost

for (int x=0;x<4;x++){
Serial.println(resuD[x]);
}
result="";

}

If I go to browser and entered in
Code: [Select]
http://tvojmuc.com/WemosData.php

I got normal response, but with Wemos...just empty...nothing!
Any Idea?

rw950431

What is logged on the server side when your Wemos makes its request?

Tvojmuc

I got it work. I change from request like in code to  "http.begin xxxxxxxxxxxxxxx" with diferen tliberis and is working now.
Login is working because I have to steps to get json from two different web pages. On one is working but on second which is not "Query" request but GET .php page was not working.
So now I managed to work both.

Go Up