removing characters from a char array

Hi,

I have a char array called 'receivedChars'. The first character is ascii capital 'R' and the next 4 characters are numbers, a sensor reading.

How can remove the 'R' and convert the numbers to a string?

Here is my code so far. In the void showNewData() I tried converting the char array to a string and using the String remove method() but it doesn't seem to work.

Many thanks

const byte numChars = 32;
char receivedChars[numChars];  // an array to store the received data

boolean newData = false;

void setup() {
  Serial.begin(9600);
  Serial.println("<Arduino is ready>");
}

void loop() {
  recvWithEndMarker();
  showNewData();
}

void recvWithEndMarker() {
  static byte ndx = 0;
  char endMarker = '\r';
  char rc;
  
  // if (Serial.available() > 0) {
           while (Serial.available() > 0 && newData == false) {
    rc = Serial.read();

    if (rc != endMarker) {
      receivedChars[ndx] = rc;
      ndx++;
      if (ndx >= numChars) {
        ndx = numChars - 1;
      }
    }
    else {
      receivedChars[ndx] = '\0'; // terminate the string
      ndx = 0;
      newData = true;
    }
  }
}

void showNewData() {
  if (newData == true) {
    //Serial.print("This just in ... ");
    String s = receivedChars;
    s.remove(0, 0);
    Serial.println(s);
    newData = false;
  }
}

conor1:
How can remove the 'R' and convert the numbers to a string?

You don't need to remove the R - you could just change it to a '0' (character 0 rather than binary value 0) with receivedChars[0] = '0';

Then you should be able to use atoi() to turn the data in receivedChars into a number. This is illustrated in the parse example in Serial Input Basics

If that does not work please give us an example for actual data you are using.

...R