No wifi connection wenn switch on

Hello

I have a problem with my esphome configuration I made a water level sensor with an ultrasonic sensor and a low level sensor. as soon as my level sensor is on and esp as to be reboot, it will not connect to the wifi.

If I disconect my level sensor and reboot, everything works fine.

I do not understand why

substitutions:
  system_name: cuve_4000l
  friendly_name: Cuve 4000l

esphome:
  name: ${system_name}
  platform: ESP8266
  board: d1_mini


wifi:
  ssid: !secret iot_wifi_ssid
  password: !secret iot_wifi_pwd

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: ${friendly_name}
    password: !secret iot_wifi_callback

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: !secret iot_ota_pwd

ota:
  password: !secret iot_ota_pwd


dallas:
  - pin: D5
    update_interval: 120s


    
switch:

binary_sensor:
  - platform: gpio
    pin:
      number: D8
      mode: INPUT_PULLUP
      inverted: false
    name: "Niveau bas ${friendly_name}"
    id: niveau_bas_${system_name}
    device_class: moisture

      
sensor:
  - platform: dallas
    address: 0x813C01D607F6A228
    name: "Température ${friendly_name}"
  

  - platform: ultrasonic
    trigger_pin: D2
    echo_pin: D1
    name: "Niveau cuve 4000l"
    id: niveau_cuve_4000
    update_interval: 60s
    unit_of_measurement: "%"
    accuracy_decimals: 0
    filters:
      - calibrate_linear:
          # Measured value of 0 maps to 0A
          - 1.09 -> 0
          - 0.09 -> 100.0

  - platform: wifi_signal
    name: "${friendly_name} signal wifi"
    update_interval: 30s

  
  - platform: uptime
    #name: "${friendly_name} uptime"
    update_interval: 300s
    id: uptime_sensor
    on_raw_value:
      then:
        - text_sensor.template.publish:
            id: uptime_human
            state: !lambda |-
              int seconds = round(id(uptime_sensor).raw_state);
              int days = seconds / (24 * 3600);
              seconds = seconds % (24 * 3600);
              int hours = seconds / 3600;
              seconds = seconds % 3600;
              int minutes = seconds /  60;
              seconds = seconds % 60;
              return (
                (days ? String(days) + "d " : "") +
                (hours ? String(hours) + "h " : "") +
                (minutes ? String(minutes) + "m " : "") +
                (String(seconds) + "s")
              ).c_str();
  
text_sensor:
  - platform: template
    name: "${friendly_name} Uptime"
    id: uptime_human
    icon: mdi:clock-start
    
  - platform: version
    name: "${friendly_name} version"

Do you have any Idea ?

Thanks for your help

logs would help.

Are you using a 5V powered level sensor connected to the ESP (that uses 3.3V logic)?

No it is only a switch connected betwen ground and GPIO XX

Sorry I thought the ultrasonic sensor was the level sensor.

See the table lower down on this page: ESP8266 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials

In short, dont use pin D8. Boot fails if pulled HIGH.

Thanks I will try tomorow with pin D3 or D4