-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
I am using this library to code my mpu6500 using an esp32-s3 board. I was running the following commands to activate and then get data from my MPU:
esp_err_t ret;
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = I2C_MASTER_SDA_IO,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_io_num = I2C_MASTER_SCL_IO,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = I2C_MASTER_FREQ_HZ,
};
float accel_bias[3] = {0.00f, 0.00f, 0.00f};
float gyro_bias[3] = {0.00f, 0.00f, 0.00f};
ret = i2c_param_config(I2C_MASTER_NUM, &conf);
if (ret != ESP_OK) {
printf("I2C param config failed\n");
return -1;
}
ret = i2c_driver_install(I2C_MASTER_NUM, conf.mode, 0, 0, ESP_INTR_FLAG_DEFAULT);
if (ret != ESP_OK) {
printf("I2C driver install failed");
return -2;
}
ret = mpu6050_init(I2C_MASTER_NUM);
if (ret != ESP_OK) {
printf("MPU Initialization failed\n");
return -3;
}
mpu6050_calibrate(I2C_MASTER_NUM, accel_bias, gyro_bias);
ESP_LOGI("MPU6050", "Calibration complete");
However, when I run this code, my code prints "MPU Initialization failed", which means the line ret = mpu6050_init(I2C_MASTER_NUM); throws an error. However, I can still get the data later on in my program from some other code. So, I decided to see if commenting out the ret = mpu6050_init(I2C_MASTER_NUM); line does anything, and when I tried that, I am still able to get the data.
Could anyone help me understand why the initialization line does not seem to be necessary to program my mpu6500?
Metadata
Metadata
Assignees
Labels
No labels