1

I have been running an application on an older original Raspberry Pi. The Raspberry Pi was running Incredible PBX and I have some tables set up in the MySQL database to store data received from an Arduino HTTP Get request that calls a PHP file. I have recently imaged the SD card and have tried running it in a new Raspberry Pi3. The issue I'm having is the newer Pi3 is showing a 400 Bad Request when Arduino sends the GET request. The Pi3 apache other_vhost_access logs show the Arduino request and also a successful request using Postman to send the HTTP request.

I would appreciate any help in how to successfully send HTTP request from Arduino to Pi3

Unsuccesful post from Arduino - localhost:80 192.168.50.21 - - [05/May/2019:09:21:03 -0400] "GET /add_data.php?ext=5000&room=212&callerid=212+TEST+PAGE" 400 506 "-" "-"

Sucessful post from Postman - localhost:80 192.168.50.145 - - [05/May/2019:09:29:27 -0400] "GET /add_data.php?ext=5000&room=110&callerid=110%20Emergency HTTP/1.1" 200 429 "-" "PostmanRuntime/7.11.0"

Arduino Code is -

if (client.connect(server, 80)) {
Serial.println("-> Connected and sending HTTP Request");
// Make a HTTP request:
client.print( "GET /add_data.php?"); //THIS SHOULD BE add_data.php
client.print("ext=");
client.print( extn );

client.print("&");
client.print("room=");
client.print( room );

client.print("&");
client.print("callerid=");
client.print( callerId2 );

client.println( " HTTP/1.1");
client.print( "Host: " );
client.println(server);
client.println( "Content-Type: application/x-www-form-urlencoded" );     
client.println( "Connection: close" );
client.println();
client.println();
client.stop();
//Serial.print ("Room = " + room);

Serial.println ("HTTP Request proceesed and sent!"); Serial.println ("Database queries in process"); } else { // you didn't get a connection to the server: Serial.println("--> connection failed/n"); }

delay(interval);

2
  • It's not really clear what the problem is. The log image that you showed doesn't seem to have a code 400. The problem seems likely to be on the Pi, but you've give the Arduino code. It's possible that one version of your server software is more forgiving to an error in the HTTP sent by the Arduino, of course, but it's more likely that your configuration is somehow not portable between models of Pi. To know that, we'd need the configuration. Commented May 6, 2019 at 21:49
  • Would you explain a bit more about what configuration files I should post Commented May 6, 2019 at 23:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.