BLE Tracker (Xiaomi MiFlora) and "too big" firmware

Hi all and @OttoWinter

I am playing with and ESP32 with 4MB flash memory and loading it with EspHome generated firmware with usual stuff:

  • Status
  • Wifi signal
  • Restart switch
  • Led Light
  • OTA
  • api
  • logger

plus

  • rc_receiver
  • some template binary sensors (10/12)

on the top of this if I add:

  • BLE tracker
  • 2xMiFlora sensors

this creates a firmware which fill @ 92% flash and in that condition:

  • OTA doesn’t work
  • ESP becomes irresponsive and continuously drops wifi connection

is it an expected behavior?

this creates a firmware which fill @ 92% flash and in that condition:

The program size doesn’t have to do with those other parts you mentioned. This rather looks like a case of Problems with esp32_ble_tracker an Xiaomi CGG1 · Issue #735 · esphome/issues · GitHub. Please try different scan settings (see esp32_ble_tracker page, scan_parameters).

Hi,

thanks for your answer.
So I went through the documented issue if I understood correctly to stabilize WiFi I should lower scan parameters:

looking at this

window should be smaller then interval hence should i test something like 250/200?

tested on another unit: confirmed BLE make it problematic (very unstable wifi, etc…)
tried 250/200 with no luck: I will wait for a bit more direction before testing further

looking here:

by my poor understanding it seems window and interval are set the same?
Apparently OMG works fine: can we take those values?

Hi, the (new) defaults are 320ms for interval and 200ms window.
Seems OpenMQTTGateway uses 160ms/160ms.
I faced wifi issues with lower values so as described in the issues…
So with 160ms/160ms it works for you, did I understand that correctly?

I will do more test this evening or tomorrow.
By the way I have also this symptoms:

hence I think it is the same problem.
For reference I see old defaults where:

interval: 512 ms
window: 48 ms

so I will try starting from that.
In the meanwhile I can report disabling BLE makes WiFi and ESP stable again

I have a question in the meanwhile: for an application like MiFlora where you don’t care about “fast response” like presence detection is there any downside to go to something like

interval: 4000 ms
window: 40 ms

as far as I understand on ESP32 same HW/Antenna is shared by WiFi and BLE hence more you congestion BLE less you leave to WiFi.
Is that correct?

I just can tell from my own experience where I had troubles getting the messages from the Xiaomi devices when the window was less than 2/3 or 1/2 of the interval.
That‘s why I initiated the issue which resulted in the new default values after some testing.
For me the new default values work for several weeks now, devices run stable, at least controlling work when I need it and I get constantly values from the sensors, I don‘t see any disconnects.

So a bit more from my side although I had little time to play with it.

I removed the BLE component from the firmware and I can definitely confirm that without it my Esp32 is perfectly stable for days (no disconnections, signal is -45dB).

i tried something like:

interval: 1000 ms
window: 50 ms

but still unstable.
I have to say I had, with previous versione of EspHome (1.13.6), BLE enabled on 2 devices and these were not really table as well.

Could it be something else not related to interval / window?

it seems also OMG faced this issue:

further info here:

maybe @1technophile can provide info/confirmation?

Hello,

Did you try with 100/100ms as scan interval and windows (current OMG parameters)?

so i tried with these parameters:

esp32_ble_tracker:
  scan_parameters:
    duration: 100s #300s
    interval: 160ms #512ms
    window: 160ms #320m

worked for a while but then I started to have this:


with signal being always good as you can see

Now I installed EspHome 1.14.3 and trying default settings

When I turn on esp32_ble_tracker in the default config it crashes my 2.4GHz and I need to restart my router (and disconnect the nodemcu)

I’m hoping tweaking w/the interval & window will make make things better

@mspinolo Sounds like 160/160 is working and WiFi is stable?
whats the min interval/window periods?

No it is not: it was for a while after flashing but then get usual disconnection pattern.

I am trying now different settings but no success so far

Thanks for sharing. What’s your router make/model?

synology RT2600AC + MR2200AC in mesh config, why?

Also using AC2600 by ASUS. Previously issue discussed/confirmed only on ASUS routers (Xiaomi BLE Temperature and Humidity sensor)

I have a sinology, not an Asus

Right, up now the ASUS router was suspect while I always had a hunch it was the esp32 messing up the 2.4GHz band

Hi @mspinolo

Does the OTA work on your’s ESP32 now? What parameter using for “scan_parameters” section.
My ESP32 connect to Google WiFi and OTA does’n work when enable “esp32_ble_tracker”

Hi,

I had ESP with BLE tracker enabled on which I can do OTA: I suggest to use 1.15 beta version which maximize compatibility for what I understood.