Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    BMA 456 not getting acceleration data using I2C.

    BMA 456 not getting acceleration data using I2C.

    New Poster


    I'm currently developing a system that collects accelerometer data and uploads it to cloud and I'm using a BMA456 connected to a Quectel BC66-NA NB-IoT module communicating over i2c. I was able to initialize and configure the accelerometer sensor but when trying to read the data, there is no data coming in the registers.Also the sensor returns no error.

    Can anyone please tell me what I'm missing? Below is my code.

    void proc_main_task(s32 taskId)
        s32 ret;    
        uint16_t rslt = BMA4_OK;
        /* Declare an instance of the BMA456 device */
        struct bma4_dev dev;
        /* Modify the parameters */
        dev.dev_addr = BMA4_I2C_ADDR_PRIMARY;
        dev.interface = BMA4_I2C_INTERFACE;
        dev.bus_read = USER_i2c_read;
        dev.bus_write = USER_i2c_write;
        dev.delay = Ql_Sleep;
        dev.read_write_len = 8;
        APP_DEBUG("\r\n<--Initializing BMA 456-->\r\n");
        /* Initialize the instance */
        rslt |= bma456_init(&dev);
        APP_DEBUG("\r\n<--bma456_init--> rslt = %d-->\r\n", rslt);
        if (rslt != BMA4_OK){
                APP_DEBUG("\r\n<--Accelerometer Initialization Failed--> rslt = %d-->\r\n", rslt);
                return rslt;
        if (rslt == BMA4_OK){
            APP_DEBUG("\r\n<--Accelerometer Initialization Success--> rslt = %d-->\r\n", rslt);
        APP_DEBUG("\r\n<--Enabling the Accelerometer Sensor-->\r\n");
        /* Enable the accelerometer */
        bma4_set_accel_enable(BMA4_ACCEL_ENABLE_MSK, &dev);
        APP_DEBUG("\r\n<--Configuring the Accelerometer Sensor-->\r\n");
        /* Declare an accelerometer configuration structure */
        struct bma4_accel_config accel_conf;
        /* Assign the desired settings */
        accel_conf.odr = BMA4_OUTPUT_DATA_RATE_100HZ;
        accel_conf.perf_mode = BMA4_CONTINUOUS_MODE;
        accel_conf.range = BMA4_ACCEL_RANGE_4G;
        accel_conf.bandwidth = BMA4_ACCEL_NORMAL_AVG4;
        /* Set the configuration */
        rslt |= bma4_set_accel_config(&accel_conf, &dev);
        APP_DEBUG("\r\n<--bma4_set_accel_config--> rslt = %d-->\r\n", rslt);
        if (rslt != BMA4_OK){
                APP_DEBUG("\r\n<--Accelerometer Configuration Failed--> rslt = %d-->\r\n", rslt);
                return rslt;
        if (rslt == BMA4_OK){
            APP_DEBUG("\r\n<--Accelerometer Configuration Success--> rslt = %d-->\r\n", rslt);
        /* Declare an instance of the sensor data structure */
        struct bma4_accel sens_data;
        /* Loop forever */
        while (1) {
            /* Read the sensor data into the sensor data instance */
            rslt |= bma4_read_accel_xyz(&sens_data, &dev);
            APP_DEBUG("\r\n<--bma4_read_accel_xyz--> rslt = %d-->\r\n", rslt);
            /* Exit the program in case of a failure */
            if (rslt != BMA4_OK){
                APP_DEBUG("\r\n<--Accelerometer Read Failed--> rslt = %d-->\r\n", rslt);
                return rslt;
            /* Use the data */
            APP_DEBUG("<--X: %d, Y: %d, Z: %d-->\r\n", sens_data.x, sens_data.y, sens_data.z);
            /* Pause for 10ms, 100Hz output data rate */
    2 REPLIES 2

    Occasional Contributor

    Could you provide more detail information ?

    1. Does BMA456 directly use NB-IOT module internal i2c interface, Quectel supplier should provide special hw/sw to enable i2c function.

    2、Can chip ID be read?

    3、Checked the code, i2c driven is not included in the main function, if necessary, upload complete code.

    4、during code running, rather use logic analyzer capture I2C waveform and VDD power supply for further analysis

    Community Moderator
    Community Moderator

    Since there was no feedback for a long time, we close this topic first. You could update feedback in the future if you have.