Skip to content

Able to get accelerometer data without running mpu6050_init #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Ishan-Sharma-17 opened this issue Feb 28, 2025 · 0 comments
Open

Comments

@Ishan-Sharma-17
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant