ESP-32 BLE client

I am trying to get notification data from my smartwatch. I figured out almost everything. But data received on the serial monitor makes no sense to me.

this is serial monitor output.
Notify callback for characteristic c3e6c1a2-e966-1000-8000-be99c223df6a of data length 14
RAW DATA: U0
pROC DATA: U0

Data from the device look like this:

55-30-00-06-00-88-00-00-0A-00-B2-00-01-60

which is hexadecimal, last byte 60 represents the O2 value which in decimal is 96. 10th byte is the identifier of the reading type which in this case is O2 measurement.
Here is another value received by notification.

55-30-00-06-00-CB-00-00-0A-00-AB-00-01-00
55-30-00-06-00-48-00-00-0A-00-AB-00-01-52

in this case, the 10th byte AB is the identifier of Hr reading, and the last byte 53 is the heart rate value (82).

Here is another example of value received by notification during a workout.

55-30-00-11-00-49-00-00-0A-00-AC-00-0C-00-00-02-E6-41-F0-AC-08-3F-05-E3-54
55-30-00-11-00-B7-00-00-0A-00-AC-00-0C-00-00-02-F3-41-F4-E3-54-3F-08-31-27

I haven't yet figured out what this means. but could step count, duration, calories burnt, and Heartrate values.
I want to get the type of reading and actual value of measurement.

Notification Callback function:
//When the BLE Server sends a new temperature reading with the notify property
static void temperatureNotifyCallback(BLERemoteCharacteristic* pBLERemoteCharacteristic,
                                      uint8_t* pData,
                                      size_t length,
                                      bool isNotify) {

  Serial.print("Notify callback for characteristic ");
  Serial.print(pBLERemoteCharacteristic->getUUID().toString().c_str());
  Serial.print(" of data length ");
  Serial.println(length);
  //store temperature value
  Serial.print("RAW DATA: ");
  Serial.println((char*)pData);
  String strData;
  strData.reserve(length);
  for (int i = 0; i < 24; i++) {
    strData += (char)pData[i];
  }
  Serial.print("pROC DATA: ");
  Serial.println(strData);
  newTemperature = true;
}

I don't know what I am doing wrong here. Can someone please guide me? and I am not a programmer :sweat_smile:
thanks

I am not a programmer

You might want to take a course to become a programmer, or hire an experienced programmer if you need to do it quickly.

I don't know what I am doing wrong here.

There are many smartwatch models, try to find the communication protocol for the model you have in hand. If you have a working system, such as an Android App, you might be able to reverse engineer the App to understand how data is handled.

Please post your complete code. When you connect to the server to you registerForNotify?

Do you have an app like Light Blue on a phone which can connect to the smartwatch and show you everything that is going on?

Hi, thanks for your reply. I have done projects with Arduino. When i said i am not a programmer i meant not a professional programmer. Just tinkering around with Arduino since long time.
i figured out the protocol and data handling use nrfconnect app, WireShark. by sniffing data packets passing through android to watch. I know how to take different kind of readings etc.
but here problem is the data received from watch is incomplete only first two bytes are getting printed on serial monitor. i don't know if it is size limit of data transfer of esp-32 or something else.

This is modified code of Arduino ESP-32 BLE example. i added service UUID's and characteristic UUID's . I am able to connect to watch and can receive notification data. but for some reasons data received by ESP-32 is incomplete only first few bytes are getting printed on serial monitor.
I can post the code somewhere if you want to have a look.
I intercepted data packets with wireshark going through my android phone app to watch. that's how i am able to decode data packets.

The third byte in your received data is 0x00 and is seen as a terminator by both of your print routines

Serial.println((char*)pData);
 Serial.println(strData);

Try to print out the bytes individually

for (int i = 0; i < 24; i++) {
    Serial.print(pData[i], HEX);
    Serial.print(" "); //separate values with a space
  }

Hi thanks, you solved my problem. Now i can receive entire data on serial monitor.

HR 75 BPM
85 48 0 7 0 238 0 121 10 0 177 0 2 115 75
data length 15
spO2 95 %
85 48 0 6 0 79 0 121 10 0 178 0 1 95
data length 14
blood pressure 116/75 mmHg
85 48 0 7 0 132 0 121 10 0 177 0 2 116 75
data length 15

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.