I have been playing with a esp8266-01 for the past 4 days, i have been very successful to the extent that i created my own library to host a site via a access point with secure encryption and passwords etc. To start pin 0 and 1 are just a straight through from serial to rx tx so they will only work directly typing from a serial monitor. You need to use say pins 6 and 7 or 2 and 3. apart from that i am shocked that you need 4 libraries to do your task i just needed software serial and so do you, just use the AT commands, i will be very nice and share my basic pre library code i.e. standard arduino code in .ino format which uses far less resources than your code.
you will first need to change your esp8266 baud rate to 9600 from 115200, to do this have your eso8266 wired to pin 0 and 1 like you did and from the serial monitor type
AT+UART_DEF=9600,8,1,0,0
make sure you have no spaces before or after the cmd.
next then change the serial monitor baud rate to 9600 and type AT to confirm the swap worked you should get "OK"
You can run my code its very easy to follow i noted it a lot for you
/*
Arduino Access point Webserver using ESP8266
Displays generated stats in a webpage
*/
#include<SoftwareSerial.h>
#define DEBUG true
SoftwareSerial esp8266(6,7); // pins 6 and 7 as RX and TX
String ssid = "ESP8266";
String password = "Password1";
float temp = 26;
float hum = 50;
int fan1 = 99;
int fan2 = 75;
void setup()
{
Serial.begin(115200); ///////For Serial monitor
esp8266.begin(9600); ///////ESP Baud rate, was at 115200 CHANGED TO 9600 MYSELF AS I HEAR 115200 IS TO HIGH !!!!!!!!!!!!!!!!!!!!!!!!!
sendData("AT+RST\r\n", 2000, DEBUG); // reset module
delay(5000);
sendData("AT+CWMODE=2\r\n", 1000, DEBUG); // configure as access point 2
delay(40);
sendData("AT+CWSAP="" + ssid + "","" + password + "",1,4\r\n", 1000, DEBUG); // configure as access point with secure connection
delay(40);
sendData("AT+CIFSR\r\n", 1000, DEBUG); // show ip address if one is assigned
delay(40);
sendData("AT+CIPMUX=1\r\n", 1000, DEBUG); // configure for multiple connections
delay(40);
sendData("AT+CIPSERVER=1,80\r\n", 1000, DEBUG); // turn on server on port 80
}
int connectionId;
void loop()
{
temp = random(1, 30); // generate some random values for testing
hum = random(30, 99);
fan1 = random(10, 99);
fan2 = random(10, 99);
if (esp8266.available())
{
Serial.print("esp8266 available");
/////////////////////Recieving from web browser to toggle led
if (esp8266.find("+IPD,"))
{
delay(3000);
connectionId = esp8266.read() - 48;
if (esp8266.find("pin="))
{
Serial.println("recieving data from web browser");
int pinNumber = (esp8266.read() - 48) * 10;
pinNumber += (esp8266.read() - 48);
digitalWrite(pinNumber, !digitalRead(pinNumber));
}
/////////////////////Sending data to browser
else
{
String style1 = "";
espsend(style1);
String refresh = "<meta http-equiv="refresh" content="120">"; // refresh every 2 mins
espsend(refresh);
String style2 = "body{background-color:#eef;}h1{color:#00f;text-align:center;font-family:"FS Lola Regular", sans-serif;}";
espsend(style2);
String style25 = "h2{color:#00f;text-align:center;font-family:"FS Lola Regular", sans-serif;}";
espsend(style25);
String style3 = "#di{width:800px;margin:50px auto;padding:20px 0px 30px 0px;background-color:#dff;}";
espsend(style3);
String style4 = "";
espsend(style4);
String webpage = "<div id="di">
Aerium Botanix Realtime Values
";
espsend(webpage);
String add1 = "
Temperature = ";
String two = String(temp, 2);
add1 += two;
add1 += "℃"; //////////Hex code for degree celcius
add1 += "
";
espsend(add1);
String add2 = "
Humidity = ";
String two2 = String(hum, 2);
add2 += two2;
add2 += "%";
add2 += "
";
espsend(add2);
String add3 = "
Fan 1 = ";
String two3 = String(fan1);
add3 += two3;
add3 += "%";
add3 += "
";
espsend(add3);
String add4 = "
Fan 2 = ";
String two4 = String(fan2);
add4 += two4;
add4 += "%";
add4 += "
";
espsend(add4);
String fin = "";
espsend(fin);
String closeCommand = "AT+CIPCLOSE="; ////////////////close the socket connection////esp command
closeCommand += connectionId; // append connection id
closeCommand += "\r\n";
sendData(closeCommand, 3000, DEBUG);
}
}
}
}
//////////////////////////////sends data from ESP to webpage///////////////////////////
void espsend(String d)
{
String cipSend = " AT+CIPSEND=";
cipSend += connectionId;
cipSend += ",";
cipSend += d.length();
cipSend += "\r\n";
sendData(cipSend, 50, DEBUG); // the 50 represent the timout code , increase if you are loosing packets
sendData(d, 50, DEBUG);
}
//////////////gets the data from esp and displays in serial monitor///////////////////////
String sendData(String command, const int timeout, boolean debug)
{
String response = "";
esp8266.print(command);
long int time = millis();
while ( (time + timeout) > millis())
{
while (esp8266.available())
{
char c = esp8266.read(); // read the next character.
response += c;
}
}
if (debug)
{
Serial.print(response); //displays the esp response messages in arduino Serial monitor
}
return response;
}