Arduino to Traccar

T.KAV3 years ago

Hi,

I need to send datas from arduino to traccar. I use osmand protocol but I have a problem sending data stably. Sometimes datas sends 5 minutes later sometimes 3 minutes later sometimes I cannot send datas. Can you help me?

gberron3 years ago

What GPS board do you use? What GPRS card do you use?
Can you share the .ino file with us? So we can verify

vmedrano3 years ago

i am using esp32 lilyGO sending gps data an other stuf from an electric vehicule, works very well.
i had some problems wirh carrier 2g.
but nothing else.

T.KAV3 years ago

I am using Sim800c and arduino leonardo. Thanks for the answer.

Codes;

#include <SoftwareSerial.h>

String apn = "internet";                    //APN
String apn_u = "";                     //APN-Username
String apn_p = "";                     //APN-Password
String url = "xxxxxxxxxxx";  //URL of Server

SoftwareSerial SWserial(10, 11); // RX, TX

void setup()
{
  Serial.begin(115200);
  Serial.println("SIM800 AT CMD Test");
  SWserial.begin(9600);
  delay(1000);
  while (SWserial.available()) {
    Serial.write(SWserial.read());
  }
  delay(2000);
  gsm_config_gprs();
}

void loop() {
  gsm_http_post("param=TestFromMySim800");
  delay(30000);
}

void gsm_http_post( String postdata) {
  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/x-www-form-urlencoded");
  gsm_send_serial("AT+HTTPDATA=192,5000");
  gsm_send_serial("AT+HTTPACTION=1");
  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();
}
Craig Williams2 years ago

Please can you guys share more information i would like to build an arduino based tracker to use with traccar

alirezasaberia year ago

me too