ByteArray to String

I’m running a Gps-Shield and Micro Oled. Getting a byte-Buffer the conversion to String failed using (const char*)ByteBuffer*.*
*// initializing oled…

int inByte = 0;       
byte pbyGpsBuffer[100];
int byBufferIndex = 0;

void loop()

byte byDataByte;
  if (Gps_serial.available())
    byDataByte =;
    pbyGpsBuffer[ byBufferIndex++ ] = byDataByte; 
    if( byBufferIndex >= 100 )
      byBufferIndex = 0;     
      File dataFile =“gps.txt”, FILE_WRITE);
      // get Byte-Buffer to String
      for (int i=0; i<=100; i++) {
        str += (const char*)pbyGpsBuffer[i];

 oled.setCursor(0, 0); 


Fumbling around in the dark, what happens if you remove the word "const" ?

Hello and welcome,

Why use a String? You already have an useable char array.

if( byBufferIndex == 99 )
    pbyGpsBuffer[ byBufferIndex ] = '\0';
    byBufferIndex = 0;
    oled.print( pbyGpsBuffer );

the matter of conversion is to filter NMEA-data - with strsep() for a convenient output on LCD.

pbyGpsBuffer data:

works well,
but needful are just some tokenized informations, so i do that with strsep() on a String. If there is a direct way with ByteArray.. will be better


If there is a direct way with ByteArray.. will be better

There is the TinyGPS++ library that handles all the tokenizing and conversion to appropriate types for you.

strtok() will be right having a String, therefore convertion is necessary

in TinyGPS++ library aren't get functions

I copied the below from somewhere in the past, which might be of use.

String myString = String((char*)myByteArray);


void setup(void)

void loop(void)
  byte byteArray[5];
  strcpy((char *)byteArray,"0123");
  String myString = String((char *)byteArray);

String myString = String((char*)myByteArray);

That sounds like a song.

“Only trouble is, String string, I’m stringing my bytearray.”

Everly Brothers?

String of Pearls !

Thanks, with TinyGPS++ lib i get marvelous output on Oled.

Also, I find that strtok() works just fine on char arrays. I find using the String class is only useful if you need a crutch.

String of Pearls !

Glenn Miller?