I am looking to create a simple python script that reads heart rate data from a Polar sensor over Bluetooth. I have read through a lot of other posts and cannot find something simple that I am able to successfully execute.
I have the device MAC address for the Polar wearable. I know the service UUID for the value I want to read (0x180D for HR). I don't care much about which library or service I use, but I cannot seem to get this to work.
I am able to have my script successfully recognize the Polar sensor, however, I cannot figure out how to read the value from this. I have downloaded a Bluetooth Scanner app for my phone which is able to successfully connect and read the value, so I know it should be easy to do and cannot figure out how to write this up.
Any help would be tremendously appreciated.
If you look at the Bluetooth assigned 16-bit UUIDs numbers then you are correct that
0x180Dis the Heart Rate serviceIt will be the Heart Rate Measurement Characteristic
0x2A37that will have the values you are seeking:I don't have a device to test this with and I don't know what platform you are writing the code for.
As a result I've used the bleak library as that is the most cross platform library.
The example also subscribes to notifications from the device rather than reads the value. This is a more typical way to get values that are regularly updating.
You can read more about the Heart Rate Measure value is constructed in:
https://www.bluetooth.com/specifications/specs/gatt-specification-supplement-6/