Newbie WeMos D1 WiFi Uno: Can't communicate from iPhone

(I'm a newbie and i thought i submitted this post a day ago, but cannot find it; please excuse me if I actually sent it prior)

Wiring is laptop USB to WeMos D1 WiFi Uno and Pin D5 to resistor to LED to GRD. My Sketch below appears to work such that in the SerialMonitor when I type Y/N it turns on/off the LED.

My problem is I can't communicate from my iPhone via WiFi to my WeMos board.
FYI:
SerialMonitor Shows:
Connecting to (...my SSID...)
WiFi Connected
Server started
Use this URL : http://192.168.1.223
LED OFF
LED ON
LED OFF

(also...I used first an iPhone App called Fing to search for devices and found that this URL has a HOST NAME of esp-00ab68.lan)

On my iPhone on Google I typed in URL I get message "Could not find website" Then I tried typing in the host name and got the same message. Lastly I went to iPhone SETTINGS and WiFi and I typed in the URL (and host name) and got the same message.

Would appreciate it if someone could tell me if my Sketch (below) needs any changes? and.....Am I doing something wrong when using my iPhone to connect to the WeMos D1 URL ?

Thank You for any guidance you can give me.

/*
 * ESP8266 (WeMosD1) WiFi Relay Control
 * 
 * learnelectronics
 * 05 JUN 2017
 * 
 * www.youtube.com/c/learnelectronics
 * arduino0169@gmail.com
*/

//   WeMos D1 WiFi UNO connected via USB to Desktop PC
//   Pin D5 to resistor to led to GRND

#include <ESP8266WiFi.h>
 
const char* ssid = "my_SSID";
const char* password = "my_PASSWORD";
 
int ledPin = D5;
WiFiServer server(80);
 
void setup() 

{
  Serial.begin(115000);
  delay(10);
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);
  // Connect to 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");
  // Start the server
  server.begin();
  Serial.println("Server started");
  // Print the IP address
  Serial.print("Use this URL : ");
  Serial.print("http://");
  Serial.print(WiFi.localIP());
  Serial.println("/");
}

void loop() 
{
    Serial.available();
  char ch = Serial.read();
  if (ch == 'y' || ch == 'Y')  
{
    digitalWrite(ledPin, HIGH);
      Serial.print("LED ON");
       Serial.println("");
}  
  if (ch == 'n' || ch == 'N')
{
    digitalWrite(ledPin, LOW);
     Serial.print("LED OFF");
      Serial.println("");    
}  
}

you are not running a Webserver on the WeMos D1 - your loop is just reading y or n from the keyboard to switch the LED on or off.
Have a look at ESP8266WiFi webserver or WiFi Access Point and webserver

You need to accept incoming WiFi connections:

  WiFiClient client = server.available();
  if (client)
  {
    String request = client.readString();
    Serial.prinln("Request received:");
    Serial.println(request);
    // This is where you would send the response
    }

Horace,
Thank you, I had no idea about Webserver Access Point, Sorry, didn't know...that makes sense.

I clicked on your first weblink and just kept getting Waiting to connect (repeatedly). I then went to your second weblink and couldn't find any Code.
So using your advice, I found Sketch below. I was thrilled to see the results:

"On Serial Monitor"
waiting to connect
IP address : 192.168.1.223
Server Listening

"On Laptop "
typed in IP address and got
Hello, this is an index page

"On iPhone"
typed in IP address and got

Cannot find network

I know I'm so close....thank you....so my questions are now:

a) why couldn't my iPhone find the network in my Sketch below....do I have a sketch issue (and as a newbie, I didn't know what to type-in or what to do with "Server Listening" and "Hello, this is an index page"

b) assuming I can fix the iPhone issue (a) above, where in the Sketch below would I add my "original void loop" to turn on/off LED?

{
Serial.available();
char ch = Serial.read();
if (ch == 'y' || ch == 'Y')
{
digitalWrite(ledPin, HIGH);
Serial.print("LED ON");
Serial.println("");
}
if (ch == 'n' || ch == 'N')
{
digitalWrite(ledPin, LOW);
Serial.print("LED OFF");
Serial.println("");
}
}

My current SKETCH IS BELOW.
Thank you Horace ! (as an aside I also got a reply in my post from johnwasser, but I didn't want to get overwhelmed trying to follow your post and his at the same time)

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

ESP8266WebServer server(80);

const char* ssid = "my_SSID"; //Enter Wi-Fi SSID
const char* password = "my_PASSWORD"; //Enter Wi-Fi Password

void setup() {
Serial.begin(115200); //Begin Serial at 115200 Baud
WiFi.begin(ssid, password); //Connect to the WiFi network

while (WiFi.status() != WL_CONNECTED) { //Wait for connection
delay(500);
Serial.println("Waiting to connect...");
}

Serial.print("IP address: ");
Serial.println(WiFi.localIP()); //Print the local IP

server.on("/", handle_index); //Handle Index page

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

void loop() {
server.handleClient(); //Handling of incoming client requests
}

void handle_index() {
//Print Hello at opening homepage
server.send(200, "text/plain", "Hello! This is an index page.");
}

strange - if I click on links they work OK!

I assume your phone can see the network
when you click on the SSID does it request the password and then fail?

the code to switch the LED is AP and webserver

I put in my SSID and Password, loaded it on to an ESP8266 (NodeMCU 1.0 clone) and was able to connect to it from my iPhone. The Serial Monitor says:

Waiting to connect...
Waiting to connect...
Waiting to connect...
IP address: 192.168.1.6
Server listening

and when I tell Safari on my iPhone to connect to 192.168.1.6 it shows:
`Hello! This is an index page.'

That's what you programmed the sketch to do so it is working fine. Are you not able to connect to your ESP8266 webserver? Is your iPhone on the same WiFi network as your ESP8266?

Hi John,
I'm using a WeMos D1_WiFi_UNO board (I'm not sure if that makes any difference).

I agree with you, in that I too feel the sketch is working fine...because I get "Server listening" in SerialMonitor and "Hello! this is an index page" on my computer

I'll try to answer your questions as best I can.

Are you not able to connect to your ESP8266 webserver?
I assume yes, I can, since I can get to it via my computer. But if that's not what you"re asking, please let me know.

Is your iPhone on the same WiFi network as your ESP8266?

The iPhone is connected to my home modem WiFi (SSID)
My computer and printer and my wife's iPhone are all connected to the same SSID.
As for the ESP8266 (WeMos_D1_WiFi_UNO) I think it's on the same SSID since I'm doing all this in my home and I typed in my actual SSID and password in the Sketch. But if that doesn't answer your question, let me know what more I need to do to answer it.

John, I've NEVER used any other WiFi Network (SSID) while in my home, and this the the first time I'm attempting to create and use an AccessPoint Webserver.....I think that's what this Sketch is supposed to do.

FYI, I have a relatively new iPhone (which is my FIRST iPhone....had a flip phone before.....my Grandkids shamed me into getting an iPhone😀)

I don't know if I have to change an iPhone setting or something. I must be doing something wrong with the iPhone. This is how I attempted to get into the WiFi access point.

And John, I'm s****orry for the details, but I don't know any other way to describe what I'm going through !
(not to mention I'm 78, but I'm active and my mind is fine; I research stuff, build things in my workshop, and do all household repairs, yesterday put in a furnace Condensate Pump)

APPROACH ONE:
I open the iphone, click on Settings, go to WiFi and there I see my home SSID name and there is check-mark next to it, and it shows it's ON.

I scroll down to where it says Other, then it has 3 boxes:

Network Name (which is blank)
Security (which shows as WPA2/WPA3)
Password (which is blank)

Tried the following 2 attempts:

Name: 192.168.1.223
Security: I changed it to None: which then did NOT ask for a password
I clicked JOIN and got "Could not find the Network 192.168.1.223"

Name:192.168.1.223
Security: I left WPA2/WPA3 as-is
Password: and then, no-matter what I would type...JOIN was greyed-out so it wouldn't let me even attempt to join.

APPROACH TWO:

On my iPhone I opened Google and in the address bar at the very top, I typed in 192.168.1.223 and it gave me search-results...so I knew that was wrong.
I then typed in the word "hat" and clicked on any one that popped up. I then went to the top of the address bar and typed in 192.168.1.223 and got "Could not find Network 192.168.1.223"

I'm stumped at the moment. I sure would appreciate any suggestions you might have.
Thank You, Richard (by the way, fyi, I'm in West Boylston, MA, USA, not sure what Country you are in.....no need for you to mention that though)

Hi Horace,
I feel the sketch I posted is working fine...because I get "Server listening" in SerialMonitor and "Hello! this is an index page" on my computer

The problem is when I try to access it with my iPhone

I'll try to answer your questions as best I can.
I assume your phone can see the network
I don't think so.

when you click on the SSID does it request the password and then fail

Here's what I've done (please excuse the details, but i don't know of any other way to tell you what I'm going through)

APPROACH ONE:
I open the iphone, click on Settings, go to WiFi and there I see my home SSID name and there is check-mark next to it, and it shows it's ON.

I scroll down to where it says Other, then it has 3 boxes:

Network Name (which is blank)
Security (which shows as WPA2/WPA3)
Password (which is blank)

Tried the following 2 attempts:

Name: 192.168.1.223
Security: I changed it to None: which then did NOT ask for a password
I clicked JOIN and got "Could not find the Network 192.168.1.223"

Name:192.168.1.223
Security: I left WPA2/WPA3 as-is
Password: and then, no-matter what I would type...JOIN was greyed-out so it wouldn't let me even attempt to join.

APPROACH TWO:

On my iPhone I opened Google and in the address bar at the very top, I typed in 192.168.1.223 and it gave me search-results...so I knew that was wrong.
I then typed in the word "hat" and clicked on any one that popped up. I then went to the top of the address bar and typed in 192.168.1.223 and got "Could not find Network 192.168.1.223"

I'm stumped at the moment. I sure would appreciate any suggestions you might have.
(Oh...being a newbie on the forum, I'm not sure if I did something wrong...another guy johnwasser sent me an emai...and I responded back as an Email.....does that appear as a Reply by me in the forum, or is that sort-of a private message to him......and by the way, by me sending YOU this email, I hope I'm not double responding as a forum Reply)

Thank You, Richard

if I run your code from post #4 the serial monitor displays

Waiting to connect...
IP address: 192.168.1.94
Server listening

I connect my Android phone to my home network and the web browser and it displays

Hello! This is an index page.

screen dump
android_1
you should be able to

  1. connect the iPhone to your home network
  2. run web browser
  3. enter URL (the IP your Serial Monitor says)
    it should connect to the webserver and display "Hello! This is an index page"

you are confusing two difference senarios

  1. A WiFi end device which connects to a WiFi network and runs a webserver
    e.g. this is the code of your post #4 and which I ran in post #9
    it connected to my home network which gave it the IP 192.168.1.94
    I could then run a web browser on any PC in the network to view the web page

  2. a WiFi Access Point which runs a webserver, i.e. it creates its own WiFi network sometimes called a WiFi Hotspot
    Sample code

//  using WEMOS D1 R1 ESP8266 basd board

/* Create a WiFi access point and provide a web server on it. */
/* For more details see http://42bots.com.
*/

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

IPAddress    apIP(42, 42, 42, 42);  // Defining a static IP address: local & gateway
                                    // Default IP in AP mode is 192.168.4.1

/* This are the WiFi access point settings. Update them to your likin */
const char *ssid = "ESP8266";
const char *password = "";

// Define a web server at port 80 for HTTP
ESP8266WebServer server(80);

const int ledPin = D5; // an LED is connected to WeMos pin D5 (ESP8266 GPIO14) via a 1K Ohm resistor

bool ledState = false;

void handleRoot() {
  digitalWrite (LED_BUILTIN, 0); //turn the built in LED on pin DO of NodeMCU on
  digitalWrite (ledPin, server.arg("led").toInt());
  ledState = digitalRead(ledPin);

 /* Dynamically generate the LED toggle link, based on its current state (on or off)*/
  char ledText[80];
  
  if (ledState) {
    strcpy(ledText, "LED is on. <a href=\"/?led=0\">Turn it OFF!</a>");
  }

  else {
    strcpy(ledText, "LED is OFF. <a href=\"/?led=1\">Turn it ON!</a>");
  }
 
  ledState = digitalRead(ledPin);

  char html[1000];
  int sec = millis() / 1000;
  int min = sec / 60;
  int hr = min / 60;

  int brightness = analogRead(A0);
  brightness = (int)(brightness + 5) / 10; //converting the 0-1024 value to a (approximately) percentage value

// Build an HTML page to display on the web-server root address
  snprintf ( html, 1000,

"<html>\
  <head>\
    <meta http-equiv='refresh' content='10'/>\
    <title>ESP8266 WiFi Network</title>\
    <style>\
      body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; font-size: 1.5em; Color: #000000; }\
      h1 { Color: #AA0000; }\
    </style>\
  </head>\
  <body>\
    <h1>ESP8266 Wi-Fi Access Point and Web Server Demo</h1>\
    <p>Uptime: %02d:%02d:%02d</p>\
    <p>Brightness: %d%</p>\
    <p>%s<p>\
    <p>This page refreshes every 10 seconds. Click <a href=\"javascript:window.location.reload();\">here</a> to refresh the page now.</p>\
  </body>\
</html>",

    hr, min % 60, sec % 60,
    brightness,
    ledText
  );
  server.send ( 200, "text/html", html );
  digitalWrite ( LED_BUILTIN, 1 );
}

void handleNotFound() {
  digitalWrite ( LED_BUILTIN, 0 );
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += ( server.method() == HTTP_GET ) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";

  for ( uint8_t i = 0; i < server.args(); i++ ) {
    message += " " + server.argName ( i ) + ": " + server.arg ( i ) + "\n";
  }

  server.send ( 404, "text/plain", message );
  digitalWrite ( LED_BUILTIN, 1 ); //turn the built in LED on pin DO of NodeMCU off
}

void setup() {
  pinMode ( ledPin, OUTPUT );
  digitalWrite ( ledPin, 0 );
  for(int i=0;i<10;i++)
    { digitalWrite (ledPin, HIGH); delay(100); digitalWrite (ledPin, LOW); delay(100); }
  
  delay(1000);
  Serial.begin(115200);
  Serial.println();
  Serial.println("Configuring access point...");

  //set-up the custom IP address
  WiFi.mode(WIFI_AP_STA);
  WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));   // subnet FF FF FF 00  
  
  /* You can remove the password parameter if you want the AP to be open. */
  WiFi.softAP(ssid, password);

  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);
 
  server.on ( "/", handleRoot );
  server.on ( "/led=1", handleRoot);
  server.on ( "/led=0", handleRoot);
  server.on ( "/inline", []() {
    server.send ( 200, "text/plain", "this works as well" );
  } );
  server.onNotFound ( handleNotFound );
  
  server.begin();
  Serial.println("HTTP server started");
}

void loop() {
  server.handleClient();
}

when I run the program the Serial Monitor displays

Configuring access point...
AP IP address: 42.42.42.42
HTTP server started

when I run a WiFi scan on my Android phone it shows a new network "ESP8266"
it is an open network so I just connect
I then run a web browser and enter the URL as IP address "42.42.42.42" and the web page is displayed

You don't. Both the ESP8266 and the iPhone being connected to the home WiFi should be sufficient.

That might be the problem. The iPhone default web browser is "Safari" and the icon looks like a round, light-blue magnetic compass. There are optional browsers, like "Google Chrome" whose icon is a blue dot surrounded by a circle with red, yellow, and green segments. The "Google" app is like a web browser but dedicated to search. Try Safari.

Note: The default ESP8266 behavior is "Station" mode where it connects to an existing WiFi network. The other mode is "Access Point" mode where it creates a new and separate WiFi network. That's for mobile use where you don't have a known WiFi network to join. That is the case where the iPhone would connect to the network created by the ESP8266. Save that for another time. :slight_smile:

John & Horace,

You guys are "awesome"

You devote your free time to helping absolute strangers. I truly appreciated your assistance. I can't thank you enough.

You SOLVED my problem of not being able to connect via my iPhone. See Photo and my Sketch below

a) I now understand the diff between Web Server and an Access Point. As you point out, I DO NOT need to create an AP if I'm in my home (or in any other WiFi Area (say my children's home)

b) The suggestion to access via SAFARI solved my problem of "Could not find the Network 192.168.1.223"

I spent countless hours last night and today editing sketches and trying diff approaches on the iPhone.

Turns out (.....once it fully sank into my SeniorCitizen brain haha) that I had to open the actual Safari site.....well, when I click on Safari on my iPhone there are multiple icon to pick (google, yahoo, etc).

Not knowing what the actual Safari site is, finally, I clicked on Apple.com icon. Then I typed in 192.168.1.223 and it connecte.....every time.

Now that I can, so-to-speak, Control things via WiFi on my iPhone (using Arduino, ESP8266) it opens up endless opportunities (as everyone mentions on the internet) ....for fun or actual usage

For now, I'm going to just enjoy playing with the on-off approach to things for a bit; I think Poppie will impress his Grandkids !!

Once I get enough experience playing with this, I think my "next-level" project will be to try to "input text via iPhone" to my Parola LED scrolling box I made earlier. I really enjoy learning new stuff about Arduino.

Again, thank you BOTH for your expert help. Regards, Richard (below is my Sketch and Photo)

/*
   ESP8266 (WeMosD1) WiFi Relay Control

   learnelectronics
   05 JUN 2017

   www.youtube.com/c/learnelectronics
   arduino0169@gmail.com
*/


//  (NOTE: with LED loop)

//  (SerialMonitor OK "Server Listening")

//  (iPhone>Safari>click Apple ICON> MUST VIP "type-in the 192#" OK "Led pin is REALLY now: on"

//

#include <ESP8266WebServer.h>
#include <ESP8266WiFi.h>
const char* ssid = "my_home_WiFi_SSID";
const char* password = "my_PASSWORD";

int ledPin = D7;
WiFiServer server(80);

void setup() {
  Serial.begin(115200);
  delay(10);


  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);

  // Connect to 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");

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

  // Print the IP address
  Serial.print("Use this URL : ");
  Serial.print("http://");
  Serial.print(WiFi.localIP());
  Serial.println("/");

}

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

  // Wait until the client sends some data
  Serial.println("new client");
  while (!client.available()) {
    delay(1);
  }

  // Read the first line of the request
  String request = client.readStringUntil('\r');
  Serial.println(request);
  client.flush();

  // Match the request

  int value = LOW;
  if (request.indexOf("/LED=ON") != -1) {
    digitalWrite(ledPin, HIGH);
    value = HIGH;
  }
  if (request.indexOf("/LED=OFF") != -1) {
    digitalWrite(ledPin, LOW);
    value = LOW;
  }



  // Return the response
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println(""); //  do not forget this one
  client.println("<!DOCTYPE HTML>");
  client.println("<html>");

  client.print("Thanks to HORACE and JOHN Led pin now: ");

  if (value == HIGH) {
    client.print("On");
  } else {
    client.print("Off");
  }
  client.println("<br><br>");
  client.println("Click <a href=\"/LED=ON\">here</a> Turn LED ON<br>");   //THIS APPEARS ON iPHONE
  client.println("<br><br>");
  client.println("Click <a href=\"/LED=OFF\">here</a> Turn LED OFF<br>"); //THIS APPEARS ON iPHONE
  client.println("</html>");

  delay(1);
  Serial.println("Client disconnected");
  Serial.println("");

}

Hi,
I unfortunately have an ooooops. I was running the sketch below a day or two ago, and was able to use WiFi on my iPhone to turn ON-OFF one LED.

But now....using the same Sketch as before (see below)....I have a problem. I open Safari, type in just "1" (I don't get a chance to even type the rest 192.168.1.223 and in SerialMonitor it says "new client" and then disconnects me. See Photo below.

Then after it disconnects me, I see on Safari, my 192.168.1.223 number, so I click on it, and get the WiFi remote screen saying Press "here" to turn on the LED......but when I press on "here" it says "new client" and does the same thing....disconnects me.

As a TEST, I changed my WeMos D1WiFi UNO board with a second identical board (and resulted in a different 192 number) and then when I when i try to use Safari and type in just a "1" I get the same message in the SerialMonitor as in the photo below).
Can someone please let me know how I could fix this problem ? (or what I am doing wrong)

I was excited about being able to turn ON-OFF an LED via my WiFi. And now I want to go from turning ON-OFF an LED to using a relay and turning ON-OFF a lamp....

But I can't start that, until I am able to get back to communicating with WiFi on my iPhone.
Thank You !
!
SERIAL MONITOR|666x500

My Sketch:

#include <ESP8266WebServer.h>
#include <ESP8266WiFi.h>
const char* ssid = "my_SSID";
const char* password = "my_PASSWORD";

int ledPin = D7;
WiFiServer server(80);

void setup() {
  Serial.begin(115200);
  delay(10);


  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);

  // Connect to 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");

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

  // Print the IP address
  Serial.print("Use this URL : ");
  Serial.print("http://");
  Serial.print(WiFi.localIP());
  Serial.println("/");

}

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

  // Wait until the client sends some data
  Serial.println("new client");
  while (!client.available()) {
    delay(1);
  }

  // Read the first line of the request
  String request = client.readStringUntil('\r');
  Serial.println(request);
  client.flush();

  // Match the request

  int value = LOW;
  if (request.indexOf("/LED=ON") != -1) {
    digitalWrite(ledPin, HIGH);
    value = HIGH;
  }
  if (request.indexOf("/LED=OFF") != -1) {
    digitalWrite(ledPin, LOW);
    value = LOW;
  }

  // Return the response
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println(""); //  do not forget this one
  client.println("<!DOCTYPE HTML>");
  client.println("<html>");

  client.print("The LED pin is now: ");

  if (value == HIGH) {
    client.print("On");
  } else {
    client.print("Off");
  }
  client.println("<br><br>");
  client.println("Click <a href=\"/LED=ON\">here</a> Turn LED ON<br>");   //THIS APPEARS ON iPHONE
  client.println("<br><br>");
  client.println("Click <a href=\"/LED=OFF\">here</a> Turn LED OFF<br>"); //THIS APPEARS ON iPHONE
  client.println("</html>");

  delay(1);
  Serial.println("Client disconnected");
  Serial.println("");

}

if I run the code in your latest post it connects to the WiFi network OK
I run a web client on my PC 192.168.1.94 and can switch LED ON/OFF
e.g. a run

WiFi connected
Server started
Use this URL : http://192.168.1.94/
new client
GET / HTTP/1.1
Client disconnected

new client
GET /LED=ON HTTP/1.1
Client disconnected

new client
GET /LED=OFF HTTP/1.1
Client disconnected

new client
GET /LED=ON HTTP/1.1
Client disconnected

new client
GET /LED=OFF HTTP/1.1
Client disconnected

also works on my Samsung Android phone OK

does your iphone connect to your home WiFi OK?
can you browse google etc etc?
if so you should be able to connect to the ESP8266

Hi Horace,
That's great news that you can turn the LED on/off with Android or iPhone. As you concluded, that means the Sketch is OK.

Here's what I tried since I got your reply:
(a) I rebooted my Modem (for the heck of it)

(b) Using my iPhone w/Safari
First, I click on SerialMonitor and click reset on the WeMos board and I get....Connecting to OCEANVIEW etc

Then I go to my iPhone and get the WiFi page... Click "here" Turn LED ON

Then I click on the "here" for ON or OFF (see Photo of SerialMonitor)
I can click it to on and off etc back and forth and although it shows on the SerialMonitor, it doesn't turn the LED on or off.

(c) Using my Computer w/Safari (tried that rather than Google for the heck of it)
First, I click on SerialMonitor and click reset on the WeMos board and I get....Connecting to OCEANVIEW etc

Then I go to my Computer and get the WiFi page... Click "here" Turn LED ON

Then I click on the "here" for ON or OFF (see Photo of SerialMonitor)
I can click it to on and off etc back and forth and although it shows on the SerialMonitor, it doesn't turn the LED on or off.

(d) I then repeated (b) and (c) above with another identical WeMos board (that was 192.168.223) and got the SAME results above.

(e) I rechecked the two jumpers from the board to the resistor/LED and they were proper

(f) As another check, I ran a simple on/off sketch on just an UNO board. And the LED's went on and off as I set in that sketch. So that told me the LED was OK.

As TWO added pieces of information:

(1) you will notice that on the SerialMonitor Photo when using my Computer. it shows ..... GET / favicon.ico HTTP/1.1 (notice the word favicon)

(2) when I saw the word favicon, that REMINDED ME of something I did right before I started to have the problem with LED's not lighting (at least I think it may (?) have been just before my problem). What I had done at that time....I was googling about webservers and came across a site (I believe it was a favicon website) that said create your own webserver, and it had an Arduino Sketch. I copied it and it wanted me to type in three things, SSID, PASSWORD and then it had a place for a web address.....so I typed in 192.168.1.223 and ran it. I assumed it ran, but I didn't know what to do next, so I just exited out of that Sketch.

I'm really trying hard to give as much information as I can and that's why I was glad I could give a little bit more info above in (1) and (2).

And to answer your questions: My iPhone connects perfectly with my Home WiFi and it's always been that way, and I can browse the internet (Google etc etc.) perfectly.

Something is just not allowing the signal to go to the LED ????
I'm grasping at straws and scrathing my head trying to figure this out....as you can imagine for a newbie, this is a bit stressful too.
Thank you

when I run your code it connects to the WiFi and I can connect a web browser to 192.168.1.94 and switch the LED on/off OK
check your LED connection it is D7

int ledPin = D7;

try updating setup() to

void setup() {
  Serial.begin(115200);
  delay(10);
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);
  Serial.println();
  Serial.println("LedPin ");
  Serial.println(ledPin);
  // Connect to WiFi network
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
  Serial.println("");
  Serial.println("WiFi connected");

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

  // Print the IP address
  Serial.print("Use this URL : ");
  Serial.print("http://");
  Serial.print(WiFi.localIP());
  Serial.println("/");

}

to test the LED it blinks the LED while the WiFi is connecting

1 Like

Horace,
Thank You Very Much......It worked....blinks while connecting AND both my Computer and iPhone connect to it via WiFi and I can turn ON-OFF the LED from either device.
Been tying it for hours, from time to time, just to make sure I have repeatability. I am clicking on Solved for this Post. Many thanks; your efforts are well appreciated. Have a wonderful day.
( I will be posting a new comment, but I read that a forum member shouldn't add multiple topics to one post.)

Good to hear is now working!
if you have a new project/problem it is OK to start a new post
it is creating multiple posts on the same topic that is banned - see read-this-before-posting-a-programming-question

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