If you run a unifi access point and your ESP32s keep going offline

… despite the ESP’s still remaining connected to the AP, try this. In your AP controller (wireless networks setting) you will probably have your Minimum Data Rate Control setting on auto. I’ve been struggling with this availability issue (note - this is only if you use BLE on your ESP otherwise I had no issues) for a week now. Previously all was ok.

I turned the setting off and set it to the minimum and as you’d expect many devices won’t like this and start complaining. But then I set it back to auto after that and everything went back to normal - ESPs always show as online now.

I have no idea why - perhaps some corruption on the actual settings that was cleared by doing this. Anyway try this to see if it might work for you.

2 Likes

Update: Setting data rate control to auto is probably not appropriate. Eventually my ESPs went offline again which was cured by another reset of the setting. I suspect the auto setting is at fault so now I’ve set it to a fixed 11Mbps, so far so good.

1 Like

ESP32 can not use BLE and WIFI at the same time, so what it does is switch between them.
So maybe it does not like that the WIFI appears to be unstable.
I use a unifi AP all on default settings, sure it’s an old one with only 2.4Ghz and only in use for IoT things (20 clients connected). I have not notice any issues.

I have BLE on a few of the ESP32.
What I do have on my ESPhome yaml is that I use

wifi:
  fast_connect: true

This will speed up the connection. And for me is needed as my IoT network is not broadcasting the ssid.

1 Like

I had previously tried this yaml setting without success. In fact I have tried all possible yaml settings with zero success.

Your unifi AP must be pretty old not to have AC support so the default data rate control settings for your AP may not be the same as for mine (AC Pro) or may not even exist or have an auto mode.

I have no idea how the auto setting works in the unifi controller (latest version 7.3) but I suspect this to be the the reason for the wifi being “unstable” as you say. If I don’t report further you can assume all to be well :grinning:

mine started dropping again over the past few days, so i’ve tried your fix here…i set it to 11mbps on my 2.4g network, and it worked relatively well but still dropped once overnight. now i have it set to 12mbps, we’ll see if that does any better. either way, it does seem much more stable (knock on wood, i’ve been down this road before making changes that seem to work and then blow up a few days later)…

I feel you. I also just remembered, I’m still on 2022.11.x of ESPhome. It was reported on github that 2023 versions seem to cause problems so for now I’ve held off updating.

In any case 20 days and no dropoffs so in my case, I think it’s safe to say it’s sorted. Hopefully you get yours sorted too.

1 Like

so far so good using 12mbps. no drops in about the past 48 hours or so.

i was just thinking of updating too, i’m still on 2022.12.3. i run HA in a proxmox VM, so i always take a snapshot before updating so i can easily roll back if i need to. maybe i’ll do that tonight if i get a few minutes free…

1 Like

Where are you adding the data rate in the yaml config of your esphome node?

we’re not, it’s in the unifi settings.

settings > wifi > select a wifi network, it’s about 2/3 of the way down the page…

1 Like

i’m still getting occasional drops (by occasional i mean one every 2-3 days or so). definitely preferable to what i was seeing previously where it was dropping literally every 2-3 minutes, but i’d still like to figure out a way to knock out even those occasional drops if possible.

what do your wifi settings on the ESP look like?

Just the ssid/password. IP is static via the router not in the yaml. I’m assuming you are using BLE (otherwise you should not be getting any dopouts) then the recommended setting for presence tracking probably isn’t appropriate (interval = window) due to the time slicing of the wifi/BT chip. This is what I use to still give a decent detection time.

esp32_ble_tracker:
scan_parameters:
interval: 600ms
window: 400ms
duration: 30s
active: true

1 Like

this is probably the part that I’m missing. I will double check those times.

I’ve started having it drop off once or twice a day pretty regularly… still way better than it was, but hopefully this will clean it up. I’m using BLE but only for temp sensors at the moment. still working on getting espresence working.

edit: I actually don’t have anything in the BLE settings at the moment, so it’s just using the default for everything.

i think i’ve got it now…i turned off active scanning. now it has been on without a single drop for about 4 days.

Mine used to always drop, but then I set the channel and transmission power, rather than auto. HT 20 (width)
Seems to have been fine in my flat with lots of noisey WiFi

Yeah. No one knows what auto power does, I read that it generally means max power for these APs so no surprises that it can cause issues.

May I suggest checking the “Multicast Enhancement” setting as well (Wifi → SSID → Advanced) - this frigging setting keeps turning ON at random intervals (firmware or controller updates) causing all kinds of issues with ESPhome, printers and sonos devices. I fight to keep it OFF.

after two weeks or so of being rock solid, i’m back to dropping off the network every few hours. this is so insanely frustrating…i don’t know what to do at this point.

THIS! I already fixed the Multicast Management problem. It was the last place I thought to look. Thanks for the heads up!

fast_connect: true

Just wanted to say thank you for this tip. Just enacted this and suddenly all my ESP devices started becoming more stable. THANK YOU.

2 Likes

Did you ever get this sorted out? My ESPHome and Tasmota esp32 devices disconnect and reconnect from Unifi 6 Enterprise APs all the time multiple times a day. I am going to try the minimum data rate control setting to 11 or 12Mbps.