Sim808 GPS,GSM,GPRS and DFRobot_Sim808 library

I write my first post because there is something that does not fit with the GET command of the library.

I have posted in the forum in Spanish but I think that in this forum there will be more people who can provide some information.

I have the following code for a test that I am doing with this module.

#include <DFRobot_sim808.h>
#define mySerial Serial1
DFRobot_SIM808 sim808(&mySerial);

char http_cmd[] = "GET /arduino/grabar_dato.php?data1=34618103646&data2=-13.88556&data3=37.67545&data4=0.22 HTTP/1.1 \r\n\r\n";
char buffer[512];
int Powerkey = 9;

void setup(){
  mySerial.begin(9600);
  Serial.begin(9600);
  
  /////////encendemos el modulo GSM,GPRS,GPS por software
  digitalWrite(Powerkey, LOW);
  delay(2000);
  digitalWrite(Powerkey, HIGH);
  delay(5000);
  
  //******** Initializa la sim808  *************
  while(!sim808.init()) {
      delay(1000);
      Serial.print("Error de inicializacion de la Sim808\r\n");
  }
  delay(3000);  
    
  //*********** Intentar DHCP con el APN correcto *******************
  while(!sim808.join(F("orangeworld"))) {
      Serial.println("Error de GPRS de la Sim808");
      delay(2000);
  }

  //************ Hemos conectado el GPRS ****************
  Serial.print("La direccion IP es: ");
  Serial.println(sim808.getIPAddress());

  //*********** Establecer conexion TCP ************
  if(!sim808.connect(TCP,"miservidor.com", 80)) {  
      Serial.println("Error de conexion TCP");
  }else{
      Serial.println("Conexion TCP satisfactoria");
  }

  //*********** Enviar GET request *****************
  sim808.send(http_cmd, sizeof(http_cmd)-1);
  int ret = sim808.recv(buffer, sizeof(buffer)-1);
  if (ret <= 0){
        Serial.println("error recibiendo");
    }
    else {
        buffer[ret] = '\0';
        Serial.print(buffer);
    }


  //************* Cerrar la conexion TCP **********
  sim808.close();

  //*** Desconectar GPRS *******
  sim808.disconnect();
}


void loop(){

}

I used the example code from the DFRobot_Sim808 library. And everything works great until I adapt it to my tests. I have put myserver.com to not put the true one.

It is about adding records to a table of a mysql on my server. Whenever the code is executed I get a “400 Bad Request” but if I do it from the browser bar, insert the registry without problems with the following command in the address bar of the browser:

http://miservidor.com/arduino/grabar_dato.php?data1=34618103646&data2=-26.88556&data3=37.67545&data4=0.25

With the following code in the php

<?php
    
   $conn= new mysqli('localhost','miusuario','micontraseña', 'mibasededatos');
   
   if($conn->connect_error) {
   die("Conexion fallida: ". $sql->connect_error);
   }
   
   $sql = "INSERT INTO mitabla (referencia, latitud, longitud, velocidad) VALUES ('".$_GET["data1"]."','".$_GET["data2"]."','".$_GET["data3"]."','".$_GET["data4"]."')";
   
   if ($conn->query($sql) === TRUE) {
       echo "Nuevo registro creado.";
       $conn->close();
    } else {
       echo "Error: " . $sql . "
" . $conn->error;
    };
    
?>

This is the answer I get from the server when it is done through arduino:

HTTP/1.1 400 Bad Request
Server: nginx
Date: Fri, 30 Mar 2018 11:50:01 GMT
Content-Type: text/html
Content-Length: 166
Connection: close

<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx</center>
</body>
</html>

[\code]


Something escapes me and I do not know what it is.

Has anyone had the same problem?

Thank you.