ArduinoBLE.h - multiple values in one characteristic

533 views Asked by At

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:

ArduinoBLE documentation - service design patterns

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).

1

There are 1 answers

0
Michael Kotzjan On BEST ANSWER

The documentation states (as posted in your image):

The accelerometer characteristic above, for example, takes 11 bytes as a ASCII-encoded string.

They just created a comma separated string containing all their data ("200,133,150") and transmitted it using writeValue. You could do the same for your values and convert them back to numbers on your receiving end. Another way would be to use a struct to hold and send your data.