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(){
  /////////encendemos el modulo GSM,GPRS,GPS por software
  digitalWrite(Powerkey, LOW);
  digitalWrite(Powerkey, HIGH);
  //******** Initializa la sim808  *************
  while(!sim808.init()) {
      Serial.print("Error de inicializacion de la Sim808\r\n");
  //*********** Intentar DHCP con el APN correcto *******************
  while(!sim808.join(F("orangeworld"))) {
      Serial.println("Error de GPRS de la Sim808");

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

  //*********** Establecer conexion TCP ************
  if(!sim808.connect(TCP,"", 80)) {  
      Serial.println("Error de conexion TCP");
      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';

  //************* Cerrar la conexion TCP **********

  //*** Desconectar GPRS *******

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 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:

With the following code in the 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.";
    } 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

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


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

Has anyone had the same problem?

Thank you.