erdose / xiaomi-mi-lywsd03mmc

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

Failed to connect to peripheral (intermitent) #11

Open henrybcn opened 3 years ago

henrybcn commented 3 years ago

Hi, very nice work done! ;) It is working, but many times I get the error "Failed to connect to peripheral"

I have the sensor close to the raspberry and here is part of the log:

2021-08-16 14:25:12 INFO TH_IDX:23 2021-08-16 14:25:18 INFO Temp: 28.8 2021-08-16 14:25:18 INFO Hum: 66 2021-08-16 14:25:18 INFO Voltage: 2.837 2021-08-16 14:25:18 INFO Battery level: 74 2021-08-16 14:25:18 INFO Comfort type: 1 2021-08-16 14:25:18 INFO The request is http://192.168.0.157:8080/json.htm?type=command&param=udevice&idx=23&nvalue=0&svalue=28.8;66;1&battery=74 2021-08-16 14:25:18 INFO The response is <Response [200]> 2021-08-16 14:30:02 INFO 2021-08-16 14:30:02 INFO Start script... 2021-08-16 14:30:02 INFO Input parameters: Domoticz Server IP: 192.168.0.157 Domoticz Server Port: 8080 Domoticz Server User: Domoticz Server Password: 2021-08-16 14:30:12 INFO TH_IDX:23 2021-08-16 14:30:19 ERROR Failed to connect to peripheral A4:C1:38:1D:69:41, addr type: public 2021-08-16 14:35:02 INFO 2021-08-16 14:35:02 INFO Start script... 2021-08-16 14:35:02 INFO Input parameters: Domoticz Server IP: 192.168.0.157 Domoticz Server Port: 8080 Domoticz Server User: Domoticz Server Password: 2021-08-16 14:35:12 INFO TH_IDX:23 2021-08-16 14:35:23 INFO Temp: 28.72 2021-08-16 14:35:23 INFO Hum: 66 2021-08-16 14:35:23 INFO Voltage: 2.837 2021-08-16 14:35:23 INFO Battery level: 74 2021-08-16 14:35:23 INFO Comfort type: 1 2021-08-16 14:35:23 INFO The request is http://192.168.0.157:8080/json.htm?type=command&param=udevice&idx=23&nvalue=0&svalue=28.72;66;1&battery=74 2021-08-16 14:35:23 INFO The response is <Response [200]>

When I "sudo hcitool lescan", I get the sensor without any issue. Any clue what can be wrong? Rgds, Henry

erdose commented 2 years ago

Sorry for my late answer! Sometimes it happens if the device is too far from the Raspberry. I use a Raspberry PI Zero as a data collector near to the sensors and it sends the request to the Domoticz (Raspberry PI 4) through WIFI.