I'm trying to convert a byte array into a string using the following code.
String b = String((char*)buffer2);
but when I output the string I get a very strange result that contains white spaces and special characters that normally shouldn't be in the string.
buffer2 is of the type byte and its length is 18. this is how its declared:
byte buffer2[18];
When I use the following code to print the byte array I get the results I expect.
for (uint8_t i = 0; i < 16; i++) {
Serial.write(buffer2[i] );
}
I'm wondering how I can convert a byte array to a string the proper way.