espruino / EspruinoHub

A BLE -> MQTT bridge for Raspberry Pi and other Embedded devices
Other
238 stars 62 forks source link

Xiaomi Mi smartband 6 #87

Open kmg454 opened 3 years ago

kmg454 commented 3 years ago

Just bought a Xiaomi MI band 6 and want to read the heartrate. It will connect to the hub but I see no advertising data at all. Is there anything I have to change in xiaomi.js to see the values of this device? Maybe the xiaomiProductName has to been added?

gfwilliams commented 3 years ago

@G1K do you have any thought on what might need to change?

kmg454 commented 3 years ago

I know the product name is XMSH15HM but in the xiaomi.js I see a Hex number in front I have no idea what to add there

G1K commented 3 years ago

I do not have myband 6, but on many previous bracelets and watches it is necessary to turn on 2 switches in the application. 1) for ads, it often has steps 2) for heartbeat data. in order for the bracelet to constantly measure and broadcast the heartbeat, you need to turn on the training mode. maybe it will transmit in the usual mode, but rarely.

kmg454 commented 3 years ago

I do not have myband 6, but on many previous bracelets and watches it is necessary to turn on 2 switches in the application. 1) for ads, it often has steps 2) for heartbeat data. in order for the bracelet to constantly measure and broadcast the heartbeat, you need to turn on the training mode. maybe it will transmit in the usual mode, but rarely.

When de Mi smartband 6 is on I can see the name of it in the Espruinohub but there is no advertising data, also no steps which I can see with earlier Mi bands. I do not know how the Xiaomi.js is working but when i look into it i see productnames. Like: 0x01aa: "LYWSDCGQ", 0x03dd: "MUE4094RT", 0x07f6: "MJYD02YLA", 0x0387: "MHOC401", ????????: "XMSH15HM" In the last line you see the productname of the MI smartband 6 but I don't know what hex numer to put in front of it. Not sure my product name must be in there, but it sounds logic to me.

G1K commented 3 years ago

The name and model is not used to decrypt messages. In most cases, the decryption goes on the service ID from the data that announces devices. Did you go in the MI FIT application and turned on the detection of the device and the transfer of the pulse?

kmg454 commented 3 years ago

The name and model is not used to decrypt messages. In most cases, the decryption goes on the service ID from the data that announces devices. Did you go in the MI FIT application and turned on the detection of the device and the transfer of the pulse? I was not using the MI fit app but Xiaomi wear. Now installed the Mi fit app but where can i find to set the transfer of the pulse?

G1K commented 3 years ago

I was not using the MI fit app but Xiaomi wear. Now installed the Mi fit app but where can i find to set the transfer of the pulse?

Search in your app or in mi fit. the setting should be somewhere in the device settings. There are not so many buttons to get confused. I don't have such a bracelet, nor an android. You can search in Google "how to enable mi band ble detection " , example https://community.home-assistant.io/t/esphome-ble-tracking-mi-band-4-working/129732/21 .

For underage accounts, this setting may not be visible.

kmg454 commented 3 years ago

I was not using the MI fit app but Xiaomi wear. Now installed the Mi fit app but where can i find to set the transfer of the pulse?

Search in your app or in mi fit. the setting should be somewhere in the device settings. There are not so many buttons to get confused. I don't have such a bracelet, nor an android. You can search in Google "how to enable mi band ble detection " , example https://community.home-assistant.io/t/esphome-ble-tracking-mi-band-4-working/129732/21 .

For underage accounts, this setting may not be visible.

Found the setting and now the band is advertising the steps :-) Now find how to advertise the heartrate (the most important in my case)

G1K commented 3 years ago

And now reread what I wrote above. The key should be the second switch and you need to turn on the training mode to constantly monitor your heart rate.

kmg454 commented 3 years ago

And now reread what I wrote above. The key should be the second switch and you need to turn on the training mode to constantly monitor your heart rate.

I tried to start a training and turn on heartrate advertising to other party. When i start a BLE heartrate app on my mobile it connects and show the heartrate, but the EspruinoHub does show nothing except steps.

kmg454 commented 3 years ago

The band is advertising but not to Espruinohub see picture

BLE
G1K commented 3 years ago

These are two different things. I was talking about switches. in Zepp app referred to as 1) Detection 2) General heart rate information. in Mi fit is similar. If both of them are turned on, then in the training mode that can be turned on from a watch or bracelet, information about the heart rate is transmitted in clear form in advertising messages. And it can be caught by anyone and is implemented in espruino in the xiaomi.js parser.

What you showed in the screenshot is a different mode, you can run it through espruino. You need to connect to the bracelet, and subscribe to notifications of a specific characteristic. then they will be sent directly and not broadcast to everyone, but there is one drawback. only one device can be connected to the bracelet at once and therefore most likely you will have to turn off the bluetooth on the phone.

kmg454 commented 2 years ago

I turned on both switches and start training or workout on the MI6 band, but the EspruinoHub does not show the heart rate. Think there must be some editing in the attributes.js I found this which show the steps but it say also something about heart rate: "fee0": function (d) {

let r = {steps: (0xff & d[0] | (0xff & d[1]) << 8)};
if (d.length === 5)
  r.heartRate = d[4];
return r;

I think this need some editing.

gfwilliams commented 2 years ago

You've been posting in the forum recently as well? https://forum.espruino.com/conversations/379871/#comment167048

Maybe just continue the discussion there rather than posting here