Hi, I am trying to understand the conversion of integer sensor values (an MPU6050 in this case) running at 20Hz. I will be storing these values inside a microSD card.
So the excellent jrowberg example has examples for both outputting the values as human readable integer values and binary raw values.
His code for outputting binary raw values is:
int16_t ax, ay, az; Serial.write((uint8_t)(ax >> 8)); Serial.write((uint8_t)(ax & 0xFF)); Serial.write((uint8_t)(ay >> 8)); Serial.write((uint8_t)(ay & 0xFF)); Serial.write((uint8_t)(az >> 8)); Serial.write((uint8_t)(az & 0xFF));
I dont get these lines, from what I have been able to gather on my own is that he's converting an int16 into 2 smaller values, the first one by using a right shift operator, and the second one is somehow converted to hexadecimal. Can someone please explain what he's trying to do here?
Also when I try to read these values from the Serial Monitor, the values just show up as a series of mirrored question marks along with a couple of random characters.
In the bigger picture what I am trying to do is to send these accelerometer values as nanopb buffers, should I be using integer values and let nanopb handle the conversions to binary data or use binary data to begin with as input to the buffers? I am aiming for the buffers to be the smallest size possible.