Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

220
Visualizações
ESP01-Apache server send data with Post to .php file

So basically I am trying to send data to a textfile in raspberrypi(apache server) from my ESP01 using AT-Commands. I am trying to use POST method of apache for same. Here is my PHP code:

`<?php
$tempF=$_POST["temp"];
$file='testfile.text';
$myfile=($file,"w+");
fwrite($myfile,$tempF);
fclose($myfile);
?>`

Here is the data I send through AT Command (AT+CIPSEND)

`POST /TEMP/post.php HTTP/1.1\r\nHost: 192.168.0.138:80\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length:9 \r\n\r\ntemp=1234`

So when I send this AT command, I assume that php file should be executed and data from 'temp' variable should be written to the text file. However there is no such output visible nor any errors displayed.

Here is simple map of how paths are placed root folder:/var/www/html inside it -> TEMP(folder), index.html inside TEMP -> post.php, testfile.txt

I have already tried following :

  1. Replace the $tempF variable with text and execute PHP on raspberrypi. So I conclude that there is no issue in php code since it worked great.
  2. Enabled php mod and simple php index file works too. 3)Tried changing all possible pathways. 4)Give complete permissions to all files to read, write and execute in root folder. i.e index.html, post.php and testfile.txt

Screenshot of my at commands

P.S. I am new to PHP and POST method of HTTP/1.1

Thanks☻

EDIT 1: As from Juraj's comment I realised that when you send \r\n through serial monitor it actually sends \n and so I tried the conventional method while entering Post Command as follows:

POST /TEMP/post.php HTTP/1.1
Host: 192.168.0.138:80
Content-Type: application/x-www-form-urlencoded
Content-Length:9

temp=1234

And I recieved following Error:

 +IPD,187:HTTP/1.0 500 Internal Server Error
 Date: Fri, 06 Aug 2021 13:06:57 GMT
 Server: Apache/2.4.38 (Raspbian)
 Content-Length: 0
 Connection: close
 Content-Type: text/html; charset=UTF-8

Update:

While searching for same, I found reqbin.com which helps to test POST/GET methods too and I still got same error 500. Note:My timeout currently is 120000ms and all files are given full permissions.

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda