1

I have an ESP8266 Node MCU and am learning to use its wifi capabilities. In my home I have a router provided by my ISP that runs a network we'll call 'network1'. I also have an Eero mesh network that runs in the house, called 'network2'.

When I upload the following minimal example and use network1,

  1. my 8266 device connects to network1 (the messages in the serial monitor confirm this) and
  2. I can use my phone and laptop to connect to the 8266 - i.e., I can put the IP into my browser and see a webpage telling me 'Hello World'.

However, I have trouble with network2, the Eero network.

  1. I can connect my 8266 device to network2 (the messages in the serial monitor confirm this) but
  2. I can't connect to the 8266 device with my phone/laptop. (Yes, I switch these over to network2 first.) I put the new IP into my browser and I am told the page is taking too long to respond.

I haven't done anything special with my network1 router; things just worked. With network2, I've tried various settings with my Eero - given the 8266 a static IP address, enabled port forwarding (on port 80) and established a firewall rule for it, but nothing works.

I can run many different programs through network1, and nothing works on the Eero network. Any suggestions on getting things to work?

My minimal working example:

#include <ESP8266WiFi.h>

const char* ssid = "network1"; // or 'network2'
const char* password = "thepassword"; // real password used in code

WiFiServer server(80); //just pick any port number you like

void setup() {
  Serial.begin(115200);
  
  // Connect to WiFi network
  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");

  // Start the server
  server.begin();
  Serial.println("Server started");

  // Print the IP address
  Serial.println(WiFi.localIP());
  //gateway = WiFi.gatewayIP();
  Serial.print("GATEWAY: ");
  Serial.println(WiFi.gatewayIP());

  // print your subnet mask:
  //subnet = WiFi.subnetMask();
  Serial.print("NETMASK: ");
  Serial.println(WiFi.subnetMask());
}

void loop() {
  // Check if a client has connected
  WiFiClient client = server.available();
  if (!client) {
    return;
  }

  // Prepare the response
  String s = "HTTP/1.1 200 OK\r\n";
  s += "Content-Type: text/html\r\n\r\n";
  s += "<!DOCTYPE HTML>\r\n<html>\r\n";
  s += "<head>\r\n";
  s+= "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\r\n";
  s+= "<title>ESP Web Server</title>\r\n";
  s+= "</head>\r\n";
  s += "Hello World";
  s += "</html>\n";

  client.flush();

  // Send the response to the client
  client.print(s);
  delay(1);
}
5
  • I'm not totally sure, but have you successfully connected any two devices on the Eero network? I wonder if you could add some Serial.println() to the loop() to verify that things are working as expected in network1 and then see where things break down for network2. – garson Dec 7 '20 at 12:20
  • @garson Do you mean connecting two ESP8266s & have them talk to each other? I have done things like get my iPhone to screencast to my Roku; in that sense, I've had devices on the Eero network talk together just fine. But not any devices that I've programmed. – GregH Dec 7 '20 at 14:28
  • Yes, that's what I meant. Hmm. This suggests restarting the eero. support.eero.com/hc/en-us/articles/…. Printing confirmations to the log when someone accesses the ESP (on network1, and then trying on network2) may point you in the right direction but I'm not sure. – garson Dec 7 '20 at 16:01
  • no matter what, you want to use the server.on() methods instead of that painful low level packet handling in loop(). – dandavis Dec 8 '20 at 7:49
  • @dandavis Will that help with the Eero issue, or just make for better page building once I get to making real applications? At the moment, learning to write good code is secondary to getting something working. – GregH Dec 8 '20 at 11:40
1

I was able to find an answer though I'm not sure why it works. It comes down to adding WiFi.mode(WIFI_STA); in the setup, as in

void setup() {
  
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  ...
  }

I was able to replicate success with another file on my ESP8266 device and Eero network as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.