Convert small 64bit signed integer into a high and low byte ?


Author Message
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 3277
Posted: 09:51pm 02 May 2026      

As 24 bit ADC values greatly exceed the accuracy of the sensors, perhaps try leaving out the least significant bytes as they will be mostly noise.

16 bits will still give greater resolution than the sensor accuracy but might be processed more easily with Bin2str$.
Eg. press = pdat(4) + (pdat(5)<<8) '16 bit

I did a similar thing with the AHT10 temperature & humidity sensor which has 20 bits for each using 5 bytes, with the middle byte having 4 bits of each.
Using 12 bits for temp. and 8 for humidity gave the same results with less code.

  AHT10 datasheet said   Humidity accuracy: typical ± 2%
 Humidity resolution: 0.024%
 Temperature accuracy: typical ± 0.3 ° C
 Temperature resolution: Typical 0.01 °C


Edit.
Another possibility is that all the data is in the lower bytes and the high byte is all 0s (or 1s for negative values). If so ignore the high byte.

What sensor are you using? I will have a look at the datasheet to see what is easiest.
Edited 2026-05-03 11:30 by phil99