Hello,
I try to use the Sprakfun LSM6DS0 breakout, but I got errors interfacing with it.
I quickly saw that I can get acceleration values and temperature, but not gyro data.
Investigating in the problem, I discovered the problem comes from I2C communication.
The board is connected to an ESP32 FireBeetle.
I already used this board with a Sparkfun ICM-20948 breakout but looking at the library, I saw that I2C errors are not checked so, maybe I also have the problem, didn't check, but that works.
So, back to my problem with the LSM6DS0, I Investigated a bit deeper with the following code, which is equivalent to imu.getAccelDataRate()
call.
void loop()
{
uint8_t status;
uint8_t regVal;
blinkState = !blinkState;
digitalWrite(LED_BUILTIN, blinkState);
Wire.beginTransmission(0x6B);
Wire.write(CTRL1_XL);
if( (status = Wire.endTransmission(false)) != 0 ) {
Serial.print("Status1 : ");
Serial.println(status, HEX);
}
Wire.requestFrom(0x6B, 1);
regVal = Wire.read();
if( (status = Wire.endTransmission()) != 0 ) {
Serial.print("Status2 : ");
Serial.println(status, HEX);
}
Serial.println(regVal, DEC);
}
And the result is:
status2 = 8
120
So clearly, the problem comes from call to Wire.endTransmission()
only, not Wire.endTransmission(false)
.
But according to Arduino doc, returns of Wire.endTransmission()
can be one of:
- 0:success
- 1:data too long to fit in transmit buffer
- 2:received NACK on transmit of address
- 3:received NACK on transmit of data
- 4:other error
Nothing about error code 8.
So, I don't really understand what happens here.
Globally, communication works, but something is bad anyway and because of that, I suspect some initialization code fails and gyro may be not enabled.
Any idea?