This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using ble_MPU_Simple Example programme we are getting only accelerometer sensor vallues.How to get the Gyro,magneto Values?

FormerMember
FormerMember

Hi I am presently working on MPU92/65 sensor interfacing with TWI/I2C.

i am using nRF51822 EK with soft device s130_nRF51_2.0.0(id:0x0080) and nRF5 SDK v11.0.0 and keil u vision5.

I was taken nrf5-ble-mpu-simple programme (C:SDK_11.0.0\examples\nrf5-mpu-examples-master\nrf5-ble-mpu-simple\pca10028\s130\arm5_no_packs\twi).

I am using nRF connect to read the values. Screenshot_20170206-121526.png But from this code we are getting values in HEX format. how to convert them to decimal.one more thing I think we are getting only accelerometer sensor values.how to get the remaining sensor values

I am attaching the screen short of output.

Please help me to convert HEX format values in to decimal and to read Gyro and Magneto sensor values.

  • Hi,

    The accelerometer, magnetometer and gyroscope values are stored in structs with an 16 bit signed integer for all axes, for example for accelerometer values:

    typedef struct
    {
        int16_t x;
        int16_t y;
        int16_t z;
    } accel_values_t;
    

    I don't know of a way to display the values as x,y,z in nRF connect, you will have to make your own app if you want to do that. Alternatively you can convert the data to strings and send them using Nordic Uart Service instead, see ble_app_uart example in the SDK.

    When data is sent over the air it is sent as bytes. Three 16 bit values will total in 6 bytes. The example treats the struct as an array which means that the first byte will be the the high byte of the X value and last byte will be the low byte of the z value. For example:

    38-37-38-F0-0C-E5
    

    will be

    x = 0x3837
    y = 0x38F0
    z = 0x0CE5
    

    Use a hex to decimal converter and you get:

    x = 14391
    y = 14576
    z = 3301
    

    To read the gyroscope values you should use:

    uint32_t mpu_read_gyro(gyro_values_t * gyro_values);
    

    and to read the magnetometer values you should use:

    uint32_t mpu_read_magnetometer(magn_values_t * p_magnetometer_values, mpu_magn_read_status_t * p_read_status);
    

    You also need to initialize the magnetometer, see the nrf5-mpu-magnetometer example for reference.

  • FormerMember
    0 FormerMember in reply to Ole Bauck

    I was edited my program according to your changes.Now I am able to read magnetometer and gyro value values.thanks

Related