ESP8266 no getting back any response from local hosted website

Hi everyone,

I heard of esp8266 module in the past but never really use it before. Recently, I need to control servo motors from webpage, looked thru google i found multiple examples which is quite ready for my personal use. I used the example from Web Controlled Servo Motor using Arduino Uno - IoT Project and Web Controlled Servo using Arduino and Wi-Fi. There are few more example which are quite similar too in youtube and other webpage. Looks like many people can use the exact example and it’s working fine. However, I always stuck at not having any response from my webpage even after i obtain my IP address for ESP8266. I have already added the js file in the same directory of my html file. Here are my codes. What could possibly goes wrong? Really sorry that I opened a new thread for this, Im not seeing anyone have exact issue as mine.


#include <SoftwareSerial.h>
#include <Servo.h>
SoftwareSerial esp8266(2,3);
#define DEBUG true
#define sg90_pin 8
Servo sg90;
int current_position = 170;
int vel = 10;
int minimum_position = 20;
int maximum_position = 160;

void setup()
    esp8266Data("AT+RST\r\n", 2000, DEBUG); //reset module
    esp8266Data("AT+CWMODE=1\r\n", 1000, DEBUG); //set station mode
    esp8266Data("AT+CWJAP=\"OnePlus666\",\"12345678\"\r\n", 2000, DEBUG);   //connect wifi network

    while(!esp8266.find("OK")) { //wait for connection
    esp8266Data("AT+CIFSR\r\n", 1000, DEBUG);
    esp8266Data("AT+CIPMUX=1\r\n", 1000, DEBUG);
    esp8266Data("AT+CIPSERVER=1,80\r\n", 1000, DEBUG);

void loop()
    if (esp8266.available())
        if (esp8266.find("+IPD,"))
            String msg;
            msg = esp8266.readStringUntil(' ');
            String command = msg.substring(0, 3);
            String valueStr = msg.substring(4);
            int value = valueStr.toInt();
            if (DEBUG) 

            //move servo1 to desired angle
              if(command == "sr1") 
                  //limit input angle
                  if (value >= maximum_position) 
                      value = maximum_position;
                   if (value <= minimum_position) 
                       value = minimum_position;
                  sg90.attach(sg90_pin); //attach servo
                  while(current_position != value) 
                      if (current_position > value) 
                          current_position -= 1;
                      if (current_position < value) 
                          current_position += 1;
                  sg90.detach(); //dettach
String esp8266Data(String command, const int timeout, boolean debug)
    String response = "";
    long int time = millis();
    while ( (time + timeout) > millis())
        while (esp8266.available())
            char c =;
            response += c;
    if (debug)
    return response;

html code

<!DOCTYPE html >
<title>Web controlled Servo</title>
<script src="jquery.js"></script>
<h1> <b> Arduino Web Controlled Servo by Electrosome </b> </h1>
<h4> <b> Enter the IP address below </b> </h4>
<div style="margin: 0; width:500px; height:80px;">
		ESP8266 IP Address:
		<INPUT TYPE="text" NAME="inputbox" VALUE="">
<h3> Scroll it to move the servo </h3>
<input type="range" min="20" max="170" onmouseup="servo1(this.value)" />

function servo1(angle)
	TextVar = form.inputbox.value;
	ArduinoVar = "http://" + TextVar + ":80";
	$.get( ArduinoVar, { "sr1": angle })	;
	{Connection: close};

Is it correct that the above Arduino code runs on a AVR Arduino (UNO, Mega2560, etc.)?

In this case it won’t work reliably because a SoftwareSerial at 57600 won’t work as expected. SoftwareSerial is usable up to about 9600baud, 19200baud if the counterpart is very timing tolerant. But as SoftwareSerial disables interrupts for extended periods of time your servo probably won’t react correctly anymore. Change to hardware serial even if that means you loose the debugging channel.

Additionally I would expect your JS code to fail because it doesn’t fulfill the same origin policy (JS code can access only the server it originates from).

If you still have problems, post a link to the hardware you use (ESP8266 comes in hundreds of different versions. The firmware is relevant for the functionality).