I'm looking at parsing information from a temp/humidity sensor that was provided with the following instructions;
There are 6 bytes.
Temperature positive/negative: 0 means positive (+) and 1 means negative (-)
Integer part of temperature. Show in Hexadecimal.
Decimal part of temperature. Show in Hexadecimal.
Reserved byte. Ignore it.
Integer part of humidity. Show in Hexadecimal.
Decimal part of humidity. Show in Hexadecimal.
For example: 00 14 05 22 32 08 means +20.5C 50.8% & 01 08 09 00 14 05 means -8.9C 20.5%
as each byte is in hex & i need to covert this to an Int I followed this approach - Java code To convert byte to Hexadecimal but the values I get when validating their example don't make sense.In Kotlin I do;
val example = byteArrayOf(0, 14, 5, 22, 32, 8)
example.map { Integer.parseInt(String.format("%02X ", it),16)}
First Example output is;
0 = "00 "
1 = "08 "
2 = "09 "
3 = "00 "
4 = "0E "
5 = "05 "
Second Example output;
0 = "00 "
1 = "0E "
2 = "05 "
3 = "16 "
4 = "20 "
5 = "08 "
What am I doing wrong? I'm starting to think the manufactures instructions could be 'misleading'