I'm using ESP32 and 1 sensor mpu9250(only for test) with tca9548a, connections are:
TCA <-> ESP
VIN - VCC
GND - GND
SDA - GPIO21
SCL - GPIO22
TCA <-> MPU
SD2 - SDA
SC2 - SCL
VIN - VIN
GND - GND
And my code here:
#include <SparkFunMPU9250-DMP.h>
#include <Wire.h>
#define TCAADDR 0x70
void tcaselect(uint8_t i) {
if (i > 7) return;
Wire.beginTransmission(TCAADDR);
Wire.write(1 << i);
Wire.endTransmission();
}
MPU9250_DMP imu;
void setup()
{
Serial.begin(115200);
Wire.begin();
tcaselect(2);
if (imu.begin() != INV_SUCCESS)
{
while (1)
{
Serial.println("Unable to communicate with MPU-9250");
Serial.println("Check connections, and try again.");
Serial.println();
delay(5000);
}
}
imu.dmpBegin(DMP_FEATURE_6X_LP_QUAT | // Enable 6-axis quat
DMP_FEATURE_GYRO_CAL, // Use gyro calibration
10); // Set DMP FIFO rate to 10 Hz
delay(10000);
}
void loop()
{
tcaselect(2);
imu.dmpUpdateFifo();
float q0 = imu.calcQuat(imu.qw);
float q1 = imu.calcQuat(imu.qx);
float q2 = imu.calcQuat(imu.qy);
float q3 = imu.calcQuat(imu.qz);
Serial.println("Q: " + String(q0, 4) + ", " +
String(q1, 4) + ", " + String(q2, 4) +
", " + String(q3, 4));delay(10);
}
I need to get quaternions from the MPU sensor but I'm only getting zeros on the output.
Library that I used: https://github.com/rupin/SparkFun_MPU-9250-DMP_Arduino_Library
What could be wrong, my connection or library?