<?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>NRF51 BLE mbed ADC</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/14549/nrf51-ble-mbed-adc</link><description>Hi, 
 I am trying to make a program for the NRF51 development kit on mbed. I have been able to take ADC samples at 1000Hz which is what I want, but I can&amp;#39;t seem to print the actual voltage over BLE UART on my phone. I am new to this type of thing altogether</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 21 Jun 2016 07:49:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/14549/nrf51-ble-mbed-adc" /><item><title>RE: NRF51 BLE mbed ADC</title><link>https://devzone.nordicsemi.com/thread/55561?ContentTypeID=1</link><pubDate>Tue, 21 Jun 2016 07:49:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d0ad4ed9-a9c7-4da1-8d8e-fbc510370bba</guid><dc:creator>Tim</dc:creator><description>&lt;p&gt;All bluetooth modules. There &lt;em&gt;is&lt;/em&gt; a TCP-like layer call L2CAP but you can never get access to it. You have to use GATT which runs on top of L2CAP. BLE 4.2 did introduce &amp;quot;Connection Oriented Channels&amp;quot; which give you access to L2CAP (or something like that), but it&amp;#39;s not available in iOS or Android. Give it 5 years or so, maybe. See &lt;a href="https://www.nordicsemi.com/layout/set/print/News/ULP-Wireless-Update/Bluetooth-technology-opens-up-to-IP-traffic"&gt;www.nordicsemi.com/.../Bluetooth-technology-opens-up-to-IP-traffic&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF51 BLE mbed ADC</title><link>https://devzone.nordicsemi.com/thread/55560?ContentTypeID=1</link><pubDate>Sat, 18 Jun 2016 15:50:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:063000e1-605d-4d64-9180-a24969d1be3a</guid><dc:creator>Sri_guy</dc:creator><description>&lt;p&gt;Ok, this code is really helpful. When you say BLE does not support TCP-like connection. Does that apply to all bluetooth modules, or just mbed? Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF51 BLE mbed ADC</title><link>https://devzone.nordicsemi.com/thread/55559?ContentTypeID=1</link><pubDate>Fri, 17 Jun 2016 12:27:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7dd02c9a-c09b-4c87-8dca-4e1b1b438b15</guid><dc:creator>Tim</dc:creator><description>&lt;p&gt;I suggest you try the new mBed Simple BLE library: &lt;a href="https://developer.mbed.org/blog/entry/A-new-Bluetooth-library-SimpleBLE/"&gt;developer.mbed.org/.../&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Unfortunately BLE doesn&amp;#39;t yet expose a TCP-like connection where you can just send data (it&amp;#39;s coming though). You have to use GATT which imposes a structure on your communications. Data is stored in GATT Characteristics, and you &amp;#39;send&amp;#39; it by having the client (phone app) enable notifications on your characteristic, and then writing to the characteristic on the device.&lt;/p&gt;
&lt;p&gt;Characteristics are grouped into Services. The easiest way to get a feel for this is to download the Master Control Panel app, connect to some BLE device and play around.&lt;/p&gt;
&lt;p&gt;You can send floats perfectly fine. Although you may as well send as &lt;code&gt;uint16&lt;/code&gt; since that&amp;#39;s what is actually read, and it is shorted. Something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;quot;mbed.h&amp;quot;
#include &amp;quot;SimpleBLE.h&amp;quot;
 
AnalogIn voltage(A0);
 
SimpleBLE ble(&amp;quot;VoltageSensor&amp;quot;);
 
// Create a new characteristic under service 0x8000, char 0x8001
// This characteristic will support READ and NOTIFY.
SimpleChar&amp;lt;float&amp;gt; voltageValue = ble.readOnly_float(0x8000, 0x8001);
 
void read() {
    voltageValue = voltage.read();
}
 
int main(int, char**) {
    Ticker t;
    t.attach(&amp;amp;read, 1.0f); // read new value every second
 
    ble.start();
    while (1) { ble.waitForEvent(); }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By the way you will get no-where near 1000 Hz unless you pack multiple reads into each notification. BLE data rates are typically around 1 kB/s, up to a theoretical max of around 6 kB/s (I forget the exact number). It depends on the phone, and how you set the connection parameters.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF51 BLE mbed ADC</title><link>https://devzone.nordicsemi.com/thread/55558?ContentTypeID=1</link><pubDate>Fri, 17 Jun 2016 12:09:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26b6677d-7785-44c7-a3fc-17dd3db126fc</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;You cant transmit float over BLE, only bytes are accepted, i.e. uint8_t. So if you have a float, you need to code that into a byte and then decode that on the BLE receiving side. You can see in the ble_nus.c file, ble_nus_string_send function how data is sent over BLE with calling sd_ble_gatts_hvx function. I.e. &lt;a href="https://github.com/NordicSemiconductor/nrf51-ADC-examples/tree/nRF51-SDK-9-0-0"&gt;this ADC example&lt;/a&gt; uses the NUS (Nordic UART Service) service.&lt;/p&gt;
&lt;p&gt;There is also possibility to calculate battery remaining in procentage, before sending it over BLE, like done &lt;a href="https://devzone.nordicsemi.com/question/30771/battery-percentage-measurement-fluctuation/"&gt;here&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>