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

nrf51822 and mpu9250 magnetometer reading

hi,

I am currently learning to use the mpu6050 read and write code in the SDK from the nrf5_sdk_12.3.0_d7731ad to control mpu9250. The part of the gyroscope and accelerometer in mpu9250 is now complete, but when I try to read the WIA register of the magnetometer, the output from uart is always 0.

My partial configuration and output code is as follows:

#include "nrf_drv_uart.h"
#include "mpu6050.h"
#include "twi_master.h" 
#include "twi_master_config.h"

mpu6050_register_write(0x0B,0x01);
mpu6050_register_write(0x0A,0x10);
mpu6050_register_write(0x24,0x1D);
mpu6050_register_write(0x31,0x8C);
mpu6050_register_write(0x32,0x00);
mpu6050_register_write(0x34,0x80);

mpu6050_register_read(0x35,&data,1);
printf("%d",data);

Parents Reply
  • Hello,

    I think you will have to backport the example that Rune linked to back to SDK12.3.0. SDK 12.3.0 does have i2c, so it should work, but you will have to include the mpu9250 drivers. Unfortunately, the SDK12.3.0 does not have the drivers for the mpu9250, but you should be able to use it similar to the mpu6050 when the registers are updated.

     

    Best regards,

    Edvin

Children
No Data
Related