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(buffer);
Note: Don't use String class in a MCU, use zero terminated character arrays.