I am trying to get the incoming serial data in Arduino from a GPS. I suppose to get the following data:


However, it is not stable. Following is the code. Appreciate your help.

#include <SoftwareSerial.h>
SoftwareSerial gps(2, 3); // RX, TX
int N = 70; // size of array
char incomingSerialData[70]; //32
int incomingSerialDataIndex = 0;

void setup() {

void loop() {
  while(gps.available()) {
    incomingSerialData[incomingSerialDataIndex] = gps.read();
    if (incomingSerialDataIndex > N-1) incomingSerialDataIndex = 0;

closed as unclear what you're asking by gre_gor, jose can u c, per1234, user31481, Avamander Dec 16 '17 at 0:23

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    have you done any research about storing values in an array? – jsotola Dec 14 '17 at 7:07
  • Yes, I did plenty ways. However, all same unstable. – zalt Dec 14 '17 at 7:13
  • 3
    unstable does not describe the observed results in any meaningful way. in other words, it does not mean anything other than it does not work – jsotola Dec 14 '17 at 7:25
  • 2
    delay(10) is a very bad idea. See Reading Serial on the Arduino. – Edgar Bonet Dec 14 '17 at 9:41
  • 3
    Most sane people use one of the many NEMA parsing libraries to do the work for them... – Majenko Dec 14 '17 at 10:41

NMEA sentences cannot be longer than 80 visible characters + terminators. Even with a CRLF, that's a max of 82 characters. You should be fine with a fixed-sized char array of 82.

  • The size of array is set to be 70 since that sentence has 70 characters. – zalt Dec 14 '17 at 7:15
  • And that's a mistake since NMEA sentences can be longer than 70. – dda Dec 14 '17 at 7:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.