Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!