Ok today i've test to modify the adafruit library. i remove some code inside to have just the Wire.read() values and i get some good news.
Here is the original code of the read function
Code: Select all
void Adafruit_MMA8451::read(void) {
// read x y z at once
Wire.beginTransmission(_i2caddr);
i2cwrite(MMA8451_REG_OUT_X_MSB);
Wire.endTransmission(false); // MMA8451 + friends uses repeated start!!
Wire.requestFrom(_i2caddr, 6);
x = Wire.read(); x <<= 8; x |= Wire.read(); x >>= 2;
y = Wire.read(); y <<= 8; y |= Wire.read(); y >>= 2;
z = Wire.read(); z <<= 8; z |= Wire.read(); z >>= 2;
uint8_t range = getRange();
uint16_t divider = 1;
if (range == MMA8451_RANGE_8_G) divider = 1024;
if (range == MMA8451_RANGE_4_G) divider = 2048;
if (range == MMA8451_RANGE_2_G) divider = 4096;
x_g = (float)x / divider;
y_g = (float)y / divider;
z_g = (float)z / divider;
}
As you can see we have a bit to bit convertion to have the angle in positive and negative value just after the requestFrom. If i remove the convertion
Code: Select all
x = Wire.read(); x <<= 8; x |= Wire.read(); x >>= 2;
y = Wire.read(); y <<= 8; y |= Wire.read(); y >>= 2;
z = Wire.read(); z <<= 8; z |= Wire.read(); z >>= 2;
and just do this
Code: Select all
Wire.requestFrom(_i2caddr, 8);
x = Wire.read(); //for fake using of bit
x = Wire.read();
y = Wire.read();
z = Wire.read();
X,Y and Z are stable from 0 to 255 but when i arrived at 0 if i continue to move a drop to 255 and decrease.
My supposition is the Z-Uno can't make this convertion because... I don't know, maybe to much bit to read or the convertion is to complexe for it.
I continu to test some other things, if someone can help me...