[Solved] How to supress leading zero trimming with serial.print(var, HEX);

PaulS:

So, because the value being fed to the template %02X is a byte, why can't I expect that in all cases the result will always be two characters?

You can. I said that because the variable type is a byte, you won't get more than two characters. You could, though, use %02x as the format specifier and an int or long as the type. Then, you could get more than two characters, but never less than 2.

I'm expecting that so I would have 1 + 2 + 2 = 5 characters as a result from sprintf(). How would that ever overwrite the 6th character of the array?

You are not counting the NULL that sprintf() adds to the array. 1 + 2 + 2 + 1 = 6.

I suppose I could follow the sprintf() with dataStream[5] = 0x0;, but why would that ever be necessary?

It isn't. sprintf() adds the NULL for you. (I'm getting tired of typing that. 8))

Ouch. My bad. Until I read this post I was reading "sprintf() DOES NULL terminate the array" as "DOES NOT terminate"... Sorry for that.