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

mpu6050 on Nrf51822

Hello

Is there any example or tutorial on how to use the mpu6050 library? I just started to program the nrf51822 and hope to find some helpful clues to get me going.

Any suggestion would be appreciated.

Nick

Update: I got the mpu-6050 working on keil, but without the mentioned examples. I did found some example on a chinese website. With some help of google translate i got to tweak it a little. For someone who is just a beginner most examples look difficult so i am already happy i got it working. And i can work forward from that base. For everyone who likes to use this very simple example. Here is my project; NRF51-MPU6050.rar

Parents
  • I am using the MPU6050 in a hobby project and successfully using the motion driver library. In both library files (inv_mpu.c and inv_mpu_dmp_motion_driver.c) I added the following block

    #elif defined NRF51
    #include "nrf_delay.h"
    #include "app_timer.h"
    #include "i2c.h"
    #define delay_ms    nrf_delay_ms
    static inline int get_ms(unsigned long *count) {
        static uint32_t cnt;
        app_timer_cnt_get(&cnt);
        cnt >>= 5;
        *count = cnt;
        return 0;
    }
    static inline int reg_int_cb(struct int_param_s *int_param) {
        (void) int_param;
        return 0;
    }
    #define log_i(...)     do {} while (0)
    #define log_e(...)     do {} while (0)
    //#define log_i(...)  SEGGER_RTT_WriteString(__VA_ARGS__)
    //#define log_e(...)  SEGGER_RTT_printf(0, __VA_ARGS__)
    //labs already defined in stdlib.h
    //fabsf already defined in math.h
    #define min(a,b) ((a<b)?a:b)
    

    just before

    #else
    #error  Gyro driver is missing the system layer implementations.
    #endif
    

    Due to limited board space, I'm not using the interrupt line, instead I am polling the fifo buffer of the MPU6050. Therefor the reg_int_cb function is empty.

    The i2c_read and i2c_write functions are in the following files:

    i2c.h

    i2c.c

    These functions are using the twi driver of SDK 9.0.0 and I added some error handling. In my case the data of the MPU6050 is used to drive two power LEDs in dependency of the inclination. But as soon as the SMPS Driver for either of one of the LEDs is running, the MPU6050 makes heavy use of clock stretching. This leads to acknowledge errors sometimes. The read and write functions will try again if that happens. Additionally to that these function also recovers the TWI interface if it gets stuck (I'm using HW Rev. 2 ICs)

    I hope these information helps you.

  • Hello. I've recently found this thread. 

    I'm struggling to use DMP functions (inclination).

    Could you share the code of this hobby project? 

    Thank you!

Reply Children
No Data
Related