Open YibaiMeng opened 6 years ago
Hi @creotiv
I had the same problem with the post above. Could you please share some insights on it? Thanks.
Hi, I’m not being able to receive the accelerometer data. I‘m calling the start_raw_data_realtime function, but it never prints a request for accelerometer data. I think this is because the code, as it is on the GitHub, only sends the requests for HR data, am I correct? What should I write into the char_ctrl to receive the desired data?
Thank you
@JosePProenca Example.py should give all raw data HR & accel data.
It's strange cause i have same hardware and software version on my band. Did it pair device without problems?
Yes, it paired without any issues, but only prints heart rate measurements.
Then i don't know whats happening there, try to run wireshark and trace all BT packets.
Alright, thanks :)
So how did it turn out? Were you able to solve the issue because I'm facing the same problem.
I'm also facing the same problem, any updates?
Hello Everyone,
I really need raw data from motion sensors.
I've tried with the following code:
char_sensor.write(b'\x01\x03\x19') char_sensor.write(b'\x02')
But nothing is notified by the device.
I've also tried to trigger only motion raw data (no hearth rate raw data) by sending
char_sensor.write(b'\x01\x01\x19') char_sensor.write(b'\x02')
Both bytes have been sent to CHARACTERISTIC_SENSOR
.
Now I'm expecting that some notifies should be triggered by CHARACTERISTIC_HZ
but nothing happens.
Please help me to manage this problem.
I've checked UUID and they are the same.
Someone has solved? can please share a possible solution to it ?
Thank you in advance
@franalotto94 I'm facing the same issue, were you able to find a solution?
@franalotto94 I'm facing the same issue, were you able to find a solution?
Hello @Paulolrl , Unfortunately, I was unabe to find a right solution to this issue. I suppose a changement in the following hardware revisions of the miband for the BT unit....
I am facing the same issue. I have triggered motion raw data as well. char_sensor.write(b'\x01\x01\x19') char_sensor.write(b'\x02')
it is returning False for char_sensor.supportsRead()
also when I am trying to read the data from char_sensor char_sensor.read() raise BTLEGattError("Bluetooth command failed", resp) BTLEGattError: Bluetooth command failed (code: 2, error: Attribute can't be read)
Any solution???
Has anyone made any progress getting the raw accel data yet?
Hi, sorry for not reporting it earlier, but I was able to make at least the raw acceleration works. Here is my code:
def start_raw_data_realtime(self, heart_measure_callback=None, heart_raw_callback=None, accel_raw_callback=None):
char_sensor1 = self.svc_1.getCharacteristics(UUIDS.CHARACTERISTIC_HZ)[0]
char_sens_d1 = char_sensor1.getDescriptors(forUUID=UUIDS.NOTIFICATION_DESCRIPTOR)[0]
char_m = self.svc_heart.getCharacteristics(UUIDS.CHARACTERISTIC_HEART_RATE_MEASURE)[0]
char_d = char_m.getDescriptors(forUUID=UUIDS.NOTIFICATION_DESCRIPTOR)[0]
char_ctrl = self.svc_heart.getCharacteristics(UUIDS.CHARACTERISTIC_HEART_RATE_CONTROL)[0]
if heart_measure_callback:
self.heart_measure_callback = heart_measure_callback
if heart_raw_callback:
self.heart_raw_callback = heart_raw_callback
if accel_raw_callback:
self.accel_raw_callback = accel_raw_callback
char_sensor = self.svc_1.getCharacteristics(UUIDS.CHARACTERISTIC_SENSOR)[0]
char_ctrl.write(b'\x15\x02\x00', True)
char_ctrl.write(b'\x15\x01\x00', True)
char_sens_d1.write(b'\x01\x00', True)
char_sensor.write(b'\x01\x03\x19')
char_d.write(b'\x01\x00', True)
char_ctrl.write(b'\x15\x01\x01', True)
char_sensor.write(b'\x02')
t = time.time()
while True:
self.waitForNotifications(0.5)
self._parse_queue()
# send ping request every 12 sec
if (time.time() - t) >= 12:
char_sensor.write(b'\x01\x03\x19')
char_sensor.write(b'\x02')
char_ctrl.write(b'\x16', True)
t = time.time()
Works perfectly! I just replaced the method and copied this in.
Waved around the Mi Band and can see data updating.
Raw accel heart: [{'x': 1, 'y': -7, 'wtf': 125}, {'x': 13, 'y': -11, 'wtf': 127}, {'x': 5, 'y': -18, 'wtf': 124}] Raw accel heart: [{'x': 3, 'y': -4, 'wtf': 127}, {'x': 5, 'y': -7, 'wtf': 130}, {'x': 6, 'y': 7, 'wtf': 133}] Raw accel heart: [{'x': -5, 'y': -64, 'wtf': 101}, {'x': 20, 'y': -8, 'wtf': 126}, {'x': 21, 'y': 33, 'wtf': 108}] Raw accel heart: [{'x': 6, 'y': -2, 'wtf': 132}, {'x': 9, 'y': 2, 'wtf': 127}, {'x': 11, 'y': 2, 'wtf': 125}] Raw accel heart: [{'x': 10, 'y': 2, 'wtf': 128}, {'x': 8, 'y': 2, 'wtf': 124}, {'x': 10, 'y': 1, 'wtf': 127}]
I tried your code @Paulolrl and it works great.
Only problem is I'm not getting achieving a high rate of movement detection right now.
Did I understand the returned data correctly?
It returns an array with 3 items, every item is a pair of x,y,wtf
values so I assumed that every item is an item in sequence. Am I right that I can compare the values from the returned three items to detect changes in movement/direction? But then I only get new value arrays every ~500ms to ~600ms
I made the below change
def _parse_raw_accel(self, bytes):
res = []
# range() changed from 3 to a 1:
for i in range(1):
and added:
# uncomment the below line to fix!
# res.append({'x': g[0], 'y': g[1], 'wtf': g[2]})
if g[0] > 150:
print("++++++++++++++++++++++XXXXXXXXXXXXXXXXXXXXXXXXX")
if g[0] < -150:
print("---------------XXXXXXXXXXXXXXXXXXXXX")
if g[1] > 150:
print("+++++++++++++++++++++++YYYYYYYYYYYYYYYYYYYYYYY")
if g[1] < -150:
print("---------------YYYYYYYYYYYYYYYYYYY")
just to get single lines, so I could tell what axis is what, and how predictably I could move the band. Seems a bit unpredictable, I'm not expecting the band to be that accurate anyway. not sure on the 'for i in range(3):'
When running
example.py
, there appears to be noRaw accel
andRaw heart
data. Perhaps the band firmware changed its instruction, or perhaps the band removed the functionality altogether.My firmware data is as follows: