user51381: I am using a magnetic float switch sensor to monitor water level in a tank. I am using a ESP8266 board.
I am trying to send the data collected by it to a php page in a host called "weris.link". I've checked the WiFi ssid and password for a myriad of times, yet somehow the connection to server still failed.
Did i commit a mistake ? 
Here's my code : 
#include <ESP8266WiFi.h>
#define FLOAT_SENSOR  D2     // the number of the pushbutton pin
#define LED           D8      // the number of the LED pin

const char* server = "weris.link"; // alamat server
const char* ssid = "aBee"; // SSID router wifi
const char* password = "xxxxx"; // password wifi
const char* SensorID = "Water_Level_Kelompok_1.Unsrat"; // ID sensor

const char* count1= "Water Tank Full";
const char* count2= "Water Level Low";
const char* recommend1= "Turn Off Flow";
const char* recommend2= "Turn on Flow";

WiFiClient client;

void setup() 
{
  Serial.begin(115200);
  // initialize the LED pin as an output:
  pinMode(LED, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(FLOAT_SENSOR, INPUT_PULLUP);

  WiFi.begin(ssid, password);

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


void loop() 
{
  if(digitalRead(FLOAT_SENSOR) == LOW) 
  {
    // turn LED on:
    digitalWrite(LED, HIGH);
    Serial.println(count1);
  } 
  else 
  {
    // turn LED off:
    digitalWrite(LED, LOW);
    Serial.println(count2);
  }
  // mulai Kirim data sensor
   if (client.connect(server,80 && LED == HIGH)) {
    Serial.print("Posting data...");
    digitalWrite(BUILTIN_LED, LOW);
    Serial.println("Tank Full: " + String(count1) + ", Tank Level Below Normal: " + String(count2));

// dengan GET /path file php penangkap data
client.println("GET /iot/terima.php?data1=" + String(count1) + "&data2=" + String(recommend1) + "&sid=" +SensorID+ " HTTP/1.1");
client.println("HOST: weris.link");
client.println("Connection: close");
client.println();
client.stop();
Serial.println();
digitalWrite(BUILTIN_LED, HIGH);
}

else if(client.connect(server,80 && LED == LOW)) {
  client.println("GET /iot/terima.php?data1=" + String(count2) + "&data2=" + String(recommend2) + "&sid=" +SensorID+ " HTTP/1.1");
  client.println("HOST: weris.link");
  client.println("Connection: close");
  client.println();
  client.stop();
  Serial.println();
  digitalWrite(BUILTIN_LED, HIGH);
 } 
  else {
Serial.println("Koneksi ke server gagal");
 }
  delay(5000);
}

Below is the screen capture from the serial monitor


user46852: This line:
if (client.connect(server,80 && LED == HIGH)) {

is definitely not going to do anything useful. Nor is this line:
else if(client.connect(server,80 && LED == LOW)) {

In both lines you're take the logical AND of the number 80 and the result of testing the LED.
Put the closing parenthesis in correct place:
if (client.connect(server,80) && LED == HIGH) {

and
else if(client.connect(server,80) && LED == LOW) {

Written this way you're still connecting twice if the LED is LOW. The code would be better written:
if (client.connect(server,80)) {
    if(LED == HIGH) {
      do stuff
    } else {
      do other stuff
    }
}

Even better would be to have the do stuff and do other stuff sections just set some variables and then write the code to talk to the web server once, using those variables. Having a single instance of the code will help avoid bugs in the future if you ever need to change it - the DRY (Don't Repeat Yourself) principle of programming.
Also, I hope you didn't just publish your wifi password here. If you did, you should change it.

51381: <p>I am using a magnetic float switch sensor to monitor water level in a tank. I am using a ESP8266 board.</p>

<p>I am trying to send the data collected by it to a php page in a host called "weris.link". I've checked the WiFi ssid and password for a myriad of times, yet somehow the connection to server still failed.</p>

<p>Did i commit a mistake ? </p>

<p>Here's my code : </p>



<pre class="lang-cpp prettyprint-override"><code>#include &lt;ESP8266WiFi.h&gt;
#define FLOAT_SENSOR  D2     // the number of the pushbutton pin
#define LED           D8      // the number of the LED pin

const char* server = "weris.link"; // alamat server
const char* ssid = "aBee"; // SSID router wifi
const char* password = "xxxxx"; // password wifi
const char* SensorID = "Water_Level_Kelompok_1.Unsrat"; // ID sensor

const char* count1= "Water Tank Full";
const char* count2= "Water Level Low";
const char* recommend1= "Turn Off Flow";
const char* recommend2= "Turn on Flow";

WiFiClient client;

void setup() 
{
  Serial.begin(115200);
  // initialize the LED pin as an output:
  pinMode(LED, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(FLOAT_SENSOR, INPUT_PULLUP);

  WiFi.begin(ssid, password);

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


void loop() 
{
  if(digitalRead(FLOAT_SENSOR) == LOW) 
  {
    // turn LED on:
    digitalWrite(LED, HIGH);
    Serial.println(count1);
  } 
  else 
  {
    // turn LED off:
    digitalWrite(LED, LOW);
    Serial.println(count2);
  }
  // mulai Kirim data sensor
   if (client.connect(server,80 &amp;&amp; LED == HIGH)) {
    Serial.print("Posting data...");
    digitalWrite(BUILTIN_LED, LOW);
    Serial.println("Tank Full: " + String(count1) + ", Tank Level Below Normal: " + String(count2));

// dengan GET /path file php penangkap data
client.println("GET /iot/terima.php?data1=" + String(count1) + "&amp;data2=" + String(recommend1) + "&amp;sid=" +SensorID+ " HTTP/1.1");
client.println("HOST: weris.link");
client.println("Connection: close");
client.println();
client.stop();
Serial.println();
digitalWrite(BUILTIN_LED, HIGH);
}

else if(client.connect(server,80 &amp;&amp; LED == LOW)) {
  client.println("GET /iot/terima.php?data1=" + String(count2) + "&amp;data2=" + String(recommend2) + "&amp;sid=" +SensorID+ " HTTP/1.1");
  client.println("HOST: weris.link");
  client.println("Connection: close");
  client.println();
  client.stop();
  Serial.println();
  digitalWrite(BUILTIN_LED, HIGH);
 } 
  else {
Serial.println("Koneksi ke server gagal");
 }
  delay(5000);
}
</code></pre>

<p>Below is the screen capture from the serial monitor</p>

<p><a href="https://i.stack.imgur.com/C3VUR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C3VUR.png" alt="Here is my picture"></a></p>
 46852: <p>This line:</p>

<pre><code>if (client.connect(server,80 &amp;&amp; LED == HIGH)) {
</code></pre>

<p>is definitely not going to do anything useful. Nor is this line:</p>

<pre><code>else if(client.connect(server,80 &amp;&amp; LED == LOW)) {
</code></pre>

<p>In both lines you're take the logical AND of the number 80 and the result of testing the LED.</p>

<p>Put the closing parenthesis in correct place:</p>

<pre><code>if (client.connect(server,80) &amp;&amp; LED == HIGH) {
</code></pre>

<p>and</p>

<pre><code>else if(client.connect(server,80) &amp;&amp; LED == LOW) {
</code></pre>

<p>Written this way you're still connecting twice if the LED is LOW. The code would be better written:</p>

<pre><code>if (client.connect(server,80)) {
    if(LED == HIGH) {
      do stuff
    } else {
      do other stuff
    }
}
</code></pre>

<p>Even better would be to have the <em>do stuff</em> and <em>do other stuff</em> sections just set some variables and then write the code to talk to the web server once, using those variables. Having a single instance of the code will help avoid bugs in the future if you ever need to change it - the DRY (Don't Repeat Yourself) principle of programming.</p>

<p>Also, I hope you didn't just publish your wifi password here. If you did, you should change it.</p>
