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

Problem with MPU6050 and nRF51822 to send Data over BLE..

I am trying to send the MPU6050 data using BLE nRF51822. I have used ble_app_uart example modified it to read the data over I2C and send the data over BLE. I can successfuly read device ID but when i read accelerometer or gyroscope data I am unable to read any register. Please help me 

  • So your question is actually just about how to read the sensor - not (yet) about how to send data over BLE.

    It is important to take these things one step at a time!

    I can successfuly read device ID

    So you must have your basic I2C comms working, then.

    but when i read accelerometer or gyroscope data I am unable to read any register

    So there must be something wrong with your higher-level code.

    You need to check your code carefully against the MPU6050's datasheet - and confirm that you are doing exactly what it says. 

    You should also look at the I2C line with an analyser or oscilloscope to see what is acually happening - and, again, confirm that it meets the datasheet requirements.

    This is all standard interface debugging stuff - nothing specifically to do with Nordic.

    www.avrfreaks.net/.../2418156

  • Yeah, you are right. But the same code which reads the accelerometer and gyroscope registers works fine when run separately. Actually I merged two examples together one ble_app_uart and other reads data from MPU6050 and prints the data on the terminal. 

    Here are some snippets of the code which reads data.

    void MPU6050_ReadAcc( int16_t *pACC_X , int16_t *pACC_Y , int16_t *pACC_Z )
    {
        
    	uint8_t buf[6];    		
    //	uint8_t addr= MPU6050_ADDRESS << 1;
    
        
    	mpu6050_register_read(MPU6050_ACC_OUT, buf, 6);
      *pACC_X = (buf[0] << 8) | buf[1];
    	if(*pACC_X & 0x8000) *pACC_X-=65536;
    		
    	*pACC_Y= (buf[2] << 8) | buf[3];
      if(*pACC_Y & 0x8000) *pACC_Y-=65536;
    	
      *pACC_Z = (buf[4] << 8) | buf[5];
    	if(*pACC_Z & 0x8000) *pACC_Z-=65536;
    }
    

  • BLE is working fine actually i am reading the device ID and send it  over BLE which works. 

    Here is the snippet. 

    	nrf_delay_ms(50);
    	mpu6050_register_read(0x75U, &id, 1); // Read the device ID 
        err_code=ble_nus_string_send(&m_nus, gyrValue.temp2, 6); // Send over BLE
    				
        APP_ERROR_CHECK(err_code);				
        nrf_delay_ms(2);			
    	id=0;

  • the same code which reads the accelerometer and gyroscope registers works fine when run separately.

    So you need to find where the BLE is "disrupting" it.

    •  Does the combined code read the accelerometer & gyroscope registers fine if you just don't enable the BLE?
    • Does the combined code read the accelerometer & gyroscope registers fine if the BLE is enabled, but not actually connected?
    • Are you sure that it's not reading the registers - or is it just that your transmission is corrupting the data?
  • Let me check and will reply and thanks for the help.

Related