<?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>how to read the data  from peripheral and send the data over ble</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/40632/how-to-read-the-data-from-peripheral-and-send-the-data-over-ble</link><description>hi........... nrf523 
 how to read the data from peripheral and send the data over ble using ble uart 
 i have merged the two programs ble_uart and twi sensor ,what changes i want to do in order to read the data from peripheral 
 anyone can explain me</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 19 Nov 2018 06:51:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/40632/how-to-read-the-data-from-peripheral-and-send-the-data-over-ble" /><item><title>RE: how to read the data  from peripheral and send the data over ble</title><link>https://devzone.nordicsemi.com/thread/157864?ContentTypeID=1</link><pubDate>Mon, 19 Nov 2018 06:51:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d448ad7d-3590-4b82-bf67-edb2a2eddd7d</guid><dc:creator>Sunil vignesh</dc:creator><description>&lt;p&gt;Hi Saral,&lt;/p&gt;
&lt;p&gt;If you want to send only the&amp;nbsp;&lt;strong&gt; data that you read&amp;nbsp;&lt;/strong&gt;from sensor means. keep the same code there is no change in the uploaded code.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;you create one function. in that you read the raw data. process it and store in one variable. then do&amp;nbsp;&lt;strong&gt;sprintf&amp;nbsp;&lt;/strong&gt; to convert into string . then push the data using&amp;nbsp;&lt;strong&gt;ble_nus_data_send().&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;and in&amp;nbsp;&lt;strong&gt;main function()&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;after init functions&amp;nbsp;&lt;/p&gt;
&lt;p&gt;in while loop you call the function with time interval of 1S delay&amp;nbsp;&lt;/p&gt;
&lt;p&gt;it will push the respective data. in your mobile using BLE UART app you can see the string&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void read_sensor_data()
{
      m_xfer_done = false;
      uint16_t length;
      
      float f = 23.50;
      char str[80];
      
      length1 = sprintf(str, &amp;quot;AccX = %5d  AccY = %5d  AccZ = %5d \n&amp;quot;, accel.x, accel.y, accel.z);

      rsltb = ble_nus_data_send(&amp;amp;m_nus, str, &amp;amp;length1, m_conn_handle);
      NRF_LOG_INFO(&amp;quot;Data send...&amp;quot;);
        NRF_LOG_FLUSH();
       printf(&amp;quot;AccX = %5d  AccY = %5d  AccZ = %5d \r\n&amp;quot;, accel.x, accel.y, accel.z);
        printf(&amp;quot;Data send.. \r\n&amp;quot;);

}

/**@brief Application main function.
 */
int main(void)
{
    bool erase_bonds;
     uint8_t sample_data[10];

    // Initialize.
    uart_init();
    log_init();
    timers_init();
    buttons_leds_init(&amp;amp;erase_bonds);
    power_management_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();

    // Start execution.
    printf(&amp;quot;\r\nUART started.\r\n&amp;quot;);
    NRF_LOG_INFO(&amp;quot;BMI160 get started...&amp;quot;);
    advertising_start();
    Acc_delay_ms(100);

    twi_init();
    Acc_delay_ms(50);

    BMI160_init();
     NRF_LOG_FLUSH();
    Acc_delay_ms(100);

    // Enter main loop.
    for (;;)
    {
        //idle_state_handle();
        nrf_delay_ms( 1000 ) ;
        read_sensor_data();
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>