1

我有一个连接到 Adafruit BNO055 9 轴方向传感器的 Adafruit Bluefruit NRF52,收集 3 个绝对方向轴加上 3 个加速度轴(总共 6 个浮点数)并通过蓝牙发送 bleuart。我需要 bleuart 每 7.5 毫秒用新的一行值更新一次,但是当我运行它时,它每秒打印的新值行不超过 20 行。本质上,我需要尽快更新值,因为我正在测量非常高速、高保真度的运动。

在每一行的开头我还有一个三位数字,代表 IMU 上每个传感器的校准状态。每条打印线看起来像:

303 68.69   4.19    -2.19   -0.12   0.14    -0.40

我目前正在使用最新的 iOs 版本流式传输到我的 iphone,理论上它可以处理 7.5 毫秒的间隔。

我读过一个解决方案可能是缓冲值并以更大的连接间隔发送更大的块,但不确定如何执行此操作。

我的相关Arduino代码如下:

Bluefruit.setConnIntervalMS(7.5, 20);

void loop()
{
    imu::Vector<3> accel = 
    bno.getVector(Adafruit_BNO055::VECTOR_LINEARACCEL);

    /* Get a new sensor event */
    sensors_event_t event;
    bno.getEvent(&event);

    /* Display the floating point data */
    bleuart.print(event.orientation.x);
    bleuart.print("\t");
    bleuart.print(event.orientation.y);
    bleuart.print("\t");
    bleuart.print(event.orientation.z);
    bleuart.print("\t");

    /* Display the floating point data for Linear Acceleration */
    bleuart.print(accel.x());
    bleuart.print("\t");
    bleuart.print(accel.y());
    bleuart.print("\t");
    bleuart.print(accel.z());
    bleuart.print("\n");
}
4

1 回答 1

1

iOS doesn't actually support a 7.5ms connection interval. Check the connection parameters section (11.6) in the Apple developer guidelines. Just because you are specifying a CI that low doesn't mean that you'll actually get it. In this scenario the nRF52 is the slave and only requests an interval that low from the master (your phone). The master, if it so wishes, can completely disregard the request you make.

You'd be better off, as you've already eluded to, buffering your data and sending it via a custom characteristic. Figure out how many bytes you need and maybe you can pack a couple of readings into a single BLE write. If you're really struggling with throughput then you'll need a custom service with multiple characteristics. I recently worked on a project that streams 8 channels of data (~125Hz/16-bit) over BLE with three characteristics and this is bordering on the maximum throughput you can achieve.

As an aside: judging data throughput by the amount of lines printed per second is a big no no. Print functions typically have huge overheads and will drastically affect your measured throughput in a negative way.

Let me know if I can help further.

于 2019-01-03T09:58:52.527 回答