NRF problem with mpu6050 and twi.

Here is the situation:I can read the accvalues by uart without the ble, but when I was trying to read the values on the phone with the ble, it didnt work. I modified the official tutorial code"ble_uart", it can be built, but the bluetooth didnt work. Also, I tried the original "ble_uart" code without mpu6050, it actually worked, Buuuut ! When it was working , I intered mpu6050 in nrf52840, the blut tooth didnt work! I just couldnt figure it out. Pleas help meeee.

Parents
  • Hello,

    Are you actually using UART or TWI between the MPU6050 and the nRF? 

    And if I understand you correctly, it is working one at the time (either Bluetooth or MPU), so what happens when you try to run it? Does the log say anything? Can you upload your main.c and your sdk_config.h? Perhaps it can give some hints on what may be the problem.

    Best regards,

    Edvin

  • Thanks for answering me, UART has no problem, my problem is that it can run “ble_uart” and my phone actually can connect the NRF,but the instance I intered the mpu6050 in nrf52840, my phone disconnect automatically. After that, I modified the code based on "ble_uart" and "i2c drives mpu6050", which can run respectively. I tried to combined the two codes to make bluetooth read acceleration values, unfortunately, it failed.

    Here is some snippet

    accel_values_t AccValue;
    	uint8_t Mpu_D1[8];
    	mpu6050_read_accel(&AccValue);
    	Mpu_D1[0]=flags;
    	Mpu_D1[1]=AccValue.x>>8;
    	Mpu_D1[2]=AccValue.x;
    	Mpu_D1[3]=AccValue.y>>8;
    	Mpu_D1[4]=AccValue.y;
    	Mpu_D1[5]=AccValue.z>>8;
    	Mpu_D1[6]=AccValue.z;
    	Mpu_D1[7]=0x00;
    	uint16_t M_Len;
    	M_Len= sizeof(Mpu_D1);
      err_code = ble_nus_data_send(&m_nus,Mpu_D1,M_Len,m_conn_handle);
      
      

    Thanks again,your answer means a lot for me!Heart

    Jay Chou

  • Do you see any logs from the nRF? If not, can you try to set the define:

    NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED

    to 0 in sdk_config. Do you see any logs then? If so, what does the log say when it disconnects?

Reply Children
Related