erdose / xiaomi-mi-lywsd03mmc

Xiaomi Mi BLE Temperature & Humidity Sensor
MIT License
26 stars 7 forks source link

2021-01-15 18:04:26 ERROR Failed to connect to peripheral XX:C1:38:C6:C5:D3, addr type: public #5

Closed lecocqe closed 3 years ago

lecocqe commented 3 years ago

Hello,

i tried your script and it gives the following error: 2021-01-15 18:04:26 ERROR Failed to connect to peripheral A4:C1:38:C6:C5:D3, addr type: public

the script runs and then in the log file: 2021-01-15 18:04:26 ERROR Failed to connect to peripheral A4:C1:38:C6:C5:D3, addr type: public

i'm sure of the MAC's and with another script; it works. I'm interested by your script because it's easy to understand as the other one, this s not the case.

thank you for your help

erdose commented 3 years ago

What is your python version? You must 3.6 or higher!

mvdklip commented 3 years ago

I am experiencing the same issue. The device shows up in a hctitool lescan, but the script won't connect. Running on Debian Buster Python 3.7.3.

Tried running the script / Python as root and tried restarting the bt stack. Is there anything I can do to debug why it can't connect?

erdose commented 3 years ago

Do the temperature sensor shows the BT icon on its screen meanwhile you try to connect? Because I realised, if the sensor remains in paired state (I don't know why) the script cannot connect anymore. Try to restart the sensor (remove the battery) and check the connection again.

mvdklip commented 3 years ago

Thanks for your response!

After trying several things I found out that the way the stock Mi firmware works is not great. Actively connecting to the device often times out and needs to be retried several times. This drains the CR2032 batteries.

In the end I decided to flash ATC firmware and now use a different script which simply picks up the data from the bluetooth advertisements. Way simpler and more reliable.