2016年8月16日 星期二

[nRF52832] [Taobao-Version] nRF52832 BLE Uart + MPU6050 Test

1. 主要是在底下這2篇的基礎下, 將兩個範例合在一起, 透過I2C去抓取MPU6050 Acc x/y/z軸數值, 並透過BLE Uart將所抓到的Acc x軸數值透過BLE丟出來.

2. Test Video:


3. Test Code link: (IDE: Keil-MDK v5.20)


4. softdevice link:

    s132_nrf52_2.0.1_softdevice.hex 

5. To be continued........




15 則留言:

  1. 這篇對我幫助很大,我自己也做了延伸,不知您那邊是否有MPU9255可以測試,我用你的程式進行修改寫程九軸控制,但是M軸就是用AK8963一直都沒有值是否能求救~Please

    回覆刪除
    回覆
    1. Hello Patrick:

      1. 你有用示波器或是邏輯分析儀去看一下為何沒有數值嗎? 是ak8963的i2c address設定錯了才沒有值, 還是有讀成功但數值永遠都是0, 建議你先做初步的分析.

      2. mpu9250已經內建m sensor了, 你是讀不到內建的m sensor data, 還是讀不到外接的ak8963 data?

      Have a nice day,
      JustinWang

      刪除
    2. 有的,我有用邏輯分析儀去讀,數值一開始為Setup Write to ['208']+ACk, K+ACK,'128'+ACK,Setup Write to ['208']+ACk, K+ACK,'0'+ACK......Setup Write to ['208'],我得I2C,MPU6050_I2C_ADDRESS 0xD1 ,我的MPU板子上是寫MPU-92/65,因為看了你的範例,我就直接用MPU6050去改,因為我自己加入MPU9250的lib都失敗,所以我用的方法是讀mpu6050的A與G值,在寫一個AK8963來讀,不知這樣是否有誤,或是我可以跟你要gmail會比較好討論可以嗎?

      刪除
    3. Hello patrick:

      If you have any problem, you can send mail to me, my e-mail address is "wangwewe@mirlab.org",
      thanks.

      Have a nice day,
      JustinWang

      刪除
  2. Hello. Thanks for your works.
    I want to add virtual com port (Bluetooth Serial Port), When nRF52832 is connected. How Can I do this?

    回覆刪除
    回覆
    1. Hello:
      Do you mean you want to use nRF52 to do Virtual Com-Port?
      If yes, you can use ble uart example code on nRF52 SDK.

      Have a nice day,
      JustinWang

      刪除
  3. Hello Justin

    I saw this post and I apply it in the nRF52832. I added another function to read the Gyroscope axis and I only got 0 in the tree axis, I did it just I show you below:

    void MPU6050_GetGyroData(float *gyr)
    {
    uint8_t tmp[6] = {0};
    int16_t tmp_int[3] = {0};

    i2c_read(MPU6050_I2C_ADDRESS ,MPU6050_GYRO_XOUT_H, tmp, 0x06);
    tmp_int[0] = (int16_t)((tmp[0]<< 8) | tmp[1]);
    tmp_int[1] = (int16_t)((tmp[2]<< 8) | tmp[3]);
    tmp_int[2] = (int16_t)((tmp[4]<< 8) | tmp[5]);

    }

    And I call it in main program just like this:

    // Enter main loop.
    for (;;)
    {
    MPU6050_GetGyroData(MPU6050_Gyr);
    memset(PrintBuffer,0x00,sizeof(PrintBuffer));
    sprintf(PrintBuffer, "x:%.2f\r\n", MPU6050_Gyr[0]);
    length = strlen(PrintBuffer);
    err_code = ble_nus_string_send(&m_nus, PrintBuffer, length);
    nrf_delay_ms(1000);
    power_manage();

    }

    Did you solve this issue? If yes please share us how you did it. Thanks for your supporting

    回覆刪除
  4. Hi there:

    Sorry for the late reply, your sensor is MPU6050 too?
    Maybe you are not enable Gyro sensor, so can't get any data.
    I need some time to setup on my side, then I can help you.

    Have a nice day,
    JustinWang

    回覆刪除
    回覆
    1. Hi Justin thanks for your Reply.

      Yes, Actually I am using the MPU6050, I will be waiting your answer then.

      Thanks a lot again.

      刪除
    2. Hello:

      Please use below link to test acc+gyro, thanks.
      https://drive.google.com/file/d/1YJd1kIGkjHj3KGkJI5RYJXYOZnoT0sfy/view?usp=sharing

      Have a nice day,
      JustinWang

      刪除
  5. Solve!

    It seems the troble comes out when I share the I2C bus lines with other sensor. I don't know why... Testing the MPU olone works. Testing MPU and magnetometer sharing the I2C bus don't work only the Gyroscope...

    回覆刪除
    回覆
    1. Hi:
      1. You can check the I2C address of every sensor, maybe MPU6050's I2C address is same with other sensor.

      2. Check your pull-high resistance is ok or not.

      刪除