Problems with the NodeMCU ESP8266

Hi everyone, I have viewed a small web create by the NodeMCU ESP8266, and when I connect to it on my computer, it works. But when I connect to it using other devices, it cant connect, apparently, only my computer only can connect to it, hope to hear your advice.
Here is that simple web.

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
 
// Replace with your network credentials
const char* ssid = "VLDCNC2";
const char* password = "khoavatly02";
 
ESP8266WebServer server(80);   //instantiate server at port 80 (http port)
 
String page = "";
int LEDPin = 13;
void setup(void){
  //the HTML of the web page
  page = "<h1>Simple NodeMCU Web Server</h1><p><a href=\"LEDOn\"><button>ON</button></a>&nbsp;<a href=\"LEDOff\"><button>OFF</button></a></p>";
  //make the LED pin output and initially turned off
  pinMode(LEDPin, OUTPUT);
  digitalWrite(LEDPin, LOW);
   
  delay(1000);
  Serial.begin(115200);
  WiFi.begin(ssid, password); //begin WiFi connection
  Serial.println("");
 
  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
   
  server.on("/", [](){
    server.send(200, "text/html", page);
  });
  server.on("/LEDOn", [](){
    server.send(200, "text/html", page);
    digitalWrite(LEDPin, HIGH);
    delay(1000);
  });
  server.on("/LEDOff", [](){
    server.send(200, "text/html", page);
    digitalWrite(LEDPin, LOW);
    delay(1000); 
  });
  server.begin();
  Serial.println("Web server started!");
}
 
void loop(void){
  server.handleClient();
}

Can't get what you mean, I think you need to give more details: which are the devices you tried? How connected to your network, and using what browser? How do you call the page (i.e. the URL) from your PC and how from the other devices? What do you mean with "can't connect" ("apparently"), do you receive an error message?

1 Like

Okay, so as you can see, the code will print the IP adress using the serial monitor, and I will search that adress on the search bar to go the the web. When I use my computer to upload the code, I can go the the website on my computer, but I cant go to it using my friend's phone or computer.

What's more, when I use my friends computer to upload the code, I cant even go to the website using their computer too!
And when I say can't connect, it means that when they type the IP adress on the search bar and press enter, it says that the site can't be reach, like the following:

I can only say you should remember you can't use https to call Arduino if it handles http only. The picture you added here doesn't show Arduino IP address, here you tried to open youtube and failed for a DNS error, not site unreachable or not responding.

I have asked you some information you missed to give us, so please now answer all the questions so I can try and help you.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.