ESP8266 using Arduino IDE

Hi guys, I got a Esp8266 WiFi board which I am trying to use with Arduino IDE to connect to a WiFi Network and then use an HTTP Post HTML PAGE to send an information and display On a LCD.

Currently I am stuck on the use of ESP8266 WIFI Board , I can’t get it connected to my WiFi Such that it shows me through the arduino IDE serial monitor the IP address of the server so I can access the HTML page.

Do you guys have any idea on how to do it ?

I can post my sketch code if you need .

Waiting for your replies, Thanks .

Post the sketch.

Provide a better explanation of the problem you're having.

Thanks for your reply Pert

Here is my code :

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

const char* WifiName="Super Network";
const char* WifiPass="Fesa77796";

ESP8266WebServer server(80);

const char htmlPage[]PROGMEM=R"=====(
<HTML>
<HEAD>
<TITLE>Post Request</TITLE>
</HEAD>
<BODY>
<CENTER>
<B> 
LED
Status =@@LEDstate@@</B>
</CENTER> 
<FORM METHOD="POST" action="/">
<BUTTON name="LED" value="1"> ON </BUTTON> 
<BUTTON name="LED" value="0"> OFF </BUTTON> 
</FORM>
<marquee Behavior="alternate"> NodeMCU ESP8266 </marquee>
</BODY>
</HTML>
)=====";

void handleRoot()
{
  String LEDstate, webPage;
  webPage=htmlPage;
  LEDstate=server.arg("LED");
  Serial.print("Argument Received");
  Serial.println(LEDstate);
  
if (LEDstate=="1")
{
  digitalWrite(D2,0);
  webPage.replace 
  ("@@LEDState@@","ON");
  }
if(LEDstate=="0")
  {
   digitalWrite(D2,1);
  webPage.replace 
  ("@@LEDState@@","OFF"); 
    }
      server.send(200,"text/html",webPage);
}
   void setup()
   {
  Serial.begin(115200);
  delay(10);
  pinMode(D2,OUTPUT);
  Serial.println();
  Serial.print("Connecting");
  WiFi.begin(WifiName,WifiPass);
  while(WiFi.status()!= WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
    }
 Serial.println("");
 Serial.print("Wi-Fi Connected");
 Serial.println("IP Address is:");
 Serial.println(WiFi.localIP());
server.on("/",handleRoot);
server.begin();
Serial.println("HTTP Server Started");    
  // put your setup code here, to run once:
}


void loop() {
  server.handleClient();
  // put your main code here, to run repeatedly:

}

The problem is that the serial monitor doesnt pop up to display the IP Address of the HTTP server at which the HTML page is, once I uploaded this sketch onto the Esp8266 WifiBoard using my WIFI credentials .

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn't show the posting toolbar then you can just manually add the code tags:
[code]``[color=blue]// your code is here[/color]``[/code]
Using code tags and other important information is explained in the How to use this forum post. Please read it.

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read. If you're using the Arduino Web Editor you will not have access to this useful tool but it's still unacceptable to post poorly formatted code. I recommend you to use the standard IDE instead.

You still haven't properly explained what the problem is.

Thanks Pert, I have modified the post , please check and let me know if you understand .

If you still dont understand the forget about that code, What
I Want is to create a Server to host a simple Html page with a button and a text box to send whatever I type in the text box to the Esp8266 ,process it and eventually display it on a LCD.

CiscoFrancis:
I have modified the post

You forgot to auto format the code.

CiscoFrancis:
The problem is that the serial monitor doesnt pop up to display the IP Address of the HTTP server at which the HTML page is, once I uploaded this sketch onto the Esp8266 WifiBoard using my WIFI credentials .

You need to open the Serial Monitor. It won't pop up. You can open it via Tools > Serial Monitor or by clicking the magnifying glass icon at the top right of the Arduino IDE.

When I open it shows funny characters , it doesn’t Show what it was supposed to, like connecting to” Network”, “IP Address” , “connection successful, in other words it doesn’t print the message in my code .

Is your baud rate is set to 115200 (in the bottom right of the serial monitor)? As this is what you have set your Serial up as in your code.

Thanks for your reply Pinja
Yes , the baud rate is set to 115200 as in my code .

this is what I am getting , can't figure out what I am doing wrong.

Ah! Your ESP is crashing. That is the trace dump. Check out the ESP Exception Decoder. It should point you at the bit of your code causing the trouble.

Thanks Pijan, I will have a look .

ERROR: xtensa-lx106-elf-gdb.exe not found!

I just fired up your sketch, and needed to define D2 before it would compile for me. Once I put in correct WiFi details it successfully launched a webpage and it changes the LED. Although the text on the webpage does not update. Sounds like something you can tinker with (I don't think you can edit the const char array) so long as you can find the source of your crashing. Im using an ESP Huzzah module btw.

That's Great, I still can't find the source of crashing , do u think that it could be my Wi-Fi Board ?

Can you post the output of the exception decoder? Also what board are you using? And what version of the esp core?

When I run the exception decoder I run into an error :ERROR: xtensa-lx106-elf-gdb.exe not found!

Arduino: 1.8.7 (Windows 10), Board: "ESP8266 NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, 4M (1M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch,

This thread might be what you need.

Arduino: 1.8.7 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, 4M (1M SPIFFS), v2

You'll want to stick a resistor in series with that LED! Somewhere around 100+ ohms should do for starters. This might well be the cause of your troubles here. It's certainly not doing your ESP any good without one.

this is the output of the Exception Decoder
It is not the LED because I tried another code just for simple Wifi Connection and I got the same error .