I'm building a vehicle tracker with Arduino shield with Waveshare SIM 808. I am communicating with the Arduino via AT commands, and came across the following problem: The method "leserial ()" returns me the result of the command missing characters
Response
+CGNSINF: 1,1,20161101222934.000,-23.285230,-51.20
Expected response
+CGNSINF: 1,1,20161101223215.000,-23.285222,-51.204778,623.000,0.02,142.3,1,,1.2,2.5,2.2,,8,7,,,38,,
Code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); //RX, TX
String inputString = "";
char inChar;
const int powerkey = 5;
const int statuspin = 6;
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
pinMode(powerkey, OUTPUT);
pinMode(statuspin, INPUT);
mySerial.println("AT");
delay(2000);
leserial();
//TURN ON GPS
mySerial.println("AT+ CGNSPWR =1");
delay(2000);
leserial();
}
void loop() {
//GET LOCATION
mySerial.println("AT+CGNSINF");
delay(4000);
leserial();
delay(5000);
}
void leserial(){
inputString = "";
while (mySerial.available()>0){
inChar = mySerial.read();
inputString += inChar;
}
Serial.println(inputString);
}