Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By martinayotte
#60607 Ok ! your code wasn't explicit, especially that Arduino sketch is incomplete and buggy.
The connection isn't shown, the hostname should NOT be "localhost" since you don't wish ESP to connect to itself but to PHP serve with it IP, the "get" should not contain hostname when sending the request, it should only contain path and arguments as :
Code: Select allString req = "/food/conec.php?temperatura="+String(t)+"&wilgotnosc="+String(h);

For more details, look at the WiFiClient example : https://github.com/esp8266/Arduino/blob ... Client.ino

For doing queries instead of data push, simple to something like "/food/conec.php?cmd=querydata" and on PHP side, return a JSON results, the ESP receving that can parse it and to something with the data.
User avatar
By martinayotte
#60619 Check this ArduinoJson library : https://github.com/bblanchon/ArduinoJson
One of their parser example here will show you that, assuming the "char json[]" is intead coming from your server response :
Code: Select allchar json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";

StaticJsonBuffer<200> jsonBuffer;

JsonObject& root = jsonBuffer.parseObject(json);

const char* sensor = root["sensor"];
long time          = root["time"];
double latitude    = root["data"][0];
double longitude   = root["data"][1];