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

Stream data over nRF52 Example?

Hello, I would like to stream sensor data from the Bosch IMU sensor over BLE at a maximum rate. I can collect data over I2C from the sensor but would like to know if there is an example that I can use for a template to stream the data to an iPhone. I understand that HID type transfer mode will provide the fastest transfer rate where up to four 20 byte block transfers can occur in a single transfer interval (of 11.25 mS) achieving an effective transfer rate up to about 7KBytes per second.

Is there an example in the SDK for HID or other type of example that will get me started with a template to connect with streaming data?

I understand that using UART mode for radio transfer will not achieve very good data rates. Can it be adapted to transfer multiple 20 byte records in a single interval to improve the effective data rate?

Can the heart rate example application be used as template for achieving a high effective data rate?

Regards, GaryD

  • We do have HID examples in our SDK. It send mouse/keyboard data. But I guess in your case you want to use your own proprietary service to send data. My suggestion is to add your own service (or the UART service) to an HID project. This way you can take advantage of the low connection interval for HID device (11.25ms as you mentioned).

    To stream data, you can simply queue as much as possible notification until the buffer on the nRF5 full, and then wait for the BLE_GATTS_EVT_HVN_TX_COMPLETE event to start queuing again.

  • Thank you for the suggestion. Can you also tell me which example(s) are in the SDK 11.0.0 that provide HID capability?

    I am also looking at the board configuration files nrf_drv_config.h. Does the following code in the .h file indicate that the I2C pins are attached to GPIO 26 and GPIO 27? I would like to know if I am interpreting the information correctly.

    #if (TWI0_ENABLED == 1)
    #define TWI0_USE_EASY_DMA 0
    
    #define TWI0_CONFIG_FREQUENCY    NRF_TWI_FREQ_100K
    #define TWI0_CONFIG_SCL 0x1b
    #define TWI0_CONFIG_SDA 0x1a
    #define TWI0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
    
    #define TWI0_INSTANCE_INDEX      0
    #endif
    

    Regards, GaryD

  • You can find the HID example in \examples\ble_peripheral\ble_app_hids_keyboard or \examples\ble_peripheral\ble_app_hids_mouse

    The I2C code above, please tell which file you get it from.

  • The file was: C:\NordicSDK11\examples\peripheral\twi_master_using_app_twi\config\twi_master_using_app_twi_pca10040\nrf_drv_config.h

  • I don't think TWI0_CONFIG_SCL or TWI0_CONFIG_SDA used any where else in the code. If you have a look at the twi_config() function in main.c you can find that SCL and SDA pin was configured to ARDUINO_SCL_PIN (27) and ARDUINO_SDA_PIN (26) .

    It's important what you configured in the parameter you pass to in APP_TWI_INIT(). Those configured with that call will be used.

Related