Problems on convert byte[] to String
byte and char are the same. If you set 0 as string terminator after last character in the buffer, you get a zero terminated string. If you really must use String, you can create an instance with a constructor that takes zero terminated string.

buffer[tam] = 0;
String str((char*) buffer);


Let in the buffer a place for the zero. (char*) is cast that says that the byte array is a char array. 

Note: Don't use String class in a MCU, use zero terminated character arrays.