<?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>Questions about Github example, ble_app_uart_saadc_timer_driven_scan_mode</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/45592/questions-about-github-example-ble_app_uart_saadc_timer_driven_scan_mode</link><description>Hi, I am trying to figure out the adc example posted by Nordic Semiconductor on Github. 
 https://github.com/NordicPlayground/nRF52-ADC-examples 
 There was two examples, and I am struggling with the first one, ble_app_uart_saadc_timer_driven_scan_mode</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 02 Apr 2019 06:54:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/45592/questions-about-github-example-ble_app_uart_saadc_timer_driven_scan_mode" /><item><title>RE: Questions about Github example, ble_app_uart_saadc_timer_driven_scan_mode</title><link>https://devzone.nordicsemi.com/thread/179655?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2019 06:54:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab6bd984-80d4-4cdd-8f18-ff2b93281173</guid><dc:creator>KYUBEEN</dc:creator><description>&lt;p&gt;Thanks Jorgen, It works for me well !!&lt;/p&gt;
&lt;p&gt;Have a great day&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Questions about Github example, ble_app_uart_saadc_timer_driven_scan_mode</title><link>https://devzone.nordicsemi.com/thread/179578?ContentTypeID=1</link><pubDate>Mon, 01 Apr 2019 16:19:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:561bed07-ce5c-4603-b714-786b2b782819</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You can do something like this (given that you keep the SAMPLES_IN_BUFFER at 4):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;uint8_t nus_string[20];
int n = sprintf(nus_string, &amp;quot;%d\r\n%d\r\n%d\r\n%d\r\n&amp;quot;, p_event-&amp;gt;data.done.p_buffer[0], p_event-&amp;gt;data.done.p_buffer[1], p_event-&amp;gt;data.done.p_buffer[2], p_event-&amp;gt;data.done.p_buffer[3]);

if(n &amp;lt;= 20) 
{
	bytes_to_send = n;
}
else 
{
	bytes_to_send = 20;
}
err_code = ble_nus_string_send(&amp;amp;m_nus, nus_string, bytes_to_send);
if (err_code != NRF_ERROR_INVALID_STATE) 
{
	APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If you have not connected the inputs, they are floating and you will get varying values in the full range of the SAADC resolution (configured at 10 bit - 0 to 1023 in the example).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Questions about Github example, ble_app_uart_saadc_timer_driven_scan_mode</title><link>https://devzone.nordicsemi.com/thread/179576?ContentTypeID=1</link><pubDate>Mon, 01 Apr 2019 16:12:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:969442e8-7224-44a3-a7c6-2fcc25de260f</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;How to properly post code - not as an image!&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/7723._5F00_Insert-Code-_2D00_-Nordic.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="76601" url="~/f/nordic-q-a/45592/questions-about-github-example-ble_app_uart_saadc_timer_driven_scan_mode/179567"]the yellow boxed line is like sending as string[/quote]
&lt;p&gt;The function name is misleading - it sends raw&amp;nbsp;bytes - &lt;em&gt;&lt;strong&gt;not&lt;/strong&gt; &lt;/em&gt;a &amp;quot;string&amp;quot; in the &amp;#39;C&amp;#39; sense.&lt;/p&gt;
[quote userid="76601" url="~/f/nordic-q-a/45592/questions-about-github-example-ble_app_uart_saadc_timer_driven_scan_mode/179567"] I have no idea where can I use sprintf()[/quote]
&lt;p&gt;That&amp;#39;s a standard &amp;#39;C&amp;#39; programming question - nothing specifically to do with Nordic!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;sprintf()&lt;/strong&gt; is part of the &lt;em&gt;Standard&lt;/em&gt; &amp;#39;C&amp;#39; library:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.cplusplus.com/reference/cstdio/sprintf/"&gt;http://www.cplusplus.com/reference/cstdio/sprintf/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You use it to create a string in a buffer that you provide.&lt;/p&gt;
&lt;p&gt;You could then transmit that buffer using ble_nus_string_send().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Questions about Github example, ble_app_uart_saadc_timer_driven_scan_mode</title><link>https://devzone.nordicsemi.com/thread/179567?ContentTypeID=1</link><pubDate>Mon, 01 Apr 2019 16:00:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:810aa6ab-212c-4c84-93b7-32067d16c833</guid><dc:creator>KYUBEEN</dc:creator><description>&lt;p&gt;Hi Jorgen,&lt;/p&gt;
&lt;p&gt;Thank you for clear answer. Following the link you tagged, I found this, which seems to be a part of sending data via ble.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1554134013702v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;But the yellow boxed line is like sending as string and I have no idea where can I use sprintf() there.&lt;/p&gt;
&lt;p&gt;Or you mean I should add another line above that yellow boxed line, like value = sprintf(value)?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And one more question is I want to figure out the meaning of the numbers, I can check with uart terminal. There are 4 samples at every event, but the number is very random in the range from about 10 to 1000. I didn&amp;#39;t give any voltage inputs yet, so I think the value should be about 0. at least some constant value. Could u help me with this too?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for reply again.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Kyubeen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Questions about Github example, ble_app_uart_saadc_timer_driven_scan_mode</title><link>https://devzone.nordicsemi.com/thread/179503?ContentTypeID=1</link><pubDate>Mon, 01 Apr 2019 12:48:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:510055c7-0663-4b10-bdc6-541f50e0b48b</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The example sends samples from the analog inputs, but the values are &lt;a href="https://github.com/NordicPlayground/nRF52-ADC-examples/blob/master/ble_app_uart__saadc_timer_driven__scan_mode/main.c#L782"&gt;sent as binary numbers&lt;/a&gt;, and not strings. If you want to see the samples as strings, you can use sprintf() function to convert the sample values into a string/char array.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>