Trouble Configuring SGP40 Sensor with ESPHome

Hello everyone,

I’m having trouble configuring an SGP40 sensor with ESPHome. I’ve copied the example configuration from the ESPHome documentation, but I keep getting an error message that says Platform not found: 'sensor.sgp4x'. I’ve double-checked the formatting and syntax of my configuration file and everything appears to be correct. I’ve also updated ESPHome to the latest version.

Has anyone else experienced this issue or have any suggestions on how to resolve it? Any help would be greatly appreciated.

Thank you!

esphome:
  name: test

esp8266:
  board: d1_mini

# Enable logging
#logger:

# Enable Home Assistant API
api:

ota:
  password: "*"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "test"
    password: "*"

captive_portal:

# Enables i2c
i2c:
  sda: 4
  scl: 5
  scan: true
  id: bus_a

sensor:

# SHT40

  - platform: sht4x
    temperature:
      name: "Temperature A"
      accuracy_decimals: 2
    humidity:
      name: "Humidity A"
      accuracy_decimals: 2
    address: 0x44
    update_interval: 30s

  - platform: sgp4x
    voc:
      name: "VOC Index A"
INFO Reading configuration /config/esphome/test.yaml...
Failed config

sensor.sgp4x: [source /config/esphome/test.yaml:69]
  
  Platform not found: 'sensor.sgp4x'.
  platform: sgp4x
  voc: 
    name: VOC Index

What version of esphome?

Home Assistant 2023.4.1
Supervisor 2023.04.0
Operating System 9.5
Frontend 20230406.1 - latest

None of those are an esphome version.

ESPHome
Current version: 2022.1.4

I’m gonna guess that platform just isn’t in that version, with it being so old. Try updating it and compile again (and don’t hesitate clicking the ‘clean build files’ button, that’s fixed countless issues for me with random compile errors).

What he said

The version I had (2022.1.4) couldn’t update, I installed the new version 2023.3.2, but it installed in parallel, I had two ESPHome in my add-ons (I didn’t expect that was possible), so I uninstalled the oldest one. The new version did recognize SGP40 successfully. I suppose I should have checked the Auto-Update flag…

You probably had the old esphome addon repository installed. Common issue.