For a school project im making a telemetry system.
Im reciving data in 2 parts for instance FF and BC.
To reconstruct them im using the following line: Reconstruct = (BC << 8) + FF
Then I have the following value BCFF.
Next I can type Serial.Println(Reconstruct1); and I get the value (-68) (this is correct), (reconstruct is in int16_t format).
Now I have the following problem.
Ive reconstucted the following value: 104A This makes the value 4170. This is not the correct value it should be closer to 68.
I think its a int32_t (because when I use the online calculator: http://www.scadacore.com/field-tools/programming-calculators/online-hex-converter/ and put 104A in the same value comes out).
When I change the datatype it is still not the value it is seposed to be.
Ive tryed changing the bitshift from 8 to 16 this did not work.
Does anyone know a way to convert this value to the right number (it should be around 68)?
(PS. When the firstpart or second part is under 10 im multiplying it by 16. this prevents a miscalculation. When the first part is 9 and the second part is BC. Then it would be 9BC (whitout the * 16) while it is seposed to be 90BC)