Can't change the wifi settings on ESPHome

Hello.

I have a ESP32 I am trying to use with ESPHome, I have a SSID just for IOT device, the ESP32 could connect to it but home assistant could not reach it (and me neither) so I wanted to try to connect it to another SSID one (the one where my laptop is) by changing the ssid name and password in the “Secrets” par of the web interface, and then reflash it, no luck it’s still connecting to the old SSID.
I tried to hardcode the ssid info in the device yaml configuration directly, same issue after installing it.
There is literally no mention of the old SSID anywhere else in the conf and it still keep flashing the ESP32 with this old SSID, I don’t know what else I can try ?
I also tried to delete the device in ESPHome and recreate it, restart ESPhome server, same issue in both case.

The device config

esphome:
  name: office-air-quality-sensor

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "xxx"

wifi:
  ssid: !secret wifi_ssid # Tried to hardcode them here
  password: !secret wifi_password # Content of the secrets file is correct and pointing to the new SSID

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Office-Air-Quality-Sensor"
    password: "xxx"

captive_portal:


web_server:
  port: 80
    
status_led:
  pin: GPIO2

i2c: {}

sensor:
  - platform: sgp30
    eco2:
      name: "office_co2"
      accuracy_decimals: 1
    tvoc:
      name: "office_tvoc"
      accuracy_decimals: 1

Thank you

How are you flashing? Ota or wired?

Wired via WebSerial as home assistant cannot connect to it for an unknown reason

Try deleting all flash data on the esp32. esptool will do this.

Check if you are using gpio12 somewhere

Gpio12 prevent flash write

They’re not using it, according to the config included above.

Thanks

After running a esptool.py erase_flash it’s working, is it expected that I can’t change wifi parameters without erasing everything ? Are there others things that cannot be changed without erasing ?

No, it’s not normal. I’ve changed SSIDs a number of times without issue.

I just tried to put back the old SSID after fixing the issue on it.
Same issue, but this time even after the erase_flash it won’t connect to the proper SSID.

I have tried to to a manual flash by downloading the generated firmware, I see the correct SSID when I check the strings inside (but I don’t know the full command to use it to flash it).

But when flashing on the web interface it doesn’t change it, like on the first times

Also when flashing the firmware via https://web.esphome.io/ it’s working fine. looks like some caching issue on the esphome home assistant side ?

You can use the “reload” integration option.