So, I got this webserver running using: http://arduino.esp8266.com/stable/package_esp8266com_index.json V2.4.1
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include "index.h" //html page
const char* ssid "xxx" // WiFi SSID
const char* password "xxx" // WiFi password
//Creat object
ESP8266WebServer server ( 301 );
void handleRoot()
{
String getPage = MAIN_page; // read html contents
if ( server.hasArg("dir") )
{
handleDir();
}
else if ( server.hasArg("spd") )
{
handleSpeed();
}
else
{
server.send ( 200, "text/html", getPage );
}
}
void handleDir()
{
String DirValue = server.arg("dir");
Serial.println(DirValue);
}
void handleSpeed()
{
String SpeedValue = server.arg("spd");
Serial.println(SpeedValue);
}
void setup()
{
//SerialCom
Serial.begin(115200, SERIAL_8N1);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while ( WiFi.status() != WL_CONNECTED )
{
delay(500); Serial.print(".");
}
//Connection stable ok
Serial.println("");
Serial.print("Connected to: " ); Serial.println( ssid );
Serial.print("IP address: "); Serial.println(WiFi.localIP());
//????
server.on ( "/", handleRoot );
server.begin();
Serial.println("HTTP server started" );
}
void loop()
{
server.handleClient();
delay(500);
}
After I updated the html page and flashed the esp8266 again (with Arduino IDE), for some reason, the esp8266 never connects to the wifi, therefore, never leaves
while ( WiFi.status() != WL_CONNECTED )
{
delay(500); Serial.print(".");
}
Another thing that's intriguing, is that I only get garbage in the Serial Monitor at 115200 baud rate, and at 74880 I get some information about the board, "Serial.print("Connecting to "); Serial.println(ssid);" is garbage too, but the dots are well received.
So I thought my board was damaged for something I did wrong. Then I tried to flash the firmware (ESP8266_NONOS_SDK-2.2.0) again to test it with AT Commands. And all worked really fine, I could change the baudrate to any I wanted and still works fine, connected and disconnected to my wifi without problems.
I tried again with Arduino IDE, but the same error keeps appearing.
The last thing I remembered to do was use the "WiFi101 firmware updater" that comes with the boards manager of esp8266, but couldn't even get past the first point "test connection".
Any ideas? (sorry any error in my writting)