ArduinoBLE.h - multiple values in one characteristic

Dear all,

I recently read the documentation of the ArduinoBLE.h library. Under "Service design patterns" it is noted that it is possible to write multiple values to one characteristic:

You could also combine readings into a single characteristic, when a given sensor or actuator has multiple values associated with it.

Characteristic Value
Motor Speed, Direction 150,1
Accelerometer X, Y, Z 200,133,150

This is more efficient, but you need to be careful not to exceed the 512-byte limit. The accelerometer characteristic above, for example, takes 11 bytes as a ASCII-encoded string.

How can I achieve that? Unfortunately I cannot find any information about this in the documentation.

I want to send all accelerometer data in one characteristic and all gyroscope data respectively along with a time stamp. This results in two characteristics

  1. accChara: [time stamp, xAcc, yAcc, zAcc] and
  2. gyroChara: [time stamp, xGyro, yGyro, zGyro],
    where time stamp is an unsigned long (via millis()) and the values read are floats (note: I am using the Arduino_LSM9DS1.h library for the IMU).

Thanks for your help :slight_smile: