Closed vanlooverenkoen closed 2 years ago
I figured the conversion to get these values from the impedance value would have been some black box algorithm on Xiaomi's part, so I never really considered looking into it. If that algorithm in the 2nd link works for this scale as well, that does make things a lot easier.
Currently I'm not interested in implementing this due to time constraints, but I'll gladly merge a PR.
I have a hunch that the impedance value might be stored in bytes 9 and 10 of the advertisement data.
Because we only need 1 number for the calculation: BIA (Bioelectrical impedance analysis) https://en.wikipedia.org/wiki/Bioelectrical_impedance_analysis
I am trying to use this java class for parsing the extra fields
The only thing we apparently need is the impedance which is stored in here:
impedance = ((data[10] & 0xFF) << 8) | (data[9] & 0xFF);
This is what it looks like:
I compared the results with the results from the xiaomi app.
And this is exactly the same. So I think we can use this to get the extra data
I need help the impedance value is always null and I can't get the other data can someone help me @vanlooverenkoen
@hmmunioz what scale are you using?
I only have a Mi Body Composition Scale 2
so I only tested that scale
@vanlooverenkoen hi bro, I use the same My body composition scale 2, can you please share the complete project with me, because I don't understand why the impedance is still null, I don't know if I have a problem with the code, could you please send it to me
The example is the complete project. So you should be able to use the example. And that should not give you a null value.
hoooooolly s***t, it worked friend, I add an impedance != null before return MiScaleData in MI_scale_device_v2.dart, and and modified proccesData for the same condition, waaaaaaaaaaa I'm very happy it's working, thanks genius @vanlooverenkoen . How complex is it to make a similar plugin for the miband6?
For now this package only supports getting your
weight
This is also supported by the scale. Is there a way to get these values as well?
https://dev.to/henrylim96/reading-xiaomi-mi-scale-data-with-web-bluetooth-scanning-api-1mb9
https://github.com/wiecosystem/Bluetooth/blob/master/sandbox/huami.health.scale2/body_metrics.py