How to store incoming serial data to char array in order to send to other module (XBee)? I am trying to get the incoming serial data in Arduino from a GPS. I suppose to get the following data:


  $GPRMC,073522.000,A,2607.5285,N,12739.9649,E,0.43,263.10,131217,,,A*6C 


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

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

void setup() {
  gps.begin(9600);
  Serial.begin(9600);
}

void loop() {
  while(gps.available()) {
    delay(10);
    incomingSerialData[incomingSerialDataIndex] = gps.read();
    incomingSerialDataIndex++;
    if (incomingSerialDataIndex &gt; N-1) incomingSerialDataIndex = 0;
  }
  Serial.println(incomingSerialData);
}
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.