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

Initialization and operation of sensor mpu6050 with nrf52840 development board

I want to be able to read the gyro and accelerometer values from the MPU6050 sensor.

As a base start I downloaded the  NRF5 SDK V15.3.0 and modified twi_sensor_pca10056 program using editor software Kielu5 to initialize the MPU6050. My current problem is that I am not getting the correct reading values from the sensor. The problem I think is coming from the MPU6050 initialization. Because the TWI supposed to work fine since its a working project and I also tested the UART by sending some initial test strings before operating.

I modified the project by including the following MPU related libraries in the main project:

  • sensor_mpu6050.h
  • sensor_mpu6050.c

I am connecting the SCL and SDL to the following respective board pins:

       SCL    = MPU6050_SCL_PIN,      // PIN 0.27
       SDA    = MPU6050_SDA_PIN,     // PIN 0.26

In the main.c , I am initializing the MPU and trying to read the MPU values and displaying them on a serial  terminal window using UART.

I am attaching the current working project main program and the added mpu libraries, the complete project is inside NRF5 v15.3.0 , I left it there since there are certain libraries that are spread across the SDK.

LINK TO PROJECT DOWNLOAD

PATH LINK TO CURRENT WORKING PROJECT :     nRF5_SDK_15.3.0_59ac345\examples\peripheral\twi_sensor\pca10056\blank\arm5_no_packs

I would appreciate someone's help since I'm new to this type of technology, don't hesitate to ask for more information.

Parents
  • Hi

    I tried running your project, and I have no problems printing to UART. I'm using an nRF52840DK with no peripheral attached and print to a PuTTY terminal, and the terminal keeps printing these values:

    TWI example started CLARK.
    <info> app:
    im here 4.
    <info> app:
    im here 5.
    <info> app:
     im here 6.
    <info> app:
     cx is 7.
    <info> app:
     gyro is 0
    <info> app:
     gyro is 0
    <info> app:
     gyro is 0
    <info> app:
    im here 5.
    <info> app:
     im here 6.
    <info> app:
     cx is 7.
    <info> app:
     gyro is 0
    <info> app:
     gyro is 0
    <info> app:
     gyro is 0
    <info> app:
    im here 5.
    <info> app:
     im here 6.
    <info> app:
     cx is 7.
    <info> app:
     gyro is 0
    <info> app:
     gyro is 0
    <info> app:
     gyro is 0
    <info> app:
    im here 5.
    <info> app:
     im here 6.
    <info> app:
     cx is 7.
    <info> app:
     gyro is 0
    <info> app:
     gyro is 0
    <info> app:
     gyro is 0
    

    I used SEGGER Embedded Studios to build and run your project, and all I had to do was to add the header files to the preprocessor defines as described here. So there doesn't seem to be any issues with how you initialize UART on the nRF side. Is the problem that you're not able to get the correct values from the MPU6050 or that the UART doesn't print at all for you?

    Best regards,

    Simon

  • Thanks for taking the time to test out my code, but my problem is that I am not getting the correct values from the mpu6050 sensor.

Reply Children
No Data
Related