user83010: I'm trying to get one esp to send integers to a second as a part of a simple remote control, but after multiple days I can't get it to work. The transmitter seems like it's connecting and sending properly as best I can tell, and the receiver is sending some kind of response, but the function I attached with server.on() never gets called.
The code is basically copy and pasted from a tutorial, the only thing I changed was removing code to display the read data to an LCD and display to serial instead.
This is the receiver's code.
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>



const char *ssid = "controllerReceiver";
const char *password = "password";

ESP8266WebServer server(80);



void setup() {
  Serial.begin(115200);

  WiFi.softAP(ssid, password);
  IPAddress myIP = WiFi.softAPIP();

  server.on("/data/", HTTP_GET, handleSentVar);
  server.begin();
  Serial.println("server online");
}

void loop() {
  server.handleClient();

}

void handleSentVar() {
  Serial.println("Handling");
  if (server.hasArg("x_value")) { // this is the variable sent from the client
    int readingInt = server.arg("x_value").toInt();
    Serial.println(readingInt);
    server.send(200, "text/html", "Data received");
  }

}

And here is the transmitter
#include <ESP8266WiFi.h>



const char *ssid = "controllerReceiver";
const char *password = "password";

int outputValue = 999;        

void setup() {
  
  Serial.begin(115200);
  delay(10);

  // Explicitly set the ESP8266 to be a WiFi-client
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    Serial.println("connecting...");
    delay(500);
  }

}

void loop() {

  char intToPrint[5];
  itoa(outputValue, intToPrint, 10); //integer to string conversion for OLED library

  // Use WiFiClient class to create TCP connections
  WiFiClient client;
  const char * host = "192.168.4.1";
  const int httpPort = 80;

  if (!client.connect(host, httpPort)) {
    Serial.println("connection failed");

    return;
  }

  // We now create a URI for the request. Something like /data/?sensor_reading=123
  String url = "/data/";
  url += "x_value=";
  url += intToPrint;

  // This will send the request to the server
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "Connection: close\r\n\r\n");
  unsigned long timeout = millis();
  while (client.available() == 0) {
    if (millis() - timeout > 5000) {
      Serial.println(">>> Client Timeout !");

      client.stop();
      return;
    }
  }

}


user37622: Replace "/data/" with "/data" and url += "x_value=" with url += "?x_value=".
The HTTP GET parameters are separated from the path by "?". The on function is executed for a path ("/data").

83010: <p>I'm trying to get one esp to send integers to a second as a part of a simple remote control, but after multiple days I can't get it to work. The transmitter seems like it's connecting and sending properly as best I can tell, and the receiver is sending some kind of response, but the function I attached with server.on() never gets called.</p>
<p>The code is basically copy and pasted from a tutorial, the only thing I changed was removing code to display the read data to an LCD and display to serial instead.</p>
<p>This is the receiver's code.</p>
<pre><code>#include &lt;ESP8266WiFi.h&gt;
#include &lt;ESP8266WebServer.h&gt;



const char *ssid = &quot;controllerReceiver&quot;;
const char *password = &quot;password&quot;;

ESP8266WebServer server(80);



void setup() {
  Serial.begin(115200);

  WiFi.softAP(ssid, password);
  IPAddress myIP = WiFi.softAPIP();

  server.on(&quot;/data/&quot;, HTTP_GET, handleSentVar);
  server.begin();
  Serial.println(&quot;server online&quot;);
}

void loop() {
  server.handleClient();

}

void handleSentVar() {
  Serial.println(&quot;Handling&quot;);
  if (server.hasArg(&quot;x_value&quot;)) { // this is the variable sent from the client
    int readingInt = server.arg(&quot;x_value&quot;).toInt();
    Serial.println(readingInt);
    server.send(200, &quot;text/html&quot;, &quot;Data received&quot;);
  }

}
</code></pre>
<p>And here is the transmitter</p>
<pre><code>#include &lt;ESP8266WiFi.h&gt;



const char *ssid = &quot;controllerReceiver&quot;;
const char *password = &quot;password&quot;;

int outputValue = 999;        

void setup() {
  
  Serial.begin(115200);
  delay(10);

  // Explicitly set the ESP8266 to be a WiFi-client
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    Serial.println(&quot;connecting...&quot;);
    delay(500);
  }

}

void loop() {

  char intToPrint[5];
  itoa(outputValue, intToPrint, 10); //integer to string conversion for OLED library

  // Use WiFiClient class to create TCP connections
  WiFiClient client;
  const char * host = &quot;192.168.4.1&quot;;
  const int httpPort = 80;

  if (!client.connect(host, httpPort)) {
    Serial.println(&quot;connection failed&quot;);

    return;
  }

  // We now create a URI for the request. Something like /data/?sensor_reading=123
  String url = &quot;/data/&quot;;
  url += &quot;x_value=&quot;;
  url += intToPrint;

  // This will send the request to the server
  client.print(String(&quot;GET &quot;) + url + &quot; HTTP/1.1\r\n&quot; +
               &quot;Host: &quot; + host + &quot;\r\n&quot; +
               &quot;Connection: close\r\n\r\n&quot;);
  unsigned long timeout = millis();
  while (client.available() == 0) {
    if (millis() - timeout &gt; 5000) {
      Serial.println(&quot;&gt;&gt;&gt; Client Timeout !&quot;);

      client.stop();
      return;
    }
  }

}
</code></pre>
 37622: <p>Replace &quot;/data/&quot; with &quot;/data&quot; and <code>url += &quot;x_value=&quot;</code> with <code>url += &quot;?x_value=&quot;</code>.</p>
<p>The HTTP GET parameters are separated from the <em>path</em> by &quot;?&quot;. The <code>on</code> function is executed for <em>a path</em> (&quot;/data&quot;).</p>
