This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BMI160 + NRF52832 + I2C

HI,

I want to develop a program to access Accelerometer and gyroscope value from BMI160 sensor. I have used this BMI160 library 

I alter the TWI_SENSOR code and it works for self testing ACC code. but i need to calibrate the x, y, z axis value and i want to add BLE stack to read in mobile app.

1. How to collect all the X,Y,Z axis value

2. i need to see the LOGS in Bluetooth app by using BLE_UART. how to edit the BLE_UART code to get the respective ACC and GYRO value in BLE APP.

Is there any code for reading X,Y,Z axis for BMI160??

Parents Reply
  • this error happen when i move the sensor fast.

    in the above image

    rslt is the return err_ode from  BMI init();

    rsltr is the return err_code from Acc_i2c_Read();

    rsltw from Acc_i2c_Write();

    rsltb from ble_nus_data_send();

        rslt = bmi160_init(&sensor);
        APP_ERROR_CHECK(rslt);
    
    
      rslt = bmi160_set_sens_conf(&sensor);
        APP_ERROR_CHECK(rslt);
        
        
        int8_t Acc_i2c_Write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)
    {
    
        //  NRF_LOG_INFO("WRITE: dev_id: %x reg_addr: %x reg_data: %x len: %i\n", dev_id, reg_addr, *reg_data, len);
    	//int8_t rslt = 0;
    	uint8_t data[len + 1];
    	data[0] = reg_addr;
    	for (uint16_t i = 0; i < len; i++) {
    		data[i + 1] = reg_data[i];
    	}
    	
    	rsltw = nrf_drv_twi_tx(&m_twi, dev_id, data, len + 1, false);
    	APP_ERROR_CHECK(rsltw);
            return rsltw;
      
    }
    
    
    int8_t Acc_i2c_Read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)
    {
    	//int8_t rslt = 0;
       //     NRF_LOG_INFO("READ: dev_id: %x reg_addr: %x len: %i\n", dev_id, reg_addr, len);
    	rsltr = nrf_drv_twi_tx(&m_twi, dev_id, &reg_addr, 1, true);
            APP_ERROR_CHECK(rsltr);
    
    	if (rsltr == 0)
    	{
    		rsltr = nrf_drv_twi_rx(&m_twi, dev_id, reg_data, len);
    	}
        //    NRF_LOG_INFO("READ: %x",*reg_data);
    	return rsltr;
    }
    
    
          length1 = sprintf(str, "DataX = %5d \n", accel.x);
    
          rsltb = ble_nus_data_send(&m_nus, str, &length1, m_conn_handle);
         // APP_ERROR_CHECK(rsltb);
    
    

Children
No Data
Related