ESP32: Only 1-2m Wifi range when running outside `esphome run`

Hej, I noticed that the reason Auth expired on Wifi connection failure is a common problem. I have tried lots of things by now but couldn’t get my ESP to connect reliably. Let me start with the pretty minimal config I use for testing by now:

esphome:
  name: jupiter

  esp32:
    board: az-delivery-devkit-v4
    framework:
      type: arduino

  logger:
    level: debug
    #level: verbose

  # Enable Home Assistant API
  api:
    password: !secret ota-password

  ota:
    password: !secret ota-password

  wifi:
    ssid: !secret wifi-ssid
    password: !secret wifi-password
    fast_connect: true
    power_save_mode: none
    output_power: 20dB

This is running on an AZDelivery ESP32-WROOM-32 dev board with a PCB antenna. No other peripherals connected atm. Should be simple enough, right?

The ESP connects to my Wifi perfectly if I run it via esphome run and have the ESP connected via USB.

It will not connect to Wifi when I power the ESP from different external power supplies and using different USB cables (which have been proven known good for data transfer otherwise). I see it disconnect with reason='Auth Expired' in this setup - except if I place it within 1-2 meters of my main Wifi AP or mesh extenders/repeaters. (They don’t technically repeat…) The AP and repeaters are AVM Fritz products.

So it looks like the Wifi range of the ESP is very limited if it is not connected to and communicating with my computer. But why?

What I’ve tried so far:

  • Another ESP32, same model
  • Erasing the ESP’s flash and re-flashing
  • Increasing the i2c frequency (found in some thread on Auth Expired issues); I don’t use i2c peripherals
  • Potentially power-related Wifi settings in ESPHome (in above config)
  • Setting the Wifi to 2,4 GHz channel 5 manually instead of auto-selected channel 1 at that time
  • Setting the Wifi to 802.11b+g+n instead of 802.11g+n
  • different power supplies and USB cables

None of that helped.

The next thing I had on my list is looking for a proper external antenna, but the Internet claimed somewhere that the PCB antenna should be fine for several meters at least, assuming other people don’t live in faraday cages…

I’m doing my best not to sound frustrated, but what else could I do? I’d rather not modify the antenna setup on my dev kit if I can help it.

I have devices 10m away from the nearest mesh node on the other side of a steel wall, they operate fine…

Maybe try powering via the 3.3V or 5V pins and see if that makes a difference?

Apart from static ip and fast connect for my deep sleep devices, I have never had to fiddle with wi-fi settings.

I have had some boards with dodgy wifi though, specifically a brand of battery powered ESP32-Cams that wouldn’t connect when powered by USB.

I use the RSSI sensor to monitor those nodes sitting on the edge of possibillity

sensor:
  - platform: wifi_signal
    name: "WiFi Signal Sensor"
    update_interval: 60s

Which gives me


That Tub Pit node gave me problems at 90dBm but slightly altering the Wi-Fi AP position allowed me to make it rock solid!

Just a few days ago i experienced my first “auth expired” situation. It was nothing more than ESP-01, 5-to-3.3V linear regulator (1117) and a couple of resistors (interface for Mitsubishi climate). Esp didn’t connect to Wi-Fi at all, constantly resetting Wi-Fi adapter. It turned out that I’ve had esp01 squeezed in a (too) small box, too close with Rx/Tx/+5V/GND wires, basically touching pcb, although isolated caused disturbances. When i moved wires only a few mm away it immediately connected.
So, check if Wi-Fi antenna part of esp module is clear of obstructions. Note that pcb antenna is pretty small, so it doesn’t take much to block it. A wire can quickly act like Faraday cage.

That’s an interesting graph for comparison. When I run the ESP from my computer, it gets -47 dBm, so the signal should be strong enough in my book. In the exact same location powered from the same computer, just without reading logs, it fails to connect.

During my last experiments I was literally holding the naked ESP board up in the air, no obstructions.

By now I wonder if the ESP maybe doesn’t actually use the PCB antenna, if that is configurable at all. Also that’s somewhat unlikely because two ESPs expose the same behavior…

I had that setup when the ESP was still on my hand-soldered drilled board (Not sure if that’s the correct term), but except a bit of +5V and GND distribution there weren’t any other electronic components mounted to it.

It IS on some boards… near antenna check if there’s any micro resistor, there are two positions (if exists): one for pcb antenna, other for connector - which may or may not be present, so if it’s not that (zero ohm) resistor might be missing/damaged.

Ah, too bad. My ESP looks like this:

The antenna is in the black PCB on the bottom. It doesn’t look like I can easily connect something bigger there. Also they usually don’t need a bigger antenna for home use, I’d love to understand what is missing and why when it is running from a plain power supply.

Any luck with esp-idf framework? Worth a shot.

Have you tried with your best quality power supply and cables you have on hand (from your phone etc). I see you said you’ve tried others. But it does smell possibly a bit “power supply-ish”.

1 Like

The only time to consider using external antenna for a home situation is you’re property is massive and you have dead zones or you are using a metal enclosure so you need an antenna to poke out of it. I’ve never seen or heard of people getting a very significant improvement with an external antenna either and that kind of explains why you don’t see them used much. Is it just the wifi connection or is the whole board browning out? Are you powering it via one of the pins or the USB port?

Folks, it is working! Thanks to all of you for your suggestions, this has kept my mind spinning for the last days.

In the end, the first impression was correct: It was lacking power. The solution was unexpected though. After @Mahko_Mahko’s repeated suggestion to try the highest quality power supplies I have I did another testing round:

  • an old-ish Apple iPad charger (15W)
  • a new-ish Anker PSU with USB-A and USB-C
  • an Ikea USB charger I got with the motorized blinds
  • a roughly decade-old 5V 1A USB-A PSU made by Hama

…and what worked in the end? The Hama one. The one I just picked because “oh why not, let’s try everything”. Maybe it is dumb enough to just supply power and not care about USB protocol? No idea. I’d really like to understand, but for now I’m just happy it works.

2 Likes

Well, esp32 module can draw well over 1A in spikes. When I’m doing tests i have it connected to a lab power supply and if i have current limit set under 1A then “current limit LED” often blinks, so generally set it to around 2A.
So: 500mA USB power supply is not enough, it must be at least 1A. And an additional quality electrolytic capacitor (say 1000uF or even more) soldered to power supply lines helps, too.
But then again…it’s not just current capability, but also quality of power supply. It’s switching type, so it can produce quite some noise and unwanted spikes, which can disturb Wi-Fi. an oscilloscope (or advanced usb tester like FNIRSI) would show quality of USB adapter.

2 Likes

A lot of people make the same mistake, myself included. Unfortunately you just cant trust this cheap chinese stuff thats everywhere. How smooth the output is, whether it meets the specs printed on it. You just cant ever be sure.

Esp boards are really sensitive to having a stable power supply. You may have tested it on another device and it powered it up. That alone doesnt mean its good. The test device likely isnt as sensitive to a rippled or unstable power supply and it deceives you into thinking its not the PSU.

If you’re having non code related issues or wifi dropping out, which is super common. 9 times out of 10 wifi disconnects or signal issues, its the PSU. Its always, always, always the PSU and second its the regulator on the esp board

1 Like