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

Sending data over BLE at 100Hz nRF5340DK

Hi,

I'm working on an app where I need to collect data from a sensor, and send it over NUS every 10ms.

I'm using nRF5340-DK (0.11.0), and I'm using nRF Connect SDK v1.5.0 for development.

My project is based on peripheral_uart sample, and I've flashed network core with HCI RPMsg sample (as shown here https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_nrf5340.html#programming-the-network-sample-from-ses)

I've configured connection interval as follows (this is code snippet from .config file from my project's zephyr folder):

CONFIG_BT_PERIPHERAL_PREF_MIN_INT=6
CONFIG_BT_PERIPHERAL_PREF_MAX_INT=6

In my app, I have following thread set up, that is used for data transmission via NUS, and I don't have while(1) function in main(), which should mean only the following thread is running:

for (;;) {
                bno055_read_accel_xyz(&sensorData.accel_xyz);
                bno055_read_gyro_xyz(&sensorData.gyro_xyz);
                bno055_read_mag_xyz(&sensorData.mag_xyz);
                if(gpio_pin_get_raw(button,23))
                {
                        bno055_set_intr_rst(1);
                }
                bt_nus_send(NULL, &sensorData, sizeof(sensorData));

                k_msleep(10);
                
	}

When I try to test this, using nRF Connect for desktop (using nRF52832 DK or nRF52840DK) I get the following error, after a couple of messages are received (I will include the log file)

h5_decode error, code: 0x802c, H5 error count: 2. raw packet: c0 db dd 0e 02 15 02 39 00 00 00 00 00 00 00 12 00 01 12 00 23 00 f6 ff d5 03 4a fb f1 ff c0

In SES, when I run Debug mode, I get the following message in the terminal

[00:00:01.002,593] [0m<inf> fs_nvs: 2 Sectors of 4096 bytes[0m
[00:00:01.002,624] [0m<inf> fs_nvs: alloc wra: 0, fd8[0m
[00:00:01.002,624] [0m<inf> fs_nvs: data wra: 0, 1c[0m
[00:00:01.023,681] [0m<inf> bt_hci_core: No ID address. App must call settings_load()[0m
[00:00:01.023,681] [0m<inf> peripheral_uart: Bluetooth initialized[0m
[00:00:13.437,103] [0m<inf> peripheral_uart: Connected E2:97:04:48:97:7E (random)[0m
[00:00:26.503,936] [0m<inf> peripheral_uart: Disconnected: E2:97:04:48:97:7E (random) (reason 8)[0m
[00:00:26.503,967] [1;33m<wrn> bt_conn: Disconnected while allocating context

When I change sleep period in my thread to 50ms, everything works fine.

I've also tried testing this on my nRF Connect app on mobile, and it won't set connection interval to 7.5ms, closest I could get it to set manually was 15ms.

Could anyone help me figure out what the problem is?
If I need to provide any more code, please suggest so.

2021-04-18T06_32_22.602Z-log.txt

Related