ESP-01 cannot connect to WiFi with SSID that contains space character?

I met strange situation. I have two devices, one is ESP-01 and other is Sonoff Basic R2.

Both set to connect to the same AP named S-2 (PR). No I did not think of that SSID.

Sonoff Basic R2 connected instantly.

ESP-01 did not want to connect. It finally connected after SSID is changed not to have space in it.

Configuration

wifi:
  id: wifi_connection

  networks:
    - ssid: !secret wifi_ssid
      password: !secret wifi_password
    - ssid: !secret wifi_ssid_bz2
      password: !secret wifi_password_bz2


  ap:
    ssid: $descriptive_devicename

sectrets.yaml:

wifi_ssid: "DNET"
wifi_password: "kelw83e"

wifi_ssid_bz2: "S2 (PR)"
wifi_password_bz2: "nexp3nw"

Both configured and compiled and flashed at the same place.

I found out some claims that ESP-01 has issues with spaces character in SSID name. But why Sonoff Basic R2 does not?

Can you back this claim? What do the serial logs tell you/us?

All I can say is that ESP-01 lists all WiFi he sees and does not recognize that one he is supposed to connect to is on the list. It just skips and rescans again. I could not save logs, it is remote location with very limited options to work on it.

I tried with two different access points, both having space in SSID. Once space is removed, ESP-01 connects when set to new SSID.

Claims that ESP-01 cannot connect to WiFi with space in SSID I found later, trying to find how to overcome this problem.

But, as changing SSID for these APs is not an option (it is not up to me) I had do give up using this device until I find some other way.

Did you try to use the BSSID instead to connect to this particular wifi AP?

# Example configuration entry
wifi:
  networks:
  - bssid: AA:BB:CC:DD:EE:FF
    password: VeryUnsafePassword

No. As I sad it’s remote location. I had no means to run ESPHome to reprogram on the site.

You could run esphome locally on your notebook if you are onsite, for example via a pip or docker. You probably also could just make a “dry run” at home to see it if makes any difference at all :bulb: