Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

219
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda