0

I'm making simple web-server on esp8266 module connected to Arduino. And when +IPD,0,GET... I'm sending AT+CIPSEND=0,16. Then I write HELLOMYDEARFRIDE. It says : send 16 bytes recived. OK. But in browser it says me that server haven't given any right response. What is problem in?

Code:

#include <SoftwareSerial.h>


SoftwareSerial softSerial(10, 11);
String ssid = "***";
String password = "***";
String _response = "";
#define DEBUG true
void setup()
{

  Serial.begin(115200);



  softSerial.begin(115200);
  connectWifi();
}

void connectWifi() {

  do {
    sendData("AT+RESTORE\r\n", 5000, DEBUG);
  } while (softSerial.find("OK"));
  do {
    sendData("AT\r\n", 2000, DEBUG);
  } while (softSerial.find("OK"));
  do {
    sendData("AT+CWMODE=1\r\n", 1000, DEBUG);
  } while (softSerial.find("OK"));
  do {
    sendData("AT+CWJAP=\"" + ssid + "\",\"" + password + "\"\r\n", 5000, DEBUG);
  } while (softSerial.find("OK"));

  do {
    sendData("AT+CIFSR\r\n", 1000, DEBUG);
  } while (softSerial.find("OK"));
  do {
    sendData("AT+CIPMUX=1\r\n", 1000, DEBUG);
  } while (softSerial.find("OK"));
  do {
    sendData("AT+CIPSERVER=1,5000\r\n", 1000, DEBUG);
  } while (softSerial.find("OK"));





}

String sendData(String command, const int timeout, boolean debug)
{


  String response = "";

  softSerial.print(command);        long int time = millis();
  while ((time + timeout) > millis())
  {
    while (softSerial.available())
    {
      char c = softSerial.read();
      response += c;
    }
  }

  if (debug)
  {
    Serial.print(response);
  }

  return response;
}
int connectionId,pin;
void loop()
{
    if (softSerial.available()) {
    Serial.write(softSerial.read());
  }
  if (Serial.available()) {
    softSerial.write(Serial.read());
  }







}
  • what is the browser expecting to receive? – jsotola Jun 9 '19 at 22:16
  • Google Chrome is expecting reciving – TheFnafException Jun 10 '19 at 3:28
  • you misunderstand what i asked .... the browser expects the web page to have a specific format .... investigate what the required format is ..... start by saving a simple web page to your computer and then examine the saved file with a text editor – jsotola Jun 10 '19 at 3:46
  • you must return a valid HTTP protocol response – Juraj Jun 10 '19 at 4:45
  • Browser receive a "Hello World!" as html code. And it can be showed as page. – TheFnafException Jun 10 '19 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.