Error while installing config file to esphome

Hi I’m new to HA and I have esp32 which connected to HA with esphome it was fine but I wanted to add a fan speed vis pulse counter I added a some code with the help of chatGPT and when trying to install the code it gives error like this

INFO ESPHome 2024.6.1
INFO Reading configuration /config/esphome/esp32.yaml...
ERROR Error while reading config: Invalid YAML syntax:

while parsing a block collection
  in "/config/esphome/esp32.yaml", line 21, column 3
expected <block end>, but found '?'
  in "/config/esphome/esp32.yaml", line 22, column 3

what can I do the yaml code is

esphome:
  name: esp32
  friendly_name: esp32

esp32:
  board: esp32dev
  framework:
    type: arduino

esp32_ble_tracker:
  
# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "C6DjitzRd+jL69UDVzf1HLWylW3Ll9tqsTjcyi6oevk="

ota:
  - platform: esphome
  safe_mode: true
  password: "63bbbcceb4ee9f51f22133e05973b2e2"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32 Fallback Hotspot"
    password: "uG9oitEfhffe"

captive_portal:
    
sensor:
  - platform: atc_mithermometer
    mac_address: "A4:C1:38:5F:B8:F3"
    temperature:
      name: "ATC Temperature"
    humidity:
      name: "ATC Humidity"
    battery_level:
      name: "ATC Battery-Level"
    battery_voltage:
      name: "ATC Battery-Voltage"
    signal_strength:
      name: "ATC Signal"
  - platform: pulse_counter
    pin: GPIO16  # Change this to the GPIO pin you're using
    name: "Fan Speed"
    unit_of_measurement: "rpm"
    icon: "mdi:fan"
    update_interval: 60s
    filters:
      - multiply: 0.5  # Adjust this value based on your fan's tachometer specifications
    count_mode:
      rising_edge: true
      falling_edge: false

should be:

ota:
  - platform: esphome
    password: "63bbbcceb4ee9f51f22133e05973b2e2"

safe_mode:

See the changelog for the very recent changes to this bit of the config.

Poor idea, as the robot doesn’t know about recent breaking changes: although in this case it’s probably your fault as it’s a basic YAML formatting error.

Use the ESPHome editor, and it’ll highlight the issues and suggest fixes.