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

Moderator: igrr

User avatar
By LOLotavio
#57824 #include <ESP8266WiFi.h>
const char* ssid = "NIGELVIADO";
const char* password = "*********";
const char* host = "meuservidor.com";
int ledPinWifiConnect = 13;
int porta = 80;
void setup() {
Serial.begin(115200);
delay(10);
pinMode(ledPinWifiConnect, OUTPUT);
//Conectando Com o Wifi
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
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() {
WiFiClient client;
// se tem conexão com a internet led azul aceso
if(WiFi.status() == WL_CONNECTED){
digitalWrite(ledPinWifiConnect,HIGH);
}
else{
digitalWrite(ledPinWifiConnect,LOW);
}
delay(5000);
Serial.print("connecting to ");
Serial.println(host);
// Usando o WiFiCliente para criar uma conexao TCP
if (!client.connect(host,porta)) {
Serial.println("connection failed");
return;
}
// criando um URL para o request
String url = "/arduino.php?loja=12";
Serial.print("Requesting URL: ");
Serial.println(url);
// ENVIANDO O GET PARA O REQUEST
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
unsigned long timeout = millis();
while (client.available() == 0) {
if (millis() - timeout > 5000) {
Serial.println(">>> Client Timeout !");
client.stop();
return;
}
}
// Lendo todas as linhas da resposta e printando na Serial
while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
}
//client.stop();
//client.setNoDelay(true);
Serial.println();
Serial.println("closing connection");
}
Resposta :Connecting to NIGELVIADO
..
WiFi connected
IP address:
connecting to
Requesting URL: /arduino.php?loja=12
HTTP/1.1 200 OK
Date: Tue, 08 Nov 2016 12:06:41 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PHP/5.5.9-1ubuntu4.17
Access-Control-Allow-Origin: *
Content-Length: 282
Connection: close
Content-Type: application/json; charset=utf-8
{"post_recebido":[],"get_recebido":{"loja":"12"},"pedido":[{"codigo":0,"string":"--------------\nLanch\u00e3o Sem Fim--------------\n\nValor: R$ 45\nEndere\u00e7o: X\n"},{"codigo":1,"string":"--------------\nLanch\u00e3o Sem Fim--------------\n\nValor: R$ 50\nEndere\u00e7o: X\n"}]}
closing connection
connecting to
connection failed
connecting to
connection failed
connecting to
....

Ty for the quick answer .