ESP have an ip but don't communicate with any thing
Posted: Thu Aug 27, 2015 9:47 am
Hi,
I have a problem, i execute this simple code - send an http request :
When I am on the router 2 (a simple hotspot router on a android phone) the code works.
When I am on the router 1 (a livebox supply by my internet provider), i have an IP address, i can see the ESP in the router (it's a web interface) but i can't get any result form the request (and i can't ping the module). The router don't route anything.
Of course the router have access to internet and from a computer connect to the router in wifi with the Curl command, the request work.
Have you some idea for me ?
Regards,
I have a problem, i execute this simple code - send an http request :
Code: Select all
#include <ESP8266WiFi.h>
//Router 1 - Livebox
const char* ssid = "Livebox-9e38";
const char* password = "xxxxxxxxxxx";
//Router 2 - Android phone
//const char* ssid = "DARKSIDE";
//const char* password = "xxxxxxxxx";
// server address:
char server[] = "www.arduino.cc";
//IPAddress server(64,131,82,241);
WiFiClient client;
unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
const unsigned long postingInterval = 10L * 1000L; // delay between updates, in milliseconds
void setup() {
Serial.begin(115200);
delay(10);
// We start by connecting to a WiFi network
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 httpRequest() {
// close any connection before send a new request.
// This will free the socket on the WiFi shield
client.stop();
// if there's a successful connection:
if (client.connect(server, 80)) {
Serial.println("connecting...");
// send the HTTP PUT request:
client.println("GET /latest.txt HTTP/1.1");
client.println("Host: www.arduino.cc");
client.println("User-Agent: ArduinoWiFi/1.1");
client.println("Connection: close");
client.println();
// note the time that the connection was made:
lastConnectionTime = millis();
} else {
// if you couldn't make a connection:
Serial.println("connection failed");
}
}
void loop() {
// if there's incoming data from the net connection.
// send it out the serial port. This is for debugging
// purposes only:
while (client.available()) {
char c = client.read();
Serial.write(c);
}
// if ten seconds have passed since your last connection,
// then connect again and send data:
if (millis() - lastConnectionTime > postingInterval) {
httpRequest();
}
}
When I am on the router 2 (a simple hotspot router on a android phone) the code works.
When I am on the router 1 (a livebox supply by my internet provider), i have an IP address, i can see the ESP in the router (it's a web interface) but i can't get any result form the request (and i can't ping the module). The router don't route anything.
Of course the router have access to internet and from a computer connect to the router in wifi with the Curl command, the request work.
Have you some idea for me ?
Regards,