How to convert string to byte array on arduino
Well, the C string is already byte array.

If you mean Arduino's String class, then it has c_str() method.

Both needs reinterpret cast to const byte pointer:

byte const* byteArray = reinterpret_cast&lt;byte const*&gt;(yourString.c_str());