Without the HEX specifier, print() will print in decimal. Isn't that what you want? If not, how do you think that anyone could guess what this means...
// i will get 33E4 in a converter to ascii it would be 13284
"33E4" is ASCII. Do you want a decimal representation? Then don't print it in hex.
You need to learn about data types and data representation.
ASCII is a standard for character representation. When you use Serial.print every character is displayed using ASCII. 33E4 is 4 ASCII characters and 13284 is 5 ASCII characters.
In your Arduino data is not stored in ASCII but as bits and bytes. They can mean all kind of things. What they mean is controlled by the data types (char, int, long) and there modifiers (e.g. unsigned). But also by byte order called little-endian vs big-endian.
For your case
CAN sends bytes, so for a 16-bit integer you need two bytes.
to get an unsigned int you need to combine the two bytes. This has been discussed many times in the forum. A quick Google search will get you many examples. e.g.
Hex, decimal, binary are just ways to represent the number. It's all the same to the processor.
I've never worked with CAM data, but this may help with how you can convert the hex string to an unsigned integer:
/*
Demo of hex to int conversion
*/
void setup() {
Serial.begin(115200);
delay(10);
Serial.println();
char hexValue[] = "33E4";
int x = strtol(hexValue, NULL, 16);
Serial.print(F("x in HEX= "));
Serial.println(x, HEX);
Serial.print(F("x in DECIMAL= "));
Serial.println(x, DEC);
}
void loop() {
}
Thank you guys verry much for the help.
I will check and try everything this evening.
Let you know how it it goes.
To clarify my issue. The reading is printed in HEX as the code shows. My output is variable. But in this case it is 33E4. When i put the 33E4 value in a app (ASCII CONVERTER) HEX> ASCII i will get the value 13284 (this value is the one i need )
I can print the output in DEC,OCT,HEX but could not seem to find the same results as the converter app gives me.