Hi,
My project is to build a motorbike logger recording accelerometer and GPS data on a SD card.
My accelerometer is a MPU6050, generating data at 100Hz.
I used this code http://www.kauailabs.com/robotics/kauai-labs-releases-port-of-latest-invensense-mpu-60509150-driver-to-arduino-platform/ which generates interrupts each time a new data is available.
My GPS is a UBLOX NEO-6M, configured with 115200 bps serial communication, 5Hz update rate.
Due to communication time from GPS to arduino, new data from the accelerometer are available while the GPS messages are transfered.
So I used a String buffer to store the GPS sentences and output them to the serial monitor only when the message transmission is finished.
Here is my code to buffer GPS data :
String GPSbuffer = "";
GPSbuffer.reserve(200);
....
// process GPS data
while (GPSUART.available()) {
char inChar = GPSUART.read();
if (inChar == '
I get the following output :
MPU TimeStamp 85050 YPR -0.61 -3.21 -0.02 0
MPU TimeStamp 85060 YPR -0.61 -3.21 -0.02 0
MPU TimeStamp 85070 YPR -0.61 -3.21 -0.02 0
GPS Timestamp 85063 $GPGGA,000828.60,4341.82420,N,00529.39033,E,1,05,3.43,248.6,M,47.7,M,,*5F
GPS Timestamp 85074 $PUBX,00,000828.60,4341.82420,N,00529.39033,E,296.230,G3-0.201,.03,5,0,0*7A
MPU TimeStamp 85083 YPR -0.61 -3.21 -0.02 0
Which is fine....but sometimes my GPS message is corrupted :
PU TimeStamp 165005 YPR -0.80 -3.27 -0.00 0
MPU TimeStamp 165015 YPR -0.80 -3.27 -0.00 0
GPS Timestamp 165018 $PUBX,00,000948.40,4341.81869,N,00529.38609,E,303.817,G2,0.000,$GPGGA,000948.60,4341.81868,N,00529.38609,E,1,04,2.11,256.2,M,47.7,M,,*59
MPU TimeStamp 165033 YPR -0.80 -3.27 -0.00 0
The end of message \n seems not always detected. This gets even worse when I click on the "autoscroll" button of the serial monitor.
When I don't output the accelerometer, every thing works fine.
Any Idea that could help?
Thanks
)
GPStimestamp = millis();
if (inChar == '\n') {
Serial.print("GPS Timestamp ");
Serial.print(GPStimestamp);
Serial.print("\t");
Serial.println(GPSbuffer);
GPSbuffer="";
}
else {
GPSbuffer += (char)inChar;
}
I get the following output :
§DISCOURSE_HOISTED_CODE_1§
Which is fine....but sometimes my GPS message is corrupted :
§DISCOURSE_HOISTED_CODE_2§
The end of message \n seems not always detected. This gets even worse when I click on the "autoscroll" button of the serial monitor.
When I don't output the accelerometer, every thing works fine.
Any Idea that could help?
Thanks