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

nordic thingy 52 ble frequency issue

Hi,
I'm working with a nordic thingy:52 and SDK thingylib on Android.

The issue I'm facing is that the real sampling frequency, compared to the one indicated by the SDK and the Nordic documentation (which is 200Hz) is different (**real 50-70Hz**).

In fact, inside the SDK, in the `ThingyUtils.java` file, there are two minimum and maximum offsets:
```java
public static final int MPU_FREQ_MIN_INTERVAL = 5; //hz
public static final int MPU_FREQ_MAX_INTERVAL = 200; //hz
```

When I bind the devices in my process, I set the maximum frequency:
```java
thingySdkManager.enableMotionNotifications(device, true);
thingySdkManager.setMotionProcessingFrequency(device, ThingyUtils.MPU_FREQ_MAX_INTERVAL);
```

and, inside the `ThingyListener ` listener I print a simple log with timestamps:
```java
private ThingyListener mThingyListener = new ThingyListener() {
// other events
@Override
public void onGyroscopeValueChangedEvent(BluetoothDevice bluetoothDevice, float x, float y, float z) {
String ts = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss.SSS", Locale.getDefault()).format(new Date());
Log.d("onGyroscopeValueChangedEvent", "ts:" + ts);
}
};
```

From the logcat, if I extract a log sequence of one second, I notice that I had 61 calls to the event, so I seem to see that the sampling rate is about 16ms (50-70Hz) not 5ms (200Hz) as expected.

Is there some kind of problem where I interface with Nordic, or is the maximum sampling frequency indicated, 200hz, not really the real one? How can I get as close as possible to 200Hz?

I also tried to set the minum values to the connection parameters and the advertising parameters.

The phone I'm using is an Oneplus6, with android 10, but I tried also two other phones of different model, and I get the same result.

Thanks.

---

logcat:
```log

2020-09-23 19:21:40.008 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.007
2020-09-23 19:21:40.011 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.011
2020-09-23 19:21:40.039 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.038
2020-09-23 19:21:40.043 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.043
2020-09-23 19:21:40.070 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.069
2020-09-23 19:21:40.071 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.070
2020-09-23 19:21:40.098 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.097
2020-09-23 19:21:40.099 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.099
2020-09-23 19:21:40.130 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.129
2020-09-23 19:21:40.132 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.131
2020-09-23 19:21:40.162 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.161
2020-09-23 19:21:40.191 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.190
2020-09-23 19:21:40.194 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.193
2020-09-23 19:21:40.217 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.217
2020-09-23 19:21:40.220 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.220
2020-09-23 19:21:40.251 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.251
2020-09-23 19:21:40.253 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.253
2020-09-23 19:21:40.279 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.279
2020-09-23 19:21:40.282 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.282
2020-09-23 19:21:40.310 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.309
2020-09-23 19:21:40.312 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.312
2020-09-23 19:21:40.340 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.339
2020-09-23 19:21:40.372 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.372
2020-09-23 19:21:40.375 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.374
2020-09-23 19:21:40.400 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.400
2020-09-23 19:21:40.426 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.425
2020-09-23 19:21:40.433 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.432
2020-09-23 19:21:40.456 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.456
2020-09-23 19:21:40.459 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.459
2020-09-23 19:21:40.485 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.485
2020-09-23 19:21:40.492 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.492
2020-09-23 19:21:40.494 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.494
2020-09-23 19:21:40.518 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.517
2020-09-23 19:21:40.520 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.519
2020-09-23 19:21:40.548 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.548
2020-09-23 19:21:40.551 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.550
2020-09-23 19:21:40.580 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.580
2020-09-23 19:21:40.582 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.582
2020-09-23 19:21:40.610 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.609
2020-09-23 19:21:40.612 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.611
2020-09-23 19:21:40.644 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.644
2020-09-23 19:21:40.666 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.666
2020-09-23 19:21:40.672 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.671
2020-09-23 19:21:40.696 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.696
2020-09-23 19:21:40.701 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.701
2020-09-23 19:21:40.725 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.725
2020-09-23 19:21:40.731 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.731
2020-09-23 19:21:40.756 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.755
2020-09-23 19:21:40.760 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.760
2020-09-23 19:21:40.787 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.787
2020-09-23 19:21:40.792 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.791
2020-09-23 19:21:40.820 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.820
2020-09-23 19:21:40.846 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.846
2020-09-23 19:21:40.848 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.848
2020-09-23 19:21:40.877 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.877
2020-09-23 19:21:40.880 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.880
2020-09-23 19:21:40.906 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.905
2020-09-23 19:21:40.913 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.912
2020-09-23 19:21:40.940 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.939
2020-09-23 19:21:40.942 22808-22808/it.chiarani.nordic_data_collector D/onGyroscopeValueChangedEvent: ts:23-09-2020 19:21:40.942
```

Parents
  • Hi.

    Sorry about the delay here.

    I will perform some tests on this. We might be able to improve this by tweaking the connection intervals.

    Br,
    Joakim

  • Hi Joakim,

    I tried to connect manually to nordics without using the ThingySDK.

    Initially, the connection starts with the 200Hz frequency for the first second, and the frequency drops dramatically

    Whether I'm connected with one device or two the problem persists. In this example that I am attaching, I have set the motion frequency to 200hz on both devices. The print is in format: timestamp;macaddres;acellerometerx;acellerometery;acellerometerz.

    I only activated the characteristic notification for rawdata (ef680406-9b35-4933-9b10-52ffa9740042) because initially I thought it might be a bandwidth problem. But in reality whether I connect with a single nordic or more, with your library or with the android sdk ble I encounter the same problem of low sample rates.

    I tested the same app on several phones. Where could the problem be? Can you tell me how to keep a sample rate as stable as possible near 200hz?

    Also, as you can see by plotting the graphs in the attached csv, the received data is not synchronized but has a delay between them. Is this a problem with the bluetooth chip on android phones?

    I await your feedback,

    Thanks,

    Fabio7181.datacollection_1610661140445.csv

Reply
  • Hi Joakim,

    I tried to connect manually to nordics without using the ThingySDK.

    Initially, the connection starts with the 200Hz frequency for the first second, and the frequency drops dramatically

    Whether I'm connected with one device or two the problem persists. In this example that I am attaching, I have set the motion frequency to 200hz on both devices. The print is in format: timestamp;macaddres;acellerometerx;acellerometery;acellerometerz.

    I only activated the characteristic notification for rawdata (ef680406-9b35-4933-9b10-52ffa9740042) because initially I thought it might be a bandwidth problem. But in reality whether I connect with a single nordic or more, with your library or with the android sdk ble I encounter the same problem of low sample rates.

    I tested the same app on several phones. Where could the problem be? Can you tell me how to keep a sample rate as stable as possible near 200hz?

    Also, as you can see by plotting the graphs in the attached csv, the received data is not synchronized but has a delay between them. Is this a problem with the bluetooth chip on android phones?

    I await your feedback,

    Thanks,

    Fabio7181.datacollection_1610661140445.csv

Children
No Data
Related