<?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>Data transfer from sensor connected with I2C over Bluetooth NUS.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/100513/data-transfer-from-sensor-connected-with-i2c-over-bluetooth-nus</link><description>Hi everyone, 
 
 I am working with the nRF SDK v2.0.4 for VsCode and with the nRF52840 DK. 
 I want to develop an application that transfer in real time the data collected by a sensor. I managed to implement the I2C logic and print the value collected</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 07 Nov 2024 02:29:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/100513/data-transfer-from-sensor-connected-with-i2c-over-bluetooth-nus" /><item><title>RE: Data transfer from sensor connected with I2C over Bluetooth NUS.</title><link>https://devzone.nordicsemi.com/thread/509341?ContentTypeID=1</link><pubDate>Thu, 07 Nov 2024 02:29:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:904fe6bf-cd27-4735-9e8f-b0df069d5dbf</guid><dc:creator>connorshannon</dc:creator><description>&lt;p&gt;Hello, I know it&amp;#39;s been a while since this thread has been active, but I&amp;#39;m having a similar issue. Esbriven, is there any chance you could share your completed code? I&amp;#39;m using a different board and sensor, but the general idea is the same and I can make the necessary changes to the code. Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data transfer from sensor connected with I2C over Bluetooth NUS.</title><link>https://devzone.nordicsemi.com/thread/430010?ContentTypeID=1</link><pubDate>Thu, 08 Jun 2023 13:26:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f96b9c5-e168-405c-b8d8-c7275550da9d</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Esbriven,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t see much point converting the data to human readable format then send over BLE.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Instead you send hex value over BLE and then convert to human readable format on the peer device, for example the app on the phone or the dongle.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;On the peer you may want to look for &amp;quot;convert float to string&amp;quot;&amp;nbsp; in the program language that you use on the peer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;For example in C:&amp;nbsp;&lt;a href="https://www.geeksforgeeks.org/gcvt-convert-float-value-string-c/"&gt;https://www.geeksforgeeks.org/gcvt-convert-float-value-string-c/&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data transfer from sensor connected with I2C over Bluetooth NUS.</title><link>https://devzone.nordicsemi.com/thread/430002?ContentTypeID=1</link><pubDate>Thu, 08 Jun 2023 12:59:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ee90a5a-4091-4d09-8099-401e28c62fd9</guid><dc:creator>Esbriven</dc:creator><description>&lt;p&gt;OK that&amp;#39;s what i thought about the button.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I think managed to understand the&amp;nbsp;&lt;span&gt;bt_gatt_notify() function i&amp;#39;m able to send the data collected from my sensor, but they are in a hex format.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So now if I want to display the data on the central in a proper format (i.e float with some text like :&amp;nbsp;AccX = %f g) what should I do ? If I understand properly the NUS protocol (with bt_nus_send() function) it recognize the data as ASCII and display it as such in the receiving&amp;nbsp;end right ? Do I have to convert my data as a string prior the sending if I want to use this method ?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;By the way I also have a nRF52840 dongle which could be programmed to convert the hex data send with the custom LBS explained in lesson 3 ex2 into a more readable format but I&amp;#39;m not sure if it&amp;#39;s doable.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks again for the response :)&amp;nbsp;&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: Data transfer from sensor connected with I2C over Bluetooth NUS.</title><link>https://devzone.nordicsemi.com/thread/429971?ContentTypeID=1</link><pubDate>Thu, 08 Jun 2023 11:37:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97254991-0403-458f-abdd-d66bee4d50fe</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Esbriven,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The &amp;quot;Button pressed&amp;quot; and &amp;quot;button releases&amp;quot; is just a feature in the app that it detect the LBS service automatically and translate 1 and 0 to &amp;quot;pressed&amp;quot; and &amp;quot;released&amp;quot;.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;When you use nRF Connect for mobile, and you declare your own service, it will display the hex value. For example:&amp;nbsp;&lt;br /&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/pastedimage1686224218235v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data transfer from sensor connected with I2C over Bluetooth NUS.</title><link>https://devzone.nordicsemi.com/thread/429821?ContentTypeID=1</link><pubDate>Wed, 07 Jun 2023 14:58:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd078399-0d56-47b9-b0ce-7d0a4e43be09</guid><dc:creator>Esbriven</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have followed the exercise 2 and I managed to send&amp;nbsp;data collected by my sensor but they are indeed in hex format. I&amp;#39;ve read that since it&amp;#39;s binary data that are transmitted, the display&amp;nbsp;has to be managed from the central (my phone with nRF Connect for mobile).&lt;/p&gt;
&lt;p&gt;Another thing that I don&amp;#39;t understand in the exercise 2 is how the message &amp;quot;button released&amp;quot; or &amp;quot;button pressed&amp;quot; are transmitted. I&amp;#39;ve notice that my phone get a notify with a value of 0x00&amp;nbsp; for &amp;quot;button released&amp;quot; and 0x01 for &amp;quot;button pressed&amp;quot; on top of the ASCII message. I searched in the different header files of zephyr to find a mention of both &amp;quot; button released&amp;quot; and &amp;quot;pressed&amp;quot;&amp;nbsp; but i couldn&amp;#39;t find any. Is it that nRF_connect (my phone) automatically recognized the value 0x00 as &amp;quot;button released&amp;quot; with the specific UUID related to the button or is it defined somewhere ?&lt;/p&gt;
&lt;p&gt;Thank you for you response.&lt;/p&gt;
&lt;p&gt;best regards.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data transfer from sensor connected with I2C over Bluetooth NUS.</title><link>https://devzone.nordicsemi.com/thread/429811?ContentTypeID=1</link><pubDate>Wed, 07 Jun 2023 14:15:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e8d134e-09cc-45da-a41e-7d78ca63e5ce</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Esbriven,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Have you gone through Lesson 4 exercise 2 ? In the exercise we show you how to send (simulated) sensor data using&amp;nbsp;&lt;span&gt;bt_gatt_notify().&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It&amp;#39;s similar to what the NUS service in peripheral_uart does. In the code you can find&amp;nbsp;bt_nus_send() is called when there is some data in the UART buffer.&amp;nbsp;&lt;br /&gt;In your case you just need to call&amp;nbsp;bt_gatt_notify() with the size of the data you want to send.&amp;nbsp;&lt;br /&gt;Note that you need to enable notification on the peer side (the phone) and if you are simply sending raw data it may not display as&amp;nbsp; normal text as it&amp;#39;s not ASCII you need to look into the raw data that you receive on the phone.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>