user59358: I am trying to connect my nodemcu client with nodemcu server, while my client is connected with two sensors (DHT11 and Soil Moisture) and it is workign perfectly, but on the server side I am unable to get all values, it is only giving me value of one parameter.
Server Side Code

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
String apiWritekey = "PBD5LAJC4BSV3OKC"; // replace with your THINGSPEAK WRITEAPI key here
const char* ssid = "Dhamaal";// your wifi SSID name
const char* password = "03334204224" ;// wifi pasword
///~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~///



///~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~///
const char* httpserver = "api.thingspeak.com";
ESP8266WebServer server;
WiFiClient client;


// Configuration parameters for Access Point
char * ssid_ap = "ESP_AP";
char * password_ap = "123456789";
IPAddress ip(192,168,11,4); // arbitrary IP address (doesn't conflict w/ local network)
IPAddress gateway(192,168,11,1);
IPAddress subnet(255,255,255,0);
// Set up the server object

// Keep track of the sensor data that's going to be sent by the client
float t1=0.0;
float h1=0.0;
float s1=0.0;

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


  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(ip,gateway,subnet);
  WiFi.softAP(ssid_ap,password_ap);

  // Configure the server's routes
  server.on("/",handleIndex); // use the top root path to report the last sensor value
  server.on("/update",handleUpdate); // use this route to update the sensor value
  server.begin();
}
void handleIndex() {
    server.send(200,"text/plain",String(t1));
    server.send(200,"text/plain",String(h1));
    server.send(200,"text/plain",String(s1));// we'll need to refresh the page for getting the latest value
}

void handleUpdate() {


  // The value will be passed as a URL argument
 t1 = server.arg("value").toFloat();
  h1 = server.arg("value").toFloat();
  s1 = server.arg("value").toFloat();

  delay(100);
  WiFi.begin(ssid, password);

  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

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

  Serial.println();
  Serial.println("");
  Serial.print("NodeMcu connected to wifi...");
  Serial.println(ssid);
  Serial.println();
  Serial.println(WiFi.localIP() );


  delay(1000);
  ///~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~///
 float t2 = t1;
 float h2 = h1;
 float s2 = s1;
  if (client.connect(httpserver,80))
  {  
         String tsData = apiWritekey;
           tsData+="&field1=";
           tsData+=String(t2);
           tsData+="&field2=";
           tsData+=String(h2);
           tsData +="&field3=";
           tsData += String(s2);
           tsData += "\r\n\r\n";

     client.print("POST /update HTTP/1.1\n");//command to update
     client.print("Host: api.thingspeak.com\n");//host name here thingspeak.com
     client.print("Connection: close\n");//closing connection
     client.print("X-THINGSPEAKAPIKEY: "+apiWritekey+"\n");
     client.print("Content-Type: application/x-www-form-urlencoded\n");
     client.print("Content-Length: ");
     client.print(tsData.length());
     client.print("\n\n");  // the 2 carriage returns indicate closing of Header fields & starting of data
     client.print(tsData);

     Serial.print("Temp: ");
     Serial.print(t2);//printing on serial monitor
     Serial.print("Humi: ");
     Serial.print(h2);
     Serial.print("Soil: ");
     Serial.print(s2);
     Serial.println("uploaded to Thingspeak server....");//dialogue box
  //}
  digitalWrite(D4, LOW); 



  client.stop();//stopping client

  Serial.println("Waiting to upload next reading...");
  Serial.println();
  delay(5000);



} }

void loop() {
server.handleClient();

}

and the output of it is 

while the code of my client is
#include <DHT.h>
#include <ESP8266WiFi.h>

// Initialize sensor parameters
// Initialize network parameters
const char* ssid = "ESP_AP";
const char* password = "123456789";
const char* host = "192.168.11.4"; // as specified in server.ino

#define DHTPIN 0          //pin where the dht11 is connected

DHT dht(DHTPIN, DHT11);

// Set up the client objet
WiFiClient client;

// Configure deep sleep in between measurements
const int sleepTimeSeconds = 2;

void setup() {

  // Connect to the server
  WiFi.begin(ssid,password);
  Serial.begin(115200);
  dht.begin();
  while(WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.print("IP Address (AP): "); Serial.println(WiFi.localIP());


void loop() {
  // put your main code here, to run repeatedly:
   while (WiFi.status() == WL_CONNECTED) {
    delay(500);
    int s = analogRead(A0);
    float h = dht.readHumidity();
    float t = dht.readTemperature();
  Serial.print("Temperature: "); Serial.println(t);
  Serial.print("Humidity: "); Serial.println(h);
  Serial.print("Soil Moisture: "); Serial.println(s);
  // Connect to the server and send the data as a URL parameter
  if(client.connect(host,80)) {
    String url = "/update?value=";
    url += String(t);
    String url1 = "/update?value=";
    url1 += String(h);
    String url2 = "/update?value=";
    url2 += String(s);
    client.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host +  "\r\n" + 
                 "Connection: keep-alive\r\n\r\n"); // minimum set of required URL headers
     client.print(String("GET ") + url1 + " HTTP/1.1\r\n" + "Host: " + host +  "\r\n" + 
                 "Connection: keep-alive\r\n\r\n"); // minimum set of required URL headers
     client.print(String("GET ") + url2 + " HTTP/1.1\r\n" + "Host: " + host +  "\r\n" + 
                 "Connection: keep-alive\r\n\r\n"); // minimum set of required URL headers
    delay(5000);

  }
    // Read all the lines of the response and print them to Serial
    Serial.println("Response: ");
    while(client.available()){
      String line = client.readStringUntil('\r');
      Serial.print(line);
  }
}
}

and its output is 

Kindly help me to get all values at server side, Thanks

user37622: You use the same name value for all /update? parameters. And the format of url parameters is ?name1=value1&name2=value2
Use 
String url = "/update?t=";
url += String(t);
String url1 = "&h=";
url1 += String(h);
String url2 = "&s=";
url2 += String(s);

send it as one GET request
and read server.arg("t"),  server.arg("h") and  server.arg("s").
Note 1: Sending more responses with serverSend to one request from browser has no effect. Only the first will work.
Note 2: this kind of use of String class will fragment the memory and cause a crash
Note 3: You don't need to use HTTP to communicate between your devices over TCP network. You can use simple TCP socket connections without HTTP protocol overhead.

59358: <p>I am trying to connect my nodemcu client with nodemcu server, while my client is connected with two sensors (DHT11 and Soil Moisture) and it is workign perfectly, but on the server side I am unable to get all values, it is only giving me value of one parameter.
Server Side Code
</p>

<pre class="lang-cpp prettyprint-override"><code>#include &lt;ESP8266WiFi.h&gt;
#include &lt;ESP8266WebServer.h&gt;
String apiWritekey = "PBD5LAJC4BSV3OKC"; // replace with your THINGSPEAK WRITEAPI key here
const char* ssid = "Dhamaal";// your wifi SSID name
const char* password = "03334204224" ;// wifi pasword
///~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~///



///~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~///
const char* httpserver = "api.thingspeak.com";
ESP8266WebServer server;
WiFiClient client;


// Configuration parameters for Access Point
char * ssid_ap = "ESP_AP";
char * password_ap = "123456789";
IPAddress ip(192,168,11,4); // arbitrary IP address (doesn't conflict w/ local network)
IPAddress gateway(192,168,11,1);
IPAddress subnet(255,255,255,0);
// Set up the server object

// Keep track of the sensor data that's going to be sent by the client
float t1=0.0;
float h1=0.0;
float s1=0.0;

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


  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(ip,gateway,subnet);
  WiFi.softAP(ssid_ap,password_ap);

  // Configure the server's routes
  server.on("/",handleIndex); // use the top root path to report the last sensor value
  server.on("/update",handleUpdate); // use this route to update the sensor value
  server.begin();
}
void handleIndex() {
    server.send(200,"text/plain",String(t1));
    server.send(200,"text/plain",String(h1));
    server.send(200,"text/plain",String(s1));// we'll need to refresh the page for getting the latest value
}

void handleUpdate() {


  // The value will be passed as a URL argument
 t1 = server.arg("value").toFloat();
  h1 = server.arg("value").toFloat();
  s1 = server.arg("value").toFloat();

  delay(100);
  WiFi.begin(ssid, password);

  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

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

  Serial.println();
  Serial.println("");
  Serial.print("NodeMcu connected to wifi...");
  Serial.println(ssid);
  Serial.println();
  Serial.println(WiFi.localIP() );


  delay(1000);
  ///~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~///
 float t2 = t1;
 float h2 = h1;
 float s2 = s1;
  if (client.connect(httpserver,80))
  {  
         String tsData = apiWritekey;
           tsData+="&amp;field1=";
           tsData+=String(t2);
           tsData+="&amp;field2=";
           tsData+=String(h2);
           tsData +="&amp;field3=";
           tsData += String(s2);
           tsData += "\r\n\r\n";

     client.print("POST /update HTTP/1.1\n");//command to update
     client.print("Host: api.thingspeak.com\n");//host name here thingspeak.com
     client.print("Connection: close\n");//closing connection
     client.print("X-THINGSPEAKAPIKEY: "+apiWritekey+"\n");
     client.print("Content-Type: application/x-www-form-urlencoded\n");
     client.print("Content-Length: ");
     client.print(tsData.length());
     client.print("\n\n");  // the 2 carriage returns indicate closing of Header fields &amp; starting of data
     client.print(tsData);

     Serial.print("Temp: ");
     Serial.print(t2);//printing on serial monitor
     Serial.print("Humi: ");
     Serial.print(h2);
     Serial.print("Soil: ");
     Serial.print(s2);
     Serial.println("uploaded to Thingspeak server....");//dialogue box
  //}
  digitalWrite(D4, LOW); 



  client.stop();//stopping client

  Serial.println("Waiting to upload next reading...");
  Serial.println();
  delay(5000);



} }

void loop() {
server.handleClient();

}
</code></pre>

<p>and the output of it is 
<a href="https://i.stack.imgur.com/l7mV5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l7mV5.png" alt="Server side output"></a></p>

<p>while the code of my client is</p>

<pre class="lang-cpp prettyprint-override"><code>#include &lt;DHT.h&gt;
#include &lt;ESP8266WiFi.h&gt;

// Initialize sensor parameters
// Initialize network parameters
const char* ssid = "ESP_AP";
const char* password = "123456789";
const char* host = "192.168.11.4"; // as specified in server.ino

#define DHTPIN 0          //pin where the dht11 is connected

DHT dht(DHTPIN, DHT11);

// Set up the client objet
WiFiClient client;

// Configure deep sleep in between measurements
const int sleepTimeSeconds = 2;

void setup() {

  // Connect to the server
  WiFi.begin(ssid,password);
  Serial.begin(115200);
  dht.begin();
  while(WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.print("IP Address (AP): "); Serial.println(WiFi.localIP());


void loop() {
  // put your main code here, to run repeatedly:
   while (WiFi.status() == WL_CONNECTED) {
    delay(500);
    int s = analogRead(A0);
    float h = dht.readHumidity();
    float t = dht.readTemperature();
  Serial.print("Temperature: "); Serial.println(t);
  Serial.print("Humidity: "); Serial.println(h);
  Serial.print("Soil Moisture: "); Serial.println(s);
  // Connect to the server and send the data as a URL parameter
  if(client.connect(host,80)) {
    String url = "/update?value=";
    url += String(t);
    String url1 = "/update?value=";
    url1 += String(h);
    String url2 = "/update?value=";
    url2 += String(s);
    client.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host +  "\r\n" + 
                 "Connection: keep-alive\r\n\r\n"); // minimum set of required URL headers
     client.print(String("GET ") + url1 + " HTTP/1.1\r\n" + "Host: " + host +  "\r\n" + 
                 "Connection: keep-alive\r\n\r\n"); // minimum set of required URL headers
     client.print(String("GET ") + url2 + " HTTP/1.1\r\n" + "Host: " + host +  "\r\n" + 
                 "Connection: keep-alive\r\n\r\n"); // minimum set of required URL headers
    delay(5000);

  }
    // Read all the lines of the response and print them to Serial
    Serial.println("Response: ");
    while(client.available()){
      String line = client.readStringUntil('\r');
      Serial.print(line);
  }
}
}
</code></pre>

<p>and its output is 
<a href="https://i.stack.imgur.com/KdAr8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KdAr8.png" alt="Client side output"></a></p>

<p>Kindly help me to get all values at server side, Thanks</p>
 37622: <p>You use the same name <code>value</code> for all <code>/update?</code> parameters. And the format of url parameters is <code>?name1=value1&amp;name2=value2</code></p>

<p>Use </p>

<pre><code>String url = "/update?t=";
url += String(t);
String url1 = "&amp;h=";
url1 += String(h);
String url2 = "&amp;s=";
url2 += String(s);
</code></pre>

<p>send it as one GET request</p>

<p>and read <code>server.arg("t")</code>,  <code>server.arg("h")</code> and  <code>server.arg("s")</code>.</p>

<p>Note 1: Sending more responses with <code>serverSend</code> to one request from browser has no effect. Only the first will work.</p>

<p>Note 2: this kind of use of String class will fragment the memory and cause a crash</p>

<p>Note 3: You don't need to use HTTP to communicate between your devices over TCP network. You can use <a href="https://arduino.stackexchange.com/questions/60819/esp8266-tcp-ip-communication/60821#60821">simple TCP socket connections</a> without HTTP protocol overhead.</p>
