ESP32-S3 Wifi sometimes working sometimes not / esp32-S3-DevkitC wifi problem [Solved]

Hello Hello !!
I am a beginner on Home Assitant and ESPHome, trying to make my first device to control a relay based on humidity measurement. I am facing a major issue trying to make the first step:
Connect my ESP32-S3 to wifi. I have went through everything I have found about that on internet for days now but still not able to make it. I will try to explain as precisely as I can the problem I encounter:

When I create a new device, I connect to my ESP32-S3 using USB cable using ESPHome Web (Web - ESPHome).

I click on ā€œPrepare for first useā€, proceed to install successfully, I then configure wi-fi.
And it works, I can even visit the device locally on 192.168.1.20)

I can see my esp32 being connected to my 2.4GHz wifi on my route; The IP has been automatically attributed via the DHCP:
Sans titre5

So it looks the ESP32 is well able to connect to my wifi using dynamic IP.

Now letā€™s install my yaml file (I continue to use ESPHome Web, so manually download the .bin file):


esphome:
  name: "esp32-vmc-controller"
  friendly_name: "vmc-controller"

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino

api:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ap:
    ssid: "ESP32-VMC-CONTROLLER-HOTSPOT"
    password: "password"

captive_portal:

logger:
  level: ERROR

ota:
  platform: esphome
  
improv_serial:

Again, the configuration is successfully installed:

So I have verified before installing my yaml configuration that the ESP32 is able to connect to the wifi, so it should be able to connect to my wifi now right ?

Well this is not what is happening, impossible to connect to ESP32.

I cannot connect anymore to my ESP32ā€¦

So I went through a lot of forum, it often recommends to provide a manual IP (it should not be needed as earlier I could connect using DHCP but well, letā€™s try). Letā€™s update the yaml file:

esphome:
  name: "esp32-vmc-controller"
  friendly_name: "vmc-controller"

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino

api:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.1.201
    gateway: 192.168.1.1
    subnet: 255.255.255.0
  ap:
    ssid: "ESP32-VMC-CONTROLLER-HOTSPOT"
    password: "password"

captive_portal:

logger:
  level: ERROR

ota:
  platform: esphome
  
improv_serial:

    
    

I install again successfully using ESPHome Web interface but it still doesnā€™t work.

Iā€™m having this problem for days now without being able to understand what Iā€™m doing wrong, I therefore come here with the hope of getting some support ! :grinning:

Please, tell me what Iā€™m doing wrong !

Note I have verified many many many times the SSID and the password of the Secrets are correct.

Please format your code correctly. No one can help you if thereā€™s an indentation error with the code as itā€™s currently displayed.

Also, double check your IPs. You first mention connecting successfully on 1.20, then when you say you canā€™t connect your manual IP code shows 1.201

Hello ! Sorry for the formating, itā€™s corrected now :slight_smile:
About the IP address, Iā€™m not that good (letā€™s say, not at all) with that kind of things but my understanding is that the manual IP (so 192.168.1.201) has to be out of the range of the DHCP server defined in my router (from 192.168.1.10 to 192.168.1.200)/
This is the reason why I have used 192.168.1.201.

firmware updates use the devices hostname. More than likely your network does not resolve the devices hostname to a correct IP.

add a use_address

domain (Optional, string): Set the domain of the node hostname used for uploading. For example, if itā€™s set to .local, all uploads will be sent to <HOSTNAME>.local. Defaults to .local.

Using DHCP on esphome devices just calls for problems. Change that to static IP first. And always use only static IPā€™s in all HA related devices, if you canā€™t set static IP to a certain device then reserve itā€™s IP in router.

Hello ! Thank you very much for your answers, I have tried to apply them (not sure I did properly but I think yes).

So I have re-done the ā€œprepare for first useā€ on my esp32 using esphome web so that I could see my esp32 on my modem. Once I saw it there, I have reserved the IP address it was using (192.168.1.20 here).

Once this done, I have also updated the yaml file as below, to add the domain (not sure if tmjpugh you were talking of use_address or domain, but Iā€™m not sure how to use the use_address and so what I should put in this field):

Note that I have updated the hostname to a simpler one without any dash or underscore, just in case.

esphome:
  name: vmc
  friendly_name: vmc

esp32:
  board: esp32-s3-devkitc-1

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  manual_ip:
    static_ip: 192.168.1.20  # Replace with an unused IP in your network
    gateway: 192.168.1.1      # Replace with your router's IP
    subnet: 255.255.255.0     # Typically this is correct for most home networks
  domain: .vmc.local

captive_portal:

logger:

api:
  encryption: 
    key: "Wh0n3sUY8JYAgTLvxqG+CuQgTc88FAcE2/tL3gQ8Xrk="

switch:
  - platform: gpio
    name: "Switch GPIO6"
    pin: GPIO6

Unfortunaly, it still doesnā€™t work.
Once I have uploaded the factory file using esphome, the esp32 is not able to connect to my modem/router:

Do you have any idea of something I could have badly implemented here ?
Again, many thanks for your help ! Even though I still donā€™t succeed, I have the feeling Iā€™m going in the right directionā€¦ hopefully :sweat_smile:

Delete the line with ā€œdomainā€ and try again

Exact same result

esphome:
  name: vmc
  friendly_name: vmc

esp32:
  board: esp32-s3-devkitc-1

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  manual_ip:
    static_ip: 192.168.1.20  # Replace with an unused IP in your network
    gateway: 192.168.1.1      # Replace with your router's IP
    subnet: 255.255.255.0     # Typically this is correct for most home networks

captive_portal:

logger:

api:
  encryption: 
    key: "Wh0n3sUY8JYAgTLvxqG+CuQgTc88FAcE2/tL3gQ8Xrk="

switch:
  - platform: gpio
    name: "Switch GPIO6"
    pin: GPIO6

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  manual_ip:
    static_ip: 192.168.1.20 
    gateway: 192.168.1.1    
    subnet: 255.255.255.0    
  domain: .vmc.local
  use_address: 192.168.1.20

Just tried that one too, with and without the domain, and it does not workā€¦ Always the same problem of ESP32 not connecting to wifi:

[21:27:33][D][wifi:697]: Retrying with hidden networksā€¦
[21:27:33][I][wifi:313]: WiFi Connecting to ā€˜Livebox-9200ā€™ā€¦
[21:27:34][W][wifi_esp32:545][arduino_events]: Event: Disconnected ssid=ā€˜Livebox-9200ā€™ bssid=AC:CF:7B:FF:92:00[redacted] reason=ā€˜Auth Expiredā€™ [21:27:34][W][wifi:653]: Error while connecting to network.
[21:27:34][D][wifi:697]: Retrying with hidden networksā€¦

Do you think buying another router than the one provided by my internet provider might be an easy way to fix this issue ?

Seems to be an issue with the board you use

Adding this might help


wifi:
  output_power: 8.5

IT WORKS !
The output_power: 8.5 fixed it ! :smiley:
Many thanks for your help !

Any recommandation in term of board I should use for next time that does not have this kind of problem ?

Glad to be of help.

No real suggestions, Iā€™m using esp32-pico d4 for most of my projects, two years ago those were quite cheap, so bought a few and still using them, no issues with those.
Anyway, your problem is solved.

1 Like

Wroom32 is always best choice if there are no special requirements.
Ps. mark your post solved.