<?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>Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/108551/which-is-the-best-way-of-sending-the-data-read-from-a-sensor</link><description>Hi, 
 I need to read the data from an acceleration sensor. I tried with a custom program of mine to simulate some data, but it is delaying too much. 
 I tried reducing the notification interval, but sometimes it just jumps numbers so to say, it should</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 30 Aug 2024 07:22:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/108551/which-is-the-best-way-of-sending-the-data-read-from-a-sensor" /><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/500520?ContentTypeID=1</link><pubDate>Fri, 30 Aug 2024 07:22:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c5c8857-e3f4-44d4-ad09-a2ccf54957ed</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Adrian,&lt;/p&gt;
&lt;p&gt;I am not familiar with the adxl355, but how fast can you read data from it? There is probably a maximum sampling rate etc. That should be specified in the data sheet. I would suggest that you first look into what you can actually achieve theoretically. And then start testing without bluetooth this time, just logging (not very often) how much data you have recieved, and ignore the data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/500461?ContentTypeID=1</link><pubDate>Thu, 29 Aug 2024 15:27:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5934d250-b07d-4e84-8419-2186b33acc08</guid><dc:creator>Adrian1504</dc:creator><description>&lt;p&gt;Hi Einar,&lt;/p&gt;
&lt;p&gt;Thank you for your answer.&lt;/p&gt;
&lt;p&gt;I tried what you suggested, and yes, now I receive more. So I am receiving&amp;nbsp;&lt;span&gt;25920 int 32 which I think makes it .8 Mbps. Since I think now the problem is the reading of the accelerometer data, I changed my program to read the FIFO, instead of reading register each time it was accessed. I am now getting .5 Mbps, which is good, but I&amp;#39;d like to increase it to .8 that was amazing. Would you know of any way I could make this better?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Maybe making 2 buffers and sending one and then the other? Increasing the frequency of SPI?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I will try them, but if you have any advice, I would be really interested in reading it.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Adrian Lopez.&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: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/499803?ContentTypeID=1</link><pubDate>Mon, 26 Aug 2024 14:28:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:721af5c2-d442-42bc-8f1a-324cd463dd05</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Adrian,&lt;/p&gt;
[quote user="Adrian1504"]Here, what do you mean?[/quote]
&lt;p&gt;I was refering to the more data field in the packets in the sniffer trace. When that is not set, that indicate that the nRF does not have more data to send, and the connection event will be closed. So it seems you are not providing data to the BLE stack fast enoug (for higher throughput).&lt;/p&gt;
&lt;p&gt;Looking at your code I see you send data in your&amp;nbsp;ble_notify_thread() and this waits for a semaphore&amp;nbsp;buffer_sem given in&amp;nbsp;simulate_data. What throuhgput do you get if you skip this part and just send the same dummy data over and over (no acellerometer data and no semaphore)? The way the code looks now I cannot see if the limiting factor here is getting the accelerometer data or sending the data over BLE.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/499719?ContentTypeID=1</link><pubDate>Mon, 26 Aug 2024 11:02:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0b8a40b-3383-45a2-9ba3-33e024eb68bc</guid><dc:creator>Adrian1504</dc:creator><description>&lt;p&gt;Hi Einar,&lt;/p&gt;
&lt;p&gt;Thank you so much for your reply.&lt;/p&gt;
&lt;p&gt;Here, what do you mean?&lt;/p&gt;
[quote userid="7377" url="~/f/nordic-q-a/108551/which-is-the-best-way-of-sending-the-data-read-from-a-sensor/499324"]I also see that ther more data field is often not set, which is also a potential problem[/quote]
&lt;p&gt;I adjusted the buffer sizes and also the event length.&lt;/p&gt;
&lt;p&gt;I tried changing the connection interval to 30ms, and it still does not work. Maybe the way I am setting my BLE connection is not right?&lt;/p&gt;
&lt;p&gt;For the prj:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_BUF_ACL_RX_SIZE=502
CONFIG_BT_BUF_ACL_TX_SIZE=502
CONFIG_BT_L2CAP_TX_MTU=498

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_BT_RX_STACK_SIZE=2048&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And in the main, I see that in the sample you attaches, they are using bt_le_conn_param, I am using this, Should I change this?:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static struct bt_le_adv_param *adv_param = BT_LE_ADV_PARAM(
	(BT_LE_ADV_OPT_CONNECTABLE |
	 BT_LE_ADV_OPT_USE_IDENTITY), /* Connectable advertising and use identity address */
	BT_GAP_ADV_FAST_INT_MIN_2, /* 0x30 units, 48 units, 30ms */
	BT_GAP_ADV_FAST_INT_MAX_2, /* 0x60 units, 96 units, 60ms */
	NULL);
	
	&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I attach my code in case it is more useful.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/BLESPIZip.zip"&gt;devzone.nordicsemi.com/.../BLESPIZip.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thank you so much&lt;/p&gt;
&lt;p&gt;Adrian Lopez&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/499324?ContentTypeID=1</link><pubDate>Thu, 22 Aug 2024 08:31:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ff6d706-528a-4aaa-aa24-38c9b028c315</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Adrian,&lt;/p&gt;
&lt;p&gt;From what I understand you want to maximize throughput. Generally, to maximize thourhput with BLE from a GATT server to a client this is important:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;2 Mbps PHY&lt;/li&gt;
&lt;li&gt;Use data length extension to send as long link laye rpackets as possible&lt;/li&gt;
&lt;li&gt;Use along event length (equal to the connection interval).&lt;/li&gt;
&lt;li&gt;If using an event length equal to the connection inteval and the link has little packet loss, increasing the connection interval can then increase the thorughput due to overhead when changing connection interval.&lt;/li&gt;
&lt;li&gt;Make sure various buffers are large enough and always provide data to the stack so that it has data to send.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Looking at the sniffer trace, 1 and 2 from the above list is good. The connection inteval is 15 ms which is perhaps a bit low. But at the same time, I also see that ther more data field is often not set, which is also a potential problem.&lt;/p&gt;
&lt;p&gt;So I suggest that you start with adjusting buffer sizes and event length as shown in the &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/eef645c4a31201df353fdff5447262d7675fa1c1/samples/bluetooth/throughput/prj.conf#L33"&gt;prj.conf from the throughput sample&lt;/a&gt;&amp;nbsp;and perhaps also adjust the connection interval. Do you get better throhgput then? If not, make sure you attempt to send data fast enough.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/499233?ContentTypeID=1</link><pubDate>Wed, 21 Aug 2024 14:06:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:efb5e2cf-ab83-4e46-a3f2-64234fcc2433</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Adrian,&lt;/p&gt;
&lt;p&gt;I will look into this and get back to you tomorrow.&lt;/p&gt;
&lt;p&gt;Br,&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/498855?ContentTypeID=1</link><pubDate>Mon, 19 Aug 2024 13:07:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e105cb4-7b33-4fc6-9355-d90cdd63ea27</guid><dc:creator>Adrian1504</dc:creator><description>&lt;p&gt;Now I figured out what to send, an apology.&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/sniffer1.zip"&gt;devzone.nordicsemi.com/.../sniffer1.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Adrian Lopez&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/498854?ContentTypeID=1</link><pubDate>Mon, 19 Aug 2024 13:03:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce81557e-8066-4abf-bf6c-11a101a1e92e</guid><dc:creator>Adrian1504</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;I am really sorry for the delay. I had to focus also on the reading of the sensor, the app for displaying the data and got stuck for a really long time. Now I had the chance to return and have a look at this issue again.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I see that now I am obtaining again .02 MB/s. I tried making 2 different threads, one that reads the values from the sensor ands stacks them in an array, and other one that sends the data. It is also not working.&lt;/p&gt;
&lt;p&gt;Having a look at the sniffer tool that you mentioned, I receive some things which I don&amp;#39;t know if it is helpful to know, or how to interpret them. I see for example, that the updates in parameters to 2M and data length are being made.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But when I subscribe to the notifications, I see that the master is also taking quite some time to send something and it is empty, is this normal?&lt;/p&gt;
&lt;p&gt;Also, I don&amp;#39;t see any warnings or errors.&lt;/p&gt;
&lt;p&gt;I attach some screenshots of the wireshark. If there is a better way to share the logs, please let me know.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This first image is before any connection event&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/2024_2D00_08_2D00_19_5F00_14h54_5F00_31.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This second image is when the connection happened&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/2024_2D00_08_2D00_19_5F00_14h54_5F00_53.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This third image is before I subscribe&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/2024_2D00_08_2D00_19_5F00_14h55_5F00_43.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This fourth image is during the subscription&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/2024_2D00_08_2D00_19_5F00_14h56_5F00_06.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If there is any other information that might be useful, please let me know.&lt;/p&gt;
&lt;p&gt;Best regards,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Adrian Lopez&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/476520?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2024 10:45:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7599a2a3-cd62-4db2-a2ec-5db3e5ce4c8d</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again, Adrian&lt;br /&gt;&lt;br /&gt;Thank you for your patience with this - I have been out of office due to the public easter holiday last week, but now I am back.&lt;br /&gt;&lt;br /&gt;Please make sure that you have followed all the steps in &lt;a href="https://infocenter.nordicsemi.com/topic/ug_sniffer_ble/UG/sniffer_ble/installing_sniffer.html"&gt;the Installing the sniffer&lt;/a&gt;&amp;nbsp;guide - especially &lt;a href="https://infocenter.nordicsemi.com/topic/ug_sniffer_ble/UG/sniffer_ble/installing_sniffer_plugin.html"&gt;the part on Installing the sniffer capture tool&lt;/a&gt;. Please do this, and let me know if the issue persists!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/475739?ContentTypeID=1</link><pubDate>Mon, 25 Mar 2024 16:57:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06d099e6-6097-4691-9a31-35186cc4f104</guid><dc:creator>Adrian1504</dc:creator><description>&lt;p&gt;Hello Karl,&lt;br /&gt;&lt;br /&gt;Sorry for the late response. I have been trying to install it, but I ran into this problem:&lt;br /&gt;&amp;quot;The term &amp;#39;nrf_sniffer_ble.bat&amp;#39; is not recognized as&lt;br /&gt;the name of a cmdlet, function, script file, or operable program.&amp;quot;&lt;br /&gt;&lt;br /&gt;I have already checked and I have python installed. Do you know what is the problem?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/473870?ContentTypeID=1</link><pubDate>Thu, 14 Mar 2024 13:09:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6a3c1bd-04a5-4b2b-b19b-9b892f9c57aa</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello&amp;nbsp;&lt;span&gt;Adrian.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Thank you for clarifying - I am glad to hear that you are having progress on the throughput!&lt;br /&gt;&lt;br /&gt;The next step in figuring out where the bottleneck in the communication is would be to gather a sniffer trace, so that we can verify that the application always have data ready to send, and whether there is anything hampering the data from being sent.&lt;br /&gt;It could for instance here be that the application is not supplying the data fast enough due to other tasks taking time away from the data generation.&lt;br /&gt;Have you had a look at my suggestion for sniffer in my previous comment?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/473846?ContentTypeID=1</link><pubDate>Thu, 14 Mar 2024 12:01:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49f51971-d326-408c-884c-868812b21a04</guid><dc:creator>Adrian1504</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;A small update, I changed some things in my code and was able to achieve now .9 Mbps, so I guess the way I am queueing the data and sending it is still not correct. I would be happy to be able to get it up to 1.2. Of course, I will leave some of my functions here:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void simulate_dataX(void)
{
	sensor_valueX++;
	if (sensor_valueX == 9) {
		sensor_valueX = 0;
	}
}

static void simulate_data(void){
	simulate_dataX();
	simulate_dataY();
	simulate_dataZ();
}

int my_lbs_send_sensor_notify(void)
{
	if (!notify_sensor_enabled) {
		return -EACCES;
	}

	return bt_gatt_notify(NULL, &amp;amp;accelerometer_svc.attrs[1], 
			      &amp;amp;buffer,
			      sizeof(buffer));
}

static void pack_data(uint8_t x, uint8_t y, uint8_t z){
	buffer[buffer_index].x = x;
    buffer[buffer_index].y = y;
    buffer[buffer_index].z = z;
    buffer_index++;

	if (buffer_index == BUFFER_SIZE){
		int err = my_lbs_send_sensor_notify();
		if (err) {
			LOG_ERR(&amp;quot;Notification failed:  %d&amp;quot;, err);
		}
		buffer_index = 0;
	}

}

void send_data_thread(void)
{
	while(1){
		if(notify_sensor_enabled){ //Without this if I was only achieveing .02 Mbps
			simulate_data();
			pack_data(sensor_valueX,sensor_valueY,sensor_valueZ);
		}

	}
		
}

K_THREAD_DEFINE(send_data_thread_id, STACKSIZE, send_data_thread, NULL, NULL,
		NULL, PRIORITY, 0, 0);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here is the prj:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;# nothing here
CONFIG_LOG=y

CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME=&amp;quot;BLE Device&amp;quot;
CONFIG_BT_DEVICE_APPEARANCE=0
#CONFIG_BT_BAS=y

CONFIG_BT_GATT_CLIENT=y

CONFIG_DEBUG_OPTIMIZATIONS=y
CONFIG_DEBUG_THREAD_INFO=y
CONFIG_FPU=y

CONFIG_BT_PERIPHERAL_PREF_MIN_INT=30
CONFIG_BT_PERIPHERAL_PREF_MAX_INT=40
CONFIG_BT_PERIPHERAL_PREF_LATENCY=0
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=1000
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=y

CONFIG_BT_USER_PHY_UPDATE=y

CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_L2CAP_TX_MTU=247

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_BT_RX_STACK_SIZE=2048&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If you need any other part of the code, let me know. Also, I am not familiar to this tool, but I will have a look at it! Thank you!&lt;/p&gt;
&lt;p&gt;Best regards,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Adrian Lopez Vudoyra&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/473627?ContentTypeID=1</link><pubDate>Wed, 13 Mar 2024 12:01:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4519b0e9-600d-4da3-8561-7392785d8773</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello&amp;nbsp;&lt;span&gt;Adrian Lopez,&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
[quote user="Adrian1504"]&lt;p&gt;When I connect my device it prints this notifications in the nrf Connect app:&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;PHY updated (TX: LE 2M, RX: LE 2M)&lt;/li&gt;
&lt;li&gt;Connection parameters updated (interval: 11.25ms, latency: 0, timeout: 10000ms)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And in the terminal I am getting this messages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;MTU exchange successful, new MTU: 244 bytes&lt;/li&gt;
&lt;li&gt;Data length updated. Length 251/27 bytes, time 2120/2120 us&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So I think that the central is accepting the changes successfully and is setting the same parameters as in the link you provided me.&amp;nbsp;&lt;/p&gt;[/quote]
&lt;p&gt;Thank you for clarifying - it is good to have it confirmed that you are using a 11.25 ms connection interval.&lt;br /&gt;&lt;br /&gt;It seems that you have successfully changed your connection parameters, and so that should not be what is causing the issue with the throughput either. Could you detail how you are generating and queueing the data for sending again? It would be great to see the relevant code as well, if possible.&lt;br /&gt;&lt;br /&gt;If the throughput is still an issue we will need to capture a sniffer trace of the communication between the devices. Are you familiar with &lt;a href="https://www.nordicsemi.com/Products/Development-tools/nrf-sniffer-for-bluetooth-le"&gt;the nRF Sniffer tool&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/472724?ContentTypeID=1</link><pubDate>Thu, 07 Mar 2024 13:27:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae255a90-6bcf-439f-ada6-b3fde7af8164</guid><dc:creator>Adrian1504</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/108551/which-is-the-best-way-of-sending-the-data-read-from-a-sensor/472107"]What does your central&amp;#39;s device log say when you connect to your peripheral device?&lt;br /&gt;Does it log the used connection parameters that it uses?[/quote]
&lt;p&gt;When I connect my device it prints this notifications in the nrf Connect app:&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;PHY updated (TX: LE 2M, RX: LE 2M)&lt;/li&gt;
&lt;li&gt;Connection parameters updated (interval: 11.25ms, latency: 0, timeout: 10000ms)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And in the terminal I am getting this messages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;MTU exchange successful, new MTU: 244 bytes&lt;/li&gt;
&lt;li&gt;Data length updated. Length 251/27 bytes, time 2120/2120 us&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So I think that the central is accepting the changes successfully and is setting the same parameters as in the link you provided me.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I will leave here a stackoverflow link that I created in case you can have a look at some of the code I have.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="https://stackoverflow.com/questions/78102521/nrf52840-not-achieving-sending-2-mbps"&gt;stackoverflow.com/.../nrf52840-not-achieving-sending-2-mbps&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thank you so much for your time.&lt;/p&gt;
&lt;p&gt;Adrian Lopez.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/472107?ContentTypeID=1</link><pubDate>Mon, 04 Mar 2024 17:21:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d33100e-30a2-4c29-939c-6b3089e3bd46</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Adrian Lopez,&lt;/p&gt;
[quote user="Adrian1504"]No, here I meant that there was a sleeping function after the notification for delaying the notification process. But now I deleted it. I also created a buffer of size 80 and each position has a 3 variable struct. Now I am able to get 11 buffers per second (That is 2640 bytes per second which is nothing if we convert it to Mbps). To be able to achieve this, because I was getting only 2 buffers per second, in the prj.conf I changed the following parameters:&amp;nbsp;[/quote]
&lt;p&gt;This way it does not actually matter when you queue the notification, since the check in essence is &amp;#39;is there a notification ready for sending&amp;#39; when a connection event is upcoming.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="Adrian1504"]&lt;div&gt;&lt;span&gt;CONFIG_BT_PERIPHERAL_PREF_MIN_INT&lt;/span&gt;&lt;span&gt;=10&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_BT_PERIPHERAL_PREF_MAX_INT&lt;/span&gt;&lt;span&gt;=10&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Why am i getting so little?&lt;br /&gt;Would it be useful for me to send my code?&lt;/span&gt;&lt;/div&gt;[/quote]
&lt;p&gt;Those kconfig options only sets the peripheral&amp;#39;s preferences, while it is still the central that decides which connection interval that will actually be used. What does your central&amp;#39;s device log say when you connect to your peripheral device?&lt;br /&gt;Does it log the used connection parameters that it uses?&lt;br /&gt;&lt;br /&gt;The peripheral may send a connection parameter update request, to suggest to use its preferred connection parameters, but the central may reject this update request and instead use whichever connection parameters it would like. The peripheral may then either accept this, or terminate the connection.&lt;br /&gt;&lt;br /&gt;I think the key to your throughput in this case is the connection parameters. Please change these on your central device, or make sure that the central device will accept any connection parameter update request from the peripheral, and &lt;a href="https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/ble_data_throughput/ble_data_throughput.html"&gt;then use one of the connection parameter configurations shown here to achieve higher throughput&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/472023?ContentTypeID=1</link><pubDate>Mon, 04 Mar 2024 13:02:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3cb1893d-c725-4de2-86bd-021dc2702b8e</guid><dc:creator>Adrian1504</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/108551/which-is-the-best-way-of-sending-the-data-read-from-a-sensor/471614"]By this I assume you mean the connection interval?[/quote]
&lt;p&gt;No, here I meant that there was a sleeping function after the notification for delaying the notification process. But now I deleted it. I also created a buffer of size 80 and each position has a 3 variable struct. Now I am able to get 11 buffers per second (That is 2640 bytes per second which is nothing if we convert it to Mbps). To be able to achieve this, because I was getting only 2 buffers per second, in the prj.conf I changed the following parameters:&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_BT_PERIPHERAL_PREF_MIN_INT&lt;/span&gt;&lt;span&gt;=10&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_BT_PERIPHERAL_PREF_MAX_INT&lt;/span&gt;&lt;span&gt;=10&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Why am i getting so little?&lt;br /&gt;Would it be useful for me to send my code?&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Adrian Lopez&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/471614?ContentTypeID=1</link><pubDate>Thu, 29 Feb 2024 15:58:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c527dedf-8e41-4b3d-aa15-5c08b03a6ebd</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello&amp;nbsp;&lt;span&gt;Adrian Lopez,&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
[quote user="Adrian1504"]Sorry for so many questions, but thank you for your help![/quote]
&lt;p&gt;No need to apologize, I am happy to help! :)&amp;nbsp;&lt;/p&gt;
[quote user="Adrian1504"]The value that I changed here was the Notify interval.&amp;nbsp;[/quote]
&lt;p&gt;By this I assume you mean the connection interval?&lt;br /&gt;It would be great if you could be explicit about the changes you made, so that I can know with certainty which value or parameter was changed, since it seems to me that the change was unsuccessful.&lt;/p&gt;
[quote user="Adrian1504"]In the function mentioned (ble_write thread), there is no notify_interval, this is not necessary for notifications? I also saw that the function being used is&amp;nbsp;bt_nus_send(), here I could also use the bt_gatt_notify function? Or this function(bt_nus_send) is specific for sending buffers?[/quote]
&lt;p&gt;You are correct that there is no&amp;nbsp;&lt;em&gt;notify_interval&lt;/em&gt; directly, and this is because the peripheral will send the notification in the next possible connection event - there is one connection event each time the &lt;em&gt;connection interval&lt;/em&gt; has elapsed.&lt;br /&gt;So for example, if you queue a notification for sending every 500 ms, and your connection have a&amp;nbsp;&lt;em&gt;connection interval&lt;/em&gt; of&amp;nbsp;250 ms, then your peripheral will send one empty packet in the first connection event (because it did not have any notification to send), and then send queued notification in the next connection event, then it will revert to sending an empty packet again to maintain the connection until a new notification is queued for sending.&lt;br /&gt;&lt;br /&gt;You are also correct that this particular example uses the bt_nus_send function to send the notification, because the example is made to showcase the use of the Nordic UART service in particular - but if you look into the implementation of this service you will see that it also uses the bt_gatt_notify functionality behind the scenes :)&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote user="Adrian1504"]And last, I guess that instead of the line 638, instead of using k_fifo_get, I should put the function which with I will read the information of my sensor? or it should be the function that will put the information in the buffer?[/quote]
&lt;p&gt;This depends on the requirements to your application - such as whether it would be acceptable or perhaps important to drop older sensor measurements, or whether it is important that&amp;nbsp;&lt;em&gt;all&lt;/em&gt; measurements make it across the link.&lt;br /&gt;In your case, I would recommend using a FIFO buffer in the same way that the NUS does, since this lets you gather data for sending independently of the BLE notification queueing.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/471552?ContentTypeID=1</link><pubDate>Thu, 29 Feb 2024 13:45:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a09ae303-ac94-441d-bac9-0f19aa5e01e9</guid><dc:creator>Adrian1504</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;Again, thank you for your detailed and helpful answer.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/108551/which-is-the-best-way-of-sending-the-data-read-from-a-sensor/470758"]Which value did you change here exactly?[/quote]
&lt;p&gt;The value that I changed here was the Notify interval.&amp;nbsp;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/108551/which-is-the-best-way-of-sending-the-data-read-from-a-sensor/470758"] can take a look at &lt;a href="https://github.com/nrfconnect/sdk-nrf/tree/main/samples/bluetooth/peripheral_uart"&gt;the Peripheral Nordic UART example&lt;/a&gt;[/quote]
&lt;p&gt;I went through the code that you mentioned, and it looks like it can be really helpful, I just have some doubts:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In the function mentioned (ble_write thread), there is no notify_interval, this is not necessary for notifications? I also saw that the function being used is&amp;nbsp;bt_nus_send(), here I could also use the bt_gatt_notify function? Or this function(bt_nus_send) is specific for sending buffers?&lt;/p&gt;
&lt;p&gt;And last, I guess that instead of the line 638, instead of using k_fifo_get, I should put the function which with I will read the information of my sensor? or it should be the function that will put the information in the buffer?&lt;/p&gt;
&lt;p&gt;Sorry for so many questions, but thank you for your help!&lt;/p&gt;
&lt;p&gt;Adrian Lopez&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/470758?ContentTypeID=1</link><pubDate>Mon, 26 Feb 2024 13:36:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1214dbba-6b2d-4f95-a8c8-17760060b9e7</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user="Adrian1504"]Thank you for the answer.[/quote]
&lt;p&gt;No problem at all, I am happy to help! :)&amp;nbsp;&lt;/p&gt;
[quote user="Adrian1504"]I would like to receive more often, I tried lowering the notify interval, which was set to 500. And I still get the same amount of numbers.&amp;nbsp;[/quote]
&lt;p&gt;Which value did you change here exactly?&lt;br /&gt;Please note that the peripheral device may only have a preference for the connection parameters, it does not actually set it. It is the central that decides which connection parameters that will be used.&lt;/p&gt;
[quote user="Adrian1504"]&lt;p&gt;I am not understanding how I can should send with the bt_gatt_notify(). Should it be: bt_gatt_nottify(NULL,&amp;lt;&lt;span&gt;characteristic declaration index&amp;gt;,&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;lt;array&amp;gt;,sizeof(array)); ?&lt;/p&gt;
&lt;p&gt;Or should it be one gatt_notify() per each array that I have?&lt;/p&gt;[/quote]
&lt;p&gt;If you would like to see a good example of how you can regularly output your sensor data over the BLE link you can take a look at &lt;a href="https://github.com/nrfconnect/sdk-nrf/tree/main/samples/bluetooth/peripheral_uart"&gt;the Peripheral Nordic UART example&lt;/a&gt;, which forwards everything it receives over BLE out on its UART, and visa versa. In the &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/f660b2ae50e0484c0ea26a6edef80f747488d483/samples/bluetooth/peripheral_uart/src/main.c#L631"&gt;ble_write_thread&lt;/a&gt; you can see how it checks the FIFO for new data, and then queues it for transfer over BLE is there is any.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/470698?ContentTypeID=1</link><pubDate>Mon, 26 Feb 2024 11:51:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05fec3e1-5ee3-4fcd-a579-157b6ad124e3</guid><dc:creator>Adrian1504</dc:creator><description>&lt;p&gt;Dear Karl,&lt;/p&gt;
&lt;p&gt;Thank you for the answer.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I saw that in fact I was getting all the data, but I am getting 3 int_8 per second. I would like to receive more often, I tried lowering the notify interval, which was set to 500. And I still get the same amount of numbers.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I need to read my sensor which throws 3 values per reading (x,y,z), the frequency of reading is still not defined, but I am thinking on doing it via I2C.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Should I do an array of 3 arrays for each of the values?&lt;/p&gt;
&lt;p&gt;I am not understanding how I can should send with the bt_gatt_notify(). Should it be: bt_gatt_nottify(NULL,&amp;lt;&lt;span&gt;characteristic declaration index&amp;gt;,&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;lt;array&amp;gt;,sizeof(array)); ?&lt;/p&gt;
&lt;p&gt;Or should it be one gatt_notify() per each array that I have?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/470685?ContentTypeID=1</link><pubDate>Mon, 26 Feb 2024 11:15:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f15cefa6-984b-48aa-b7a0-4064cf8b69f7</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user="Adrian1504"]I am still not reading any sensor, for now it is just dummy values, and supposedly they should be increasing in 1 unit each time the loop comes. But sometimes it is being increased in more than one unit.&amp;nbsp;&lt;br /&gt;I think maybe sending each time the sensor is being &amp;quot;read&amp;quot; is not the best. Is it possible to send maybe an array? Or which is the best way to send the most amount of the &amp;quot;read&amp;quot; sensor?[/quote]
&lt;p&gt;Thank you for clarifying. I assume then that this means that you are sending the dummy data over your BLE link, and the main question is why some of the numbers in the sequence is missing.&lt;br /&gt;In essence, BLE is a lossless protocol - no data is ever lost in the link - since every packet is either acknowledged by the peer. If a packet it not acknowledged by the peer in its next packet it will be retransmitted until acknowledged, or until the link is terminated.&lt;br /&gt;Therefore, the data must be lost before it is queued for sending.&lt;br /&gt;Could you be that your call to queue the data for sending failed, for instance due to a full buffer?&lt;br /&gt;This could lead to some missing samples in the sequence.&lt;br /&gt;If you share your relevant &amp;#39;loop&amp;#39; code then I can take a look.&lt;/p&gt;
[quote user="Adrian1504"]I think maybe sending each time the sensor is being &amp;quot;read&amp;quot; is not the best. Is it possible to send maybe an array? Or which is the best way to send the most amount of the &amp;quot;read&amp;quot; sensor?[/quote]
&lt;p&gt;You can send an array in a single packet, yes - it just depends on the size of the data and frequency.&lt;br /&gt;How often are you reading the sensor data, how large as the samples, and what latency requirements do you have for your application?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/470554?ContentTypeID=1</link><pubDate>Sat, 24 Feb 2024 13:01:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d48d62f-d739-4386-95dd-fd07bd163ad1</guid><dc:creator>Adrian1504</dc:creator><description>&lt;p&gt;Hi Karl,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am still not reading any sensor, for now it is just dummy values, and supposedly they should be increasing in 1 unit each time the loop comes. But sometimes it is being increased in more than one unit.&amp;nbsp;&lt;br /&gt;I think maybe sending each time the sensor is being &amp;quot;read&amp;quot; is not the best. Is it possible to send maybe an array? Or which is the best way to send the most amount of the &amp;quot;read&amp;quot; sensor?&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Which is the best way of sending the data read from a sensor?</title><link>https://devzone.nordicsemi.com/thread/470419?ContentTypeID=1</link><pubDate>Fri, 23 Feb 2024 10:16:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a330e0f9-a66f-4b94-a4ea-eb9ae4c51ffd</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user=""]I need to read the data from an acceleration sensor. I tried with a custom program of mine to simulate some data, but it is delaying too much.[/quote]
&lt;p&gt;Could you elaborate on what you are doing here, and which delay you are referring to here?&lt;br /&gt;Are you reading out the sensor data over I2C for instance, and then sending it over BLE, where the mentioned delay applies to the BLE communication?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you are just starting out with the nRF Connect SDK then I highly recommend taking a look through &lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/"&gt;the nRF Connect SDK Fundemental course to quickly familiarize with the SDK&lt;/a&gt;! :)&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>