ESP8266 Webserver Project

Moderator: Sprite_tm

User avatar
By patana93
#90675 Hello everyone!

I'm trying to use and ESP8266 module with an Arduino to turn on/off a Philips hue light bulb. I've already set the Philips account and it work perfectly with the browser. Now I've tried to do the same thing with that HW configuration but I always fail to connect to the bridge. So I've used a NodeMCU board to simulate a webserver to see if the problem is the bridge but again with browser works and with the board I cannot connect to the server. At the moment I have switched the role so I'm running the web server on the Arduino+ESP and the client on my NodeMCU in order to use the ESP8266HTTPClient.h and ESP8266WiFi.h libraries that are more powerful than WiFiEsp.h to do http request.
Ah, if I tried the example to connect to the Arduino page to get the logo in ASCII the sketch works perfectly so I think that the problem is to establish the connection locally.

About code, I avoid to write the webserver because I have change anything.
Instead the important part about the client is this:

Code: Select all 

....

WiFiClient client;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  Serial.println("Connecting to WiFi");
  Serial.println(WiFi.localIP());
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print(".");
  }
  Serial.println("Connected to the WiFi network"); 

.....


if(client.connect("http://192.168.1.128", 80)){
     client.print("GET ");
     client.println(" HTTP/1.1");
     client.stop();
  } else {
    Serial.println("Unable to connect to server");
  }


I always get Unable to connect to server. I've also tried to use just the IP without http://.

Any help?

Thanks in advance!