Problem with Arduino Sending POST Data to InfinityFree PHP Server

Hello,

I am working on a student project involving an IoT-based poultry monitoring system. My setup includes the following:

  1. Hardware:
  • Arduino ESP32 is connected to DHT11 and MQ135 sensors to collect temperature, humidity, NH3, and CO2 data.
  • The Arduino sends data via an HTTP POST request to a PHP script hosted on an InfinityFree server.
  1. Software:
  • The PHP script (sensordata.php) is designed to receive the sensor data and insert it into a MySQL database.
  • The server has a file (post_log.txt) to log all incoming POST requests for debugging.
  1. What is Working:
  • The Arduino successfully connects to WiFi and builds the HTTP request correctly.
  • The script works perfectly in my local XAMPP environment, receiving and storing the data as intended.
  1. What is Not Working:
  • When hosted on InfinityFree:
    • The Arduino sends the POST request, but the server either does not receive it or fails to process it.
    • The post_log.txt file does not update, and no data appears in the database.
  • Testing the PHP script on Postman shows a redirection error that includes a script requiring JavaScript (aes.js). After this step, the response doesn’t confirm successful data reception.
  1. Troubleshooting Steps Taken:
  • Confirmed Arduino code is functioning by monitoring the serial output (HTTP requests and responses).
  • Set file permissions for post_log.txt to 777 to ensure the script can write to it.
  • Tested the PHP script manually via Postman, where it produces the expected “Data received” response locally but not on InfinityFree.
  • Ensured the database credentials and connections are correct in the script.
  1. Request for Help:
  • Could this issue be related to InfinityFree’s restrictions on HTTP requests, file writing, or redirects involving aes.js?
  • If so, is there a way to bypass these limitations or configure my server/files to allow POST requests from an Arduino device?

Its infinityfree’s security , click the link below for details

8 Likes