sandeepmistry / arduino-BLEPeripheral

An Arduino library for creating custom BLE peripherals with Nordic Semiconductor's nRF8001 or nR51822.
MIT License
463 stars 180 forks source link

byte array characteristic / multiple doubles/floats to characteristic #220

Closed mristau closed 6 years ago

mristau commented 6 years ago

I have a LIS2DE12 Accelerometer on my board, which is used to send interrupts to wake up my nRF52, which is working just fine.

What i want now, is sending the Accelerometer Data over BLE. The LIS2DE12 has 3 8-bit registers containing the data of each axis, so it's basically 3x8bits of data. I use a Vector-Library to store the data, which internally uses a double array, but i would be fine with just sending the raw 24bits and making the calculations on clientside. It would be easy to add 3 Characteristics one for every axis, but that way they could be out of sync.

Could i make a 3 byte characteristic and write the 3 axes to it directly? Which of the many characteristic types would fit for that, or would i have to define a new one

sandeepmistry commented 6 years ago

Hi @mristau,

I would suggest using BLECharacteristic with a value size of 3 bytes: https://github.com/sandeepmistry/arduino-BLEPeripheral/blob/master/API.md#contructor

Then you can set the value with a 3 byte array.