custom-components / ble_monitor

BLE monitor for passive BLE sensors
https://community.home-assistant.io/t/passive-ble-monitor-integration/
MIT License
1.89k stars 243 forks source link

The sensor does not update well when the RSSI is low #579

Closed andrewjswan closed 2 years ago

andrewjswan commented 2 years ago

The weather deteriorated and one sensor which is far away started to update its data very badly. The RSSI shows up to -95. As soon as the RSSI increases to -85, the sensor starts to update its values normally. Is this a problem with the sensor? Or maybe there are some limitations in the source code? Sensor: Xiaomi LYWSD03MMC

image image

And is it possible to round RSSI value, because some sensors show one decimal place. image

Thrilleratplay commented 2 years ago

@andrewjswan RSSI is an abbreviation of Received signal strength indication. A decrease in signal strength typically results in fewer data packets being received by Home Assistant. It does not necessarily mean there is an issue with the sensor nor the Bluetooth receiver; interference from other devices or physical objects can impede the signal. If there is a significant change without physically moving the transmitting sensor or Home Assistant receiver, investigate something that may have moved in that time frame or addition devices that use 2.4GHz frequency. Try to remove any interference found. The signal strength updating should tell you whether or not any change has made an impact.

andrewjswan commented 2 years ago

@Thrilleratplay Nothing has changed for me, neither the location of the HA, nor the location of the sensors. The rest of the sensors, about 20, work fine.

Magalex2x14 commented 2 years ago

@andrewjswan there are no RSSI related restrictions or filters in the integration. @Thrilleratplay said everything right about the RSSI indicator, we used to rely on it when assessing signal quality, but unfortunately it is not enough for an objective assessment. In electronics, there is such an important indicator as the signal-to-noise ratio (SNR), which indicates how much the useful signal is greater than the noise level in the air. For example, RSSI can be equal to -90 dBm, and the noise level can also be equal to -90 dBm - then it is very difficult to isolate a useful signal. Unfortunately, BLE messages do not contain information about the signal-to-noise ratio, so we have nothing to do but rely only on RSSI with some consideration for our own observations and experience in a particular situation.

I can only suggest temporarily placing the problem sensor next to another, and compare their RSSI indicator. If the problematic device has it much lower, then the problem is in the sensor. If not, then the problem should be looked for in the electromagnetic environment in the area where the problem device is located (for example, your neighbor installed a cheap faulty microwave owen behind the wall, and drives it often :)

Magalex2x14 commented 2 years ago

I see that the sensor is located on the loggia, that is, on the street. Perhaps the problem is related to the fact that it is not designed to work in such conditions (it has a low level of protection from external factors, low IP rating). What kind of device is it?

andrewjswan commented 2 years ago

@Magalex2x14 Why I asked this, because I found these lines in the documentation and maybe I misunderstood them. transmits 20-25 valuable BT LE messages (RSSI -75..-70 dBm). During the period = 60 (seconds), the component accumulates all these 20-25 messages, and after the 60 seconds expires, averages them and updates the sensor status in Home Assistant

This sensor is located outside, and it's been there for almost two years. The same sensor is on the other side of the house, and it works fine. Nothing has changed in the location, only the weather on the side of this sensor has gotten worse, wind in its direction, rain, ice.

The second sensor is outside: image The second sensor updates its value every 10 minutes, the first from 10 minutes to 2-3 hours, I have put next to him a few ble gateway, but it does not greatly improve the situation, although there is no dips of 4 hours or more. Next to HA is BT gateway for MiHome, there in MiHome data are updated quickly enough, no delays, with a direct connection, too, no problems.

Ernst79 commented 2 years ago

Just thinking, battery level might have decreased over these two years, reducing the signal strength? Perhaps replacing the battery will increase the signal strength. The BT gateway for MiHome might have a better antenna than your HA machine, which could explain the difference (e.g. the build in BT in a raspberry isn't the best BT interface you can find :-) ).

andrewjswan commented 2 years ago

The battery is new, changed about 3 months ago, I have HA on the NUC and 3 BLE gateways on the ESP32 are also connected. The nearest gateway is about 3 meters from the sensor. :)

andrewjswan commented 2 years ago

In MiHome BT Gateway ESP32 Inside :)

Thrilleratplay commented 2 years ago

@andrewjswan

only the weather on the side of this sensor has gotten worse, wind in its direction, rain, ice.

The Xiaomi LYWSD03MMC does not look like it is weather resistant. Perhaps with the weather changes, ice/moisture/dirt has build up inside the enclosure. If it is dry inside, move it inside. If you do not want to impact historical data, take out the battery. If possible, try to disassemble it and look for grime that has accumulated on the sensors, chips or contacts. As these are built down to a price, it may just be dying and need to be replaced without anything obvious wrong with it.

You have to keep in mind that even if you have not changed anything, change may have still happened. For the sake of argument, lets say this sensor was placed outside, the home is remote and left vacant so there is no interference from neighbors, traffic, cell phones, etc. The sensor is still subjected to weather changes (ice and moisture creep into the enclosure and can cause issues from ice breaking/loosening contacts to moisture allowing mold to grow), outdoor air (pollen or pollution can accumulate on the sensors or Bluetooth Transmitter), and time (these are cheaply made and not intended to remain outside). Even if you have others from the same manufacturing batch that work just find, it may be due to their location outside where direct sunlight is different. Even if all things are equal, it may come down to chance. Variations happen, it is why the RSSI changes for all of the devices. It isn't an answer, just an explanation.

andrewjswan commented 2 years ago

@Thrilleratplay Sensor in a hermetic box, withstands from -25C to +50C without problems. :)

The RSSI on this sensor was in the range -85+-5, now in the moments when it began to decrease, began to occur dips in the data. I began to investigate the cause. If it is degradation of the sensor, it is one thing, if it is a software problem it is another. On the gateway I see packets from the sensor, but there is no data update in HA. It remains to decrypt these packets and see if there are data updates, or is it just a BLE packet with no information.

Ernst79 commented 2 years ago

@andrewjswan You could further debug this by enabling the logger at debug level, This should show all advertisements, also the ones that do arrive in BLE monitor but do not contain (Xiaomi) BLE data advertisements.

andrewjswan commented 2 years ago

Now it is warmer, the RSSI is back to normal, and the sensor updates without problems, I put an additional ble gateway next to it. If there will be problems, I will enable debugging ...

Ernst79 commented 2 years ago

Ok, I'll close this issue then, feel free to reopen it if the issue comes back