I can not send data to traccar regularly

T.KAV3 years ago

Hi I have a project about GPS. I am using sim800c and arduino leonardo. When I try to send data to traccar server, I can not see the datas on server. Sometimes I can send data but not its not regularly.

When I try the different server, I can send datas correctly.

Can you help me?

Codes;

#include <TinyGPS++.h>
#include <TinyGPSPlus.h>

#include <ArduinoJson.h>
#include <SoftwareSerial.h>
#include <DFRobot_SIM808.h>


String apn = "internet";                    //APN
String apn_u = "";                     //APN-Username
String apn_p = "";                     //APN-Password
String url = "http://xxx.xx.xxx.xx:5055/?id=001&lat=xx.652661&lon=xx.830153";  //URL of Server

SoftwareSerial SWserial(10, 11); // RX, TX
TinyGPSPlus gps;
void setup()
{
  Serial.begin(115200);
  Serial.println("SIM800 AT CMD Test");
  SWserial.begin(9600);
  delay(30000);
  while (SWserial.available()) {
    Serial.write(SWserial.read());
  }
  delay(2000);
  gsm_config_gprs();
  

}

void loop() {
  
  gsm_http_get("param=TestFromMySim800");
  delay(1000);

}

void gsm_http_get( String getdata) {
  Serial.println(" --- Start GPRS & HTTP --- ");
  gsm_send_serial("AT+SAPBR=1,1");
  gsm_send_serial("AT+SAPBR=2,1");
  gsm_send_serial("AT+HTTPINIT");
  gsm_send_serial("AT+HTTPPARA=CID,1");
  gsm_send_serial("AT+HTTPPARA=URL," + url);
  gsm_send_serial("AT+HTTPPARA=CONTENT,application/Json");
  gsm_send_serial("AT+HTTPDATA=192,5000");
  gsm_send_serial(getdata);
  gsm_send_serial("AT+HTTPACTION=0");
  gsm_send_serial("AT+HTTPREAD");
  gsm_send_serial("AT+HTTPTERM");
  gsm_send_serial("AT+SAPBR=0,1");
}

void gsm_config_gprs() {
  Serial.println(" --- CONFIG GPRS --- ");
  gsm_send_serial("AT+SAPBR=3,1,Contype,GPRS");
  gsm_send_serial("AT+SAPBR=3,1,APN," + apn);
  if (apn_u != "") {
    gsm_send_serial("AT+SAPBR=3,1,USER," + apn_u);
  }
  if (apn_p != "") {
    gsm_send_serial("AT+SAPBR=3,1,PWD," + apn_p);
  }
}

void gsm_send_serial(String command) {
  Serial.println("Send ->: " + command);
  SWserial.println(command);
  long wtimer = millis();
  while (wtimer + 3000 > millis()) {
    while (SWserial.available()) {
      Serial.write(SWserial.read());
    }
  }
  Serial.println();
}
Anton Tananaev3 years ago

What do you see in the server logs?

T.KAV3 years ago

There is an example,

2022-04-05 01:20:42  INFO: [c3e3a837: osmand < xx.xxx.xxx.xxx] HEX: 504f5354202f3f69643d76616c6c615f63616c697374696d266c61743d33392e363532363631266c6f6e3d33322e38333031353320485454502f312e310d0a486f73743a203138382e33382e3132332e32303a353035350d0a4163636570743a202a2f2a0d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a436f6e74656e742d547970653a206170706c69636174696f6e2f782d7777772d666f726d2d75726c656e636f6465640d0a557365722d4167656e743a2053494d434f4d5f4d4f44554c450d0a436f6e74656e742d4c656e6774683a2032340d0a0d0a706172616d3d5465737446726f6d4d7953696d3830300d0a
2022-04-05 01:20:42  INFO: [c3e3a837: osmand > xx.xxx.xxx.xxx] HEX: 485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2022-04-05 01:20:43  INFO: [c3e3a837] id: valla_calistim, time: 2022-04-05 01:20:42, lat: xx.65266, lon: xx.83015, course: 0.0
2022-04-05 01:20:44  INFO: [c3e3a837] disconnected
2022-04-05 01:21:46  INFO: [fbef0d56] connected
2022-04-05 01:21:46  INFO: [fbef0d56: osmand < xx.xxx.xxx.xxx] HEX: 504f5354202f3f69643d76616c6c615f63616c697374696d266c61743d33392e363532363631266c6f6e3d33322e38333031353320485454502f312e310d0a486f73743a203138382e33382e3132332e32303a353035350d0a4163636570743a202a2f2a0d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a436f6e74656e742d547970653a206170706c69636174696f6e2f782d7777772d666f726d2d75726c656e636f6465640d0a557365722d4167656e743a2053494d434f4d5f4d4f44554c450d0a436f6e74656e742d4c656e6774683a2032340d0a0d0a706172616d3d5465737446726f6d4d7953696d3830300d0a
2022-04-05 01:21:46  INFO: [fbef0d56: osmand > xx.xxx.xxx.xxx] HEX: 485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2022-04-05 01:21:46  INFO: [fbef0d56] disconnected
2022-04-05 01:22:52  INFO: [f324be66] connected
2022-04-05 01:22:56  INFO: [f324be66: osmand < xx.xxx.xxx.xxx] HEX: 504f5354202f3f69643d76616c6c615f63616c697374696d266c61743d33392e363532363631266c6f6e3d33322e38333031353320485454502f312e310d0a486f73743a203138382e33382e3132332e32303a353035350d0a4163636570743a202a2f2a0d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a436f6e74656e742d547970653a206170706c69636174696f6e2f782d7777772d666f726d2d75726c656e636f6465640d0a557365722d4167656e743a2053494d434f4d5f4d4f44554c450d0a436f6e74656e742d4c656e6774683a2032340d0a0d0a706172616d3d5465737446726f6d4d7953696d3830300d0a
2022-04-05 01:22:56  INFO: [f324be66: osmand > xx.xxx.xxx.xxx] HEX: 485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2022-04-05 01:22:57  INFO: [f324be66] id: valla_calistim, time: 2022-04-05 01:22:56, lat: xx.65266, lon: xx.83015, course: 0.0
2022-04-05 01:22:58  INFO: [f324be66] disconnected
2022-04-05 01:25:05  INFO: [40600b8a] connected
2022-04-05 01:25:06  INFO: [40600b8a: osmand < xx.xxx.xxx.xxx] HEX: 504f5354202f3f69643d76616c6c615f63616c697374696d266c61743d33392e363532363631266c6f6e3d33322e38333031353320485454502f312e310d0a486f73743a203138382e33382e3132332e32303a353035350d0a4163636570743a202a2f2a0d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a436f6e74656e742d547970653a206170706c69636174696f6e2f782d7777772d666f726d2d75726c656e636f6465640d0a557365722d4167656e743a2053494d434f4d5f4d4f44554c450d0a436f6e74656e742d4c656e6774683a2032340d0a0d0a706172616d3d5465737446726f6d4d7953696d3830300d0a
2022-04-05 01:25:06  INFO: [40600b8a: osmand >xx.xxx.xxx.xxx] HEX: 485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2022-04-05 01:25:06  INFO: [40600b8a] id: valla_calistim, time: 2022-04-05 01:25:06, lat: xx.65266, lon: xx.83015, course: 0.0
2022-04-05 01:25:07  INFO: [40600b8a] disconnected
2022-04-05 01:26:13  INFO: [dc7c60e2] connected
2022-04-05 01:27:17  INFO: [8d7b29f1] connected
2022-04-05 01:27:18  INFO: [8d7b29f1: osmand <xx.xxx.xxx.xxx] HEX: 504f5354202f3f69643d76616c6c615f63616c697374696d266c61743d33392e363532363631266c6f6e3d33322e38333031353320485454502f312e310d0a486f73743a203138382e33382e3132332e32303a353035350d0a4163636570743a202a2f2a0d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a436f6e74656e742d547970653a206170706c69636174696f6e2f782d7777772d666f726d2d75726c656e636f6465640d0a557365722d4167656e743a2053494d434f4d5f4d4f44554c450d0a436f6e74656e742d4c656e6774683a2032340d0a0d0a706172616d3d5465737446726f6d4d7953696d3830300d0a
2022-04-05 01:27:18  INFO: [8d7b29f1: osmand > xx.xxx.xxx.xxx] HEX: 485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2022-04-05 01:27:18  INFO: [8d7b29f1] disconnected
2022-04-05 01:28:23  INFO: [e4a8130e] connected
2022-04-05 01:28:25  INFO: [e4a8130e: osmand < xx.xxx.xxx.xxx] HEX: 504f5354202f3f69643d76616c6c615f63616c697374696d266c61743d33392e363532363631266c6f6e3d33322e38333031353320485454502f312e310d0a486f73743a203138382e33382e3132332e32303a353035350d0a4163636570743a202a2f2a0d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a436f6e74656e742d547970653a206170706c69636174696f6e2f782d7777772d666f726d2d75726c656e636f6465640d0a557365722d4167656e743a2053494d434f4d5f4d4f44554c450d0a436f6e74656e742d4c656e6774683a2032340d0a0d0a706172616d3d5465737446726f6d4d7953696d3830300d0a
2022-04-05 01:28:25  INFO: [e4a8130e: osmand > xx.xxx.xxx.xxx] HEX: 485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2022-04-05 01:28:26  INFO: [e4a8130e] disconnected
2022-04-05 01:34:31  INFO: [bcb76691] connected
2022-04-05 01:34:32  INFO: [bcb76691: osmand < xx.xxx.xxx.xxx] HEX: 504f5354202f3f69643d76616c6c615f63616c697374696d266c61743d33392e363532363631266c6f6e3d33322e38333031353320485454502f312e310d0a486f73743a203138382e33382e3132332e32303a353035350d0a4163636570743a202a2f2a0d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a436f6e74656e742d547970653a206170706c69636174696f6e2f782d7777772d666f726d2d75726c656e636f6465640d0a557365722d4167656e743a2053494d434f4d5f4d4f44554c450d0a436f6e74656e742d4c656e6774683a2032340d0a0d0a706172616d3d5465737446726f6d4d7953696d3830300d0a
2022-04-05 01:34:32  INFO: [bcb76691: osmand > xx.xxx.xxx.xxx] HEX: 485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2022-04-05 01:34:32  INFO: [bcb76691] id: valla_calistim, time: 2022-04-05 01:34:32, lat: xx.65266, lon: xx.83015, course: 0.0
Anton Tananaev3 years ago

The problem is that you disconnect too quickly. Try keeping connection open or disable geocoding.

Rob67ert2 years ago

Hi,

Do you have the correct ArduinoJson.h file for me?