title: PHP GET request sent by ESP8266 Wifi chip but not received by website
body: <p>I am building a simple website which should update a text file when the host receives data from another device connected to the same network. The device in question is a small weather station which measures temperature. The temperature is sent by the station in a PHP GET command through Wifi from an ESP8266 chip. The signal is received by the home router and redirected to a laptop on the network which is hosting the website.</p>
  
  <p>I am having issues because the ESP8266 chip seems to send the data/PHP GET command correctly. Yet the website never updates itself.</p>
  
  <p>In order to simplify the system for troubleshooting, the weather station is replaced by the laptop. The laptop is connected directly to the ESP8266 chip through a USB-to-Serial(UART) cable. All the AT commands to communicate with the ESP8266 chip are typed in the Arduino IDE Serial Monitor.</p>
  
  <p><strong>The website</strong></p>
  
  <p>The website is very simple. Whenever it receives data from the ESP8266 chip, it writes it in a text file.</p>
  
  <p>The website is stored on a laptop whose IP is 192.168.1.2.</p>
  
  <pre><code>phodor@UBUNTU:~$ ifconfig    
  wlp2s0    Link encap:Ethernet  HWaddr 18:cf:5e:ee:3f:10  
            inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
  </code></pre>
  
  <p>The website is a php file hosted on an apache2 server. When executed, the php file stores the temperature in file data.txt. The files are stored at /var/www/html.</p>
  
  <pre><code>phodor@UBUNTU:~$ ls -la /var/www/html
  -rwxrwxrwx 1 root root     0 Jul 31 22:41 data.txt
  -rwxr-xr-x 1 root root   127 Jul 31 21:40 index.php
  </code></pre>
  
  <p>Any GET request sent to the PHP file should contain the temperature so the PHP file can store the temperature in data.txt.</p>
  
  <pre><code>phodor@UBUNTU:~$ cat /var/www/html/index.php 
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  &lt;?php
    $a = $_GET['temp'];
    $dataSaved = file_put_contents("data.txt",$a . "\n",FILE_APPEND);  
    echo "Temperature is " . $a . " oC.";  
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>When I type manually the following line in Firefox:</p>
  
  <pre><code>http://192.168.1.2/index.php?temp=28
  </code></pre>
  
  <p>The following text gets displayed in the browser &amp; number "28" gets saved in data.txt.</p>
  
  <pre><code>Temperature is 28 oC.
  </code></pre>
  
  <p><strong>The ESP8266 Chip</strong></p>
  
  <p>As explained above, in the final system the ESP8266 chip will receive serial instructions from a small weather station. But in order to simplify debugging, the chip is now connected to the laptop with a USB-to-Serial (UART) cable. Serial commands are sent to the chip by using the Arduino IDE Serial Monitor. Here are the commands sent.</p>
  
  <pre><code>AT
  
  OK
  AT+CWLAP
  +CWLAP:(3,"MYMODEM",-31,"aa:bb:cc:dd:ee:ff",1,21)
  
  OK
  AT+CWJAP="MYMODEM","mypassword"
  
  WIFI CONNECTED
  WIFI GOT IP
  
  OK
  AT+CIPSTART="TCP","192.168.1.2",80
  CONNECT
  
  OK
  AT+CIPSEND=56
  
  OK
  &gt; GET /index.php?temp=10 HTTP/1.1\r\nHost: 192.168.1.2\r\n\r\n
  
  busy s...
  
  Recv 56 bytes
  
  SEND OK
  CLOSED
  </code></pre>
  
  <p>So at this point, message "Temperature is 10 oC." should appear in the Serial Monitor and the number "10" should get appended to file "data.txt". But nothing happens...</p>
  
  <p>Any suggestions?</p>
  
  <p><strong>Additional Notes</strong></p>
  
  <p>1) The PHP and AT code I am using is very similar to what is presented in this post: <a href="https://www.youtube.com/watch?v=q02f4sPghSo" rel="nofollow">https://www.youtube.com/watch?v=q02f4sPghSo</a>   .</p>
  
  <p>2) As was pointed in some comments below, the GET command might be less conventional. POST or PUT might be more appropriate. Yet at the moment I am only trying to understand why the website is not responding to the chip.</p>