title: POST data from Arduino to website
body: <p>I am working on a project where I am trying to send data using HTTP and POST method from my Arduino Mega2560 to a website which I host on localhost. I am living to a students' accommodation and thus, I do not have access to the router. However, I have bought a router and have connected it to the wall via the WAN. Also, the Arduino is connected to one of the ethernet plugs of the router via an Ethernet shield and my laptop to another ethernet plug. I am trying to retrieve the data from the website, but I cannot seem to load them.</p>
  
  <p><strong>Arduino Code</strong></p>
  
  <pre><code>#include &lt;dht.h&gt;
  #include &lt;SPI.h&gt;
  #include &lt;Ethernet.h&gt;
  
  dht DHT1;
  int temperatureSensorPin1 = 25;
  
  byte mac[] = {
    0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
  };
  EthernetClient client;
  EthernetServer server(80);
  
  long previousMillis = 0;
  unsigned long currentMillis = 0;
  long interval = 250000;
  String data;
  
  long lastUpdate = 0;
  
  void setup() {
  
    Serial.begin(9600);
    if(Ethernet.begin(mac) == 0) {
      Serial.println("Failed to configure Ethernet using DHCP");
    }
  
    data = "";
  
    pinMode(temperatureSensorPin1, INPUT);
  }
  
  void loop() {
  
  
  int temp1 = DHT1.read11(temperatureSensorPin1);
  
  switch (temp1)
    {
      case DHTLIB_OK:  
          Serial.print("OK,\t"); 
          break;
      case DHTLIB_ERROR_CHECKSUM: 
          Serial.print("Checksum error,\t"); 
          break;
      case DHTLIB_ERROR_TIMEOUT: 
          Serial.print("Time out error,\t"); 
          break;
      case DHTLIB_ERROR_CONNECT:
          Serial.print("Connect error,\t");
          break;
      case DHTLIB_ERROR_ACK_L:
          Serial.print("Ack Low error,\t");
          break;
      case DHTLIB_ERROR_ACK_H:
          Serial.print("Ack High error,\t");
          break;
      default: 
          Serial.print("Unknown error,\t"); 
          break;
    }
  
    currentMillis = millis();
    if(currentMillis - previousMillis &gt; interval) {
      previousMillis = currentMillis;
    }
    String data="temp1="+String(DHT1.temperature, 0)+"&amp;temp2="+String(DHT2.temperature, 0)+"&amp;temp3="+String(DHT3.temperature, 0)+"&amp;temp4="+String(DHT4.temperature, 0)+"&amp;temp5="+String(DHT5.temperature, 0)
                    +"&amp;hum1="+String(DHT1.humidity, 0)+"&amp;hum2="+String(DHT2.humidity, 0)+"&amp;hum3="+String(DHT3.humidity, 0)+"&amp;hum4="+String(DHT4.humidity, 0)+"&amp;hum5="+String(DHT5.humidity, 0)+"&amp;gas="+gasValue;
  
    Serial.println(Ethernet.localIP());
    if(client.connect("192.168.0.1", 80)) {
      client.println("POST /home/visualisation.php HTTP/1.1");
      client.println("Host:  192.168.0.1");
      //client.println("User-Agent: Arduino/1.0");
      //client.println("Connection: close");
      client.println("Content-Type: application/x-www-form-urlencoded;");
      client.print("Content-Length: ");
      client.println(data.length());
      client.println();
      client.print(data);
      //Serial.println(data);
      Serial.println("We have connection");
    }
  
    if(client.connected()) {    
      Serial.println("We have abc");
      client.stop();
    }
  
    delay(4000);
  }
  </code></pre>
  
  <p><strong>PHP Code</strong></p>
  
  <pre><code>&lt;?php
  $temp1 = "";
  if(isset($_POST['temp1'])) {
      $temp1 = $_POST['temp1'];
  }
  echo $temp1;
  ?&gt;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/5NIKY.png" alt="Windows ip configuration"></p>
  
  <p><img src="https://i.stack.imgur.com/OmWXX.png" alt="Router ip configuration"></p>
  
  <p>Is the connection that I have made the appropriate one? How should I do it in order to work?</p>
  
  <p>P.S.: I would like to clarify that I do not have an extended knowledge regarding networking.</p>