<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>can&amp;#39;t send data via ble nus service at high speed and leads to disconnection</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/102531/can-t-send-data-via-ble-nus-service-at-high-speed-and-leads-to-disconnection</link><description>Hi I use nrf52840 dongle as central and nrf52840dk as peripheral 
 my development aim is to get a analog signal( more specific, eeg signal ) to nrf52840dk, 
 convert it to digital value by saadc of dk, send this data to nrf52840 dongle which act as central</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 06 Aug 2023 12:13:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/102531/can-t-send-data-via-ble-nus-service-at-high-speed-and-leads-to-disconnection" /><item><title>RE: can't send data via ble nus service at high speed and leads to disconnection</title><link>https://devzone.nordicsemi.com/thread/440013?ContentTypeID=1</link><pubDate>Sun, 06 Aug 2023 12:13:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04fc5e87-b0fb-492f-a6ae-f11f53128833</guid><dc:creator>LeeJW</dc:creator><description>&lt;p&gt;thanks for your reply!&lt;/p&gt;
&lt;p&gt;i will try that to my project.&lt;/p&gt;
&lt;p&gt;have a nice day!&lt;/p&gt;
&lt;p&gt;best regards&lt;/p&gt;
&lt;p&gt;LeeJW&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: can't send data via ble nus service at high speed and leads to disconnection</title><link>https://devzone.nordicsemi.com/thread/439996?ContentTypeID=1</link><pubDate>Sat, 05 Aug 2023 08:38:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d305a1d-2b57-492a-9eca-8cbc7c831e9f</guid><dc:creator>haakonsh</dc:creator><description>[quote user="LeeJW"]&lt;p&gt;&lt;span&gt;BTW 20kHZ sample rate was able in my project.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;i was just unable to send adc value via ble more rapidly&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;so the problem was about throughput am i right?&lt;/p&gt;[/quote]
&lt;p&gt;Yes, definitely. Also, if you want to use the Nordic Uart Service as a transport layer I suggest you don&amp;#39;t encode your data into a string representational form, but leave it as&amp;nbsp;int16_t and treat the received string as a binary blob with string termination. NUS is great for prototyping, but I suggest that you create a custom service instead of using NUS. That way you can have a dedicated characteristic for sending raw data, in addition to&amp;nbsp;characteristics for control and meta-data (configurations, start/stop sampling, etc).&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Also, one neat feature of the TIMER peripheral is that you can capture timestamps of your ADC samples. The timestamps are useful if the&amp;nbsp;datastream is interrupted/corrupted as you&amp;#39;ll have reliable points of reference for parsing the received data.&amp;nbsp;You&amp;#39;ll be able to buffer&amp;nbsp;a few seconds of data in local RAM if the link is interrupted for any reason, or if the link throughput momentarily falls below your datastream throughput requirements.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can start a TIMER at the same point in time as you start a sampling session and periodically capture its value using the same signal that triggers SAADC sampling.&amp;nbsp;A TIMER&amp;#39;s&amp;nbsp;CAPTURE task will record its own counter value and place it into one of its 5 CAPTURE/COMPARE registers that can be read by the CPU at a later point. You won&amp;#39;t be able to reliably read timestamps with the CPU at 20kHz or even 500Hz, but you can capture timestamps for every &amp;#39;x&amp;#39; number of samples.&amp;nbsp;F.ex.&amp;nbsp;once per block of samples that will fit inside a BLE payload.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: can't send data via ble nus service at high speed and leads to disconnection</title><link>https://devzone.nordicsemi.com/thread/439803?ContentTypeID=1</link><pubDate>Fri, 04 Aug 2023 04:02:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6b93851-5eed-4ecf-b59a-ad9bb68c2547</guid><dc:creator>LeeJW</dc:creator><description>&lt;p&gt;Hi haakonsh&lt;/p&gt;
&lt;p&gt;#define MIN_CONN_INTERVAL MSEC_TO_UNITS(30, UNIT_1_25_MS)&lt;br /&gt;#define MAX_CONN_INTERVAL MSEC_TO_UNITS(30, UNIT_1_25_MS)&lt;/p&gt;
&lt;p&gt;NRF_SDH_BLE_GAP_DATA_LENGTH 251&lt;/p&gt;
&lt;p&gt;NRF_SDH_BLE_GAP_EVENT_LENGTH 6 to 320&amp;nbsp;&lt;/p&gt;
&lt;p&gt;NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247&lt;/p&gt;
&lt;p&gt;SAADC_SAMPLES_IN_BUFFER 4 to 8&lt;/p&gt;
&lt;p&gt;also used&lt;/p&gt;
&lt;p&gt;void conn_evt_len_ext_set(void)&lt;br /&gt;{&lt;br /&gt; ret_code_t err_code;&lt;br /&gt; ble_opt_t opt;&lt;/p&gt;
&lt;p&gt;memset(&amp;amp;opt, 0x00, sizeof(opt));&lt;br /&gt; opt.common_opt.conn_evt_ext.enable = 1;&lt;/p&gt;
&lt;p&gt;err_code = sd_ble_opt_set(BLE_COMMON_OPT_CONN_EVT_EXT, &amp;amp;opt);&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;yeah increasing&amp;nbsp;&lt;span&gt;NRF_SDH_BLE_GAP_EVENT_LENGTH&amp;nbsp; and&amp;nbsp;SAADC_SAMPLES_IN_BUFFER&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;solved above problem&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;BTW 20kHZ sample rate was able in my project.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;i was just unable to send adc value via ble more rapidly&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;so the problem was about throughput am i right?&lt;/p&gt;
&lt;p&gt;there are so much more things i must learn about this stuff !!&lt;/p&gt;
&lt;p&gt;thanks for your help haakonsh&lt;/p&gt;
&lt;p&gt;best regards&lt;/p&gt;
&lt;p&gt;LeeJW&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: can't send data via ble nus service at high speed and leads to disconnection</title><link>https://devzone.nordicsemi.com/thread/439792?ContentTypeID=1</link><pubDate>Thu, 03 Aug 2023 21:38:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6c95561b-1c7b-44a5-a1da-915c5940751a</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;What is you connection interval, Event, length, MTU size, and&amp;nbsp;LL packet&amp;nbsp;size?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I think you&amp;#39;re running a connection interval of 20ms, event length of 7.5ms, MTU of 27, and LL of 31, as that is the default params.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;If that is in fact the case I suggest you&amp;nbsp;increase the MTU and LL packet sizes, as well as the SAADC buffer sizes.&lt;/p&gt;
&lt;p&gt;Do you have any real-time latency requirements?&lt;/p&gt;
&lt;p&gt;I suggest you don&amp;#39;t convert the samples from int16_t to float before transmission. A float requires at least 32bit so you need 2x the throuput to transmit the same amount of data. Also a 32bit float might loose a bit of precision, and it&amp;#39;s best to use int16_t until you can convert to float on a larger machine. Also the float conversions will require a significant amount of power on the Cortext-M4F CPU.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I also suggets you enable at least 8x oversampling and increase the sample rate significantly. The SAADC will not use&amp;nbsp;much more power while sampling extra samples for oversampling.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There&amp;#39;s no reason why you should not be able to get up to 20kHz sample rate (including 8x oversampling)&amp;nbsp;with an nRF52840 in both ends of the BLE link in an average RF environment.&amp;nbsp;Though the average current consumption will increase to ~10-12mA at that sample rate and throughput.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;See also&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/the-ultimate-guide-to-maximizing-your-ble-and-blue"&gt;The ultimate guide to maximizing your BLE and Bluetooth 5 data throughput&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>