You are here

How to send an array of ADC readings as a bluetooth characteristic | Cypress Semiconductor

How to send an array of ADC readings as a bluetooth characteristic

Summary: 3 Replies, Latest post by hli on 24 Apr 2016 07:47 AM PDT
Verified Answers: 1
Last post
Log in to post new comments.
r.dijkstra05_1488816's picture
6 posts

As I would like to do some processing like finding top to top AC values, average values etc on multiple ADC reading results on the client (phone) side, I am searching for a way to send (int16) array as/in a bluetooth chracteristic. However, I can't find a tutorial on how to set this up.

In the bluetooth profile, I can find the sint16 array property for a characteristic, but I can't find any information on how to set this up.

My questions are;

How many samples can I send in one array (how many values can be stored and sent in one array)

How do I store these values in the array in the main.c function before I send it? For sending individual ADC result values I now have the below piece of code where 'meetwaarde' is an int16 in which the ADC result is stored. What do I need to change to send an array instead of one single value?



tempHandle.value.val = (uint8 *)&meetwaarde;

tempHandle.value.len = 2;

CyBle_GattsWriteAttributeValue(&tempHandle, 0, &cyBle_connHandle,0);


if (updateNotify ) {



And of course, how can the values be pulled out of the array on the client side (android) again?

I have a function for pulling a value from a characteristic now which looks like the code below;

private void updateWaarde(BluetoothGattCharacteristic c) {
    int waarde = c.getIntValue(BluetoothGattCharacteristic.FORMAT_SINT16, 0);
    EditText textVeld = (EditText) findViewById(;

I am wondering how I can store the array which I get back in the characteristic in a local (java) array.

Any support would be much appreciated.

mady's picture
Cypress Employee
964 posts


1) By default the GATT MTU Size is 23 bytes. So the size of the array you can send is also limited by this.

However, in order to increase this, you can set the MTU Size in PSoC Creator-> BLE Component -> GAP Settings -> MTU Size is kept to a high value. (Say 40, 60 or 100). Max value is 512. However the client and server should undergo negotiation about the increased MTU Size.

The client should always initiate the MTU increase request. 

If your Cypress BLE Device is server, it will receive CYBLE_EVT_GATTS_XCNHG_MTU_REQ event once the client initiate the MTU request. It should  now respond by CyBle_GattsExchangeMtuRsp.

If your Cypess BLE Deviceis client, it should initiate the MTU negotiation by calling CyBle_GattcExchangeMtuReq. Once the server has responded, the client would receive CYBLE_EVT_GATTC_XCHNG_MTU_RSP event. Please refer to BLE Datasheet for more details on these APIs and events.

2) You can refer the source code of our CySmart Android App to check how the notified value is read as array on the client. You can refer the capsesence RGB Led Custom Service.


- Madhu Sudhan


r.dijkstra05_1488816's picture
6 posts

Hello Madhu,

Thank you for your reply. I will look into the cysmart app on clues how to get an array out of a characteristic.

On the part of sending an array, I was hoping to be able to send about 500 int16 values in one array. I assume 500 int16 values won't fit in a 20, or even 500 bit array?

I read in an article about throughput, that the ble device should be able to put a datarate of about 200kb/s through. I'm not yet sure how this relates to a maximum characteristic size of about 500.

Any explanation (or articles I should read) are welcome.

user_78878863's picture
2553 posts

AFAIK when you have a characteristic with more than the MTU allows, the BLE stack should automatically do a 'long read'. This means its splitting up the transfer into multiple packets. I did this before with 244 bytes of data, and did not remember of any special this I needed to do.

Log in to post new comments.