Arm Mbed OS support forum

Send data from multiple sensors through BLE (nrf52)

Hi
I am trying to send data from multiple sensors (Heartrate and temperature) simultaneously through BLE

For now i was thinking of adapting the heartrate example (https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-ble-HeartRate/) to send multiple sensor data (instead of only HR).
The thing is I don’t really know where to start or how to do it.

(I am using a NRF52 EVK board)

best

The classic OS2 example is a little more simpler for you to adapt.
https://os.mbed.com/teams/Bluetooth-Low-Energy/code/BLE_HeartRate/

Plenty to read here to that will help you.
https://os.mbed.com/teams/Bluetooth-Low-Energy/

Are those links not a bit old. They don’t appear to have been updated for MBED 5.x

The BLE_API already includes pre-made service classes that are available for use:

To use any of these services simply use

#include “ble/services/HeartRateService.h”

Similarly you can do the same for temperature:
#include “ble/services/ HealthThermometerService.h”

This allows you create two GATT services, one for heart rate and one for temperature.

Then there are also MBED examples available on their github repo

There is an example available for each (i.e. heart rate and temperature). It now just requires you to modify one of these examples to incorporate the other service.

I believe to do this requires modifying one of the “demo” classes within main.cpp