<?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>Passing ADC through to NUS Service Wrong Results</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/34117/passing-adc-through-to-nus-service-wrong-results</link><description>I can&amp;#39;t figure out why I can&amp;#39;t send ADC values to the NUS service via BLE correctly. I should be getting hex values that convert to something like 0 or -1, since the ADC pin is grounded. Instead I am getting back like 0x040020E9 using the Nordic app.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 14 May 2018 08:43:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/34117/passing-adc-through-to-nus-service-wrong-results" /><item><title>RE: Passing ADC through to NUS Service Wrong Results</title><link>https://devzone.nordicsemi.com/thread/131810?ContentTypeID=1</link><pubDate>Mon, 14 May 2018 08:43:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a79b5d9-44df-4227-b59d-977697466373</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Well,&lt;/p&gt;
&lt;p&gt;You can change the characteristic to hold/send 16 bit values, but if you want to send 16 bits, I suggest that you split it in two 8bit values, as this is probably easier to do.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Passing ADC through to NUS Service Wrong Results</title><link>https://devzone.nordicsemi.com/thread/131741?ContentTypeID=1</link><pubDate>Fri, 11 May 2018 20:46:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b37108d-948b-4d8b-8d11-f4fd6070f69c</guid><dc:creator>ewizardii</dc:creator><description>&lt;p&gt;Thanks, I think I found a way around it - unless one can straight pass to `ble_nus_data_send` 16 bit values this is what I am doing:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    static uint16_t adc_value;
    static uint16_t adc_len;

    uint8_t i = SAADC_SAMPLES_IN_BUFFER - 1;
    adc_value = p_event-&amp;gt;data.done.p_buffer[i];
    adc_len = sizeof(adc_value);
    err_code = ble_nus_data_send(&amp;amp;m_nus, (uint8_t *)&amp;amp;adc_value, &amp;amp;adc_len, m_conn_handle);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Passing ADC through to NUS Service Wrong Results</title><link>https://devzone.nordicsemi.com/thread/131678?ContentTypeID=1</link><pubDate>Fri, 11 May 2018 08:30:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d474829a-9731-44c0-bf96-4c0fa4069288</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I think the problem is that your saadc buffer holds uint8_t values, while they are actually uint16_t.&lt;/p&gt;
&lt;p&gt;Try to change to:&lt;/p&gt;
&lt;p&gt;uint16_t transfer_buffer[SAADC_SAMPLES_IN_BUFFER];&lt;/p&gt;
&lt;p&gt;and see if it sends the correct values.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>