Component scd4x.sensor is marked FAILED

Hello everyone, I don’t know since when, but my configuration of the ESP8266 via ESPHome has stopped working. I have now also tried it with an ESP32 - same error. I then replaced the sensor with a new one. Didn’t help either, but it is unlikely that the new sensor is also defective.
Can you help me?

Here is my code:

substitutions:
  devicename: Airquality03
  update_interval_s: "60s"
  update_interval_wifi: "120s"
  temperature_calibration: "0.0"
  humidity_calibration: "0.0"

esphome:
  name: airquality03
  comment: 13-Luftqualitätsmesser 3 + Co2

esp8266:
  board: d1_mini

# Enable logging
logger:
# Enable Home Assistant API
api:
  encryption:
    key: "s...="
# Example configuration entry
ota:
  - platform: esphome
    password: "6...7"

wifi:
  networks:
   - ssid: !secret iot_wifi_ssid
     password: !secret iot_wifi_password
  fast_connect: true
  power_save_mode: none
  # Optional manual IP
  manual_ip:
    static_ip: 1.2.3.4
    gateway: 1.2.3.1
    subnet: 255.255.255.0
    dns1: 1.2.3.1
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${devicename}"
    password: "D...2"

time:
  - platform: homeassistant
    timezone: Europe/Amsterdam
    id: current_time
    on_time_sync:
      - component.update: uptime_timestamp

i2c:
  sda: D4
  scl: D5
  scan: true
  id: bus_a

sensor:
  - platform: scd4x
    id: scd41
    i2c_id: bus_a
    address: 0x62
    altitude_compensation: 123m
    measurement_mode: low_power_periodic
    automatic_self_calibration: true
    co2:
      name: "CO2"
      id: "co2"
    temperature:
      name: "Temperature ${devicename}"
      filters:
        - lambda: return x + ${temperature_calibration};
      id: "temperature"
    humidity:
      name: "Humidity ${devicename}"
      filters:
        - lambda: return x + ${humidity_calibration};
      id: "humidity"
    update_interval: ${update_interval_s}

  - platform: wifi_signal
    name: "${devicename} WiFi Signal"
    update_interval: ${update_interval_wifi}
#################################################################    
  - platform: uptime
    name: "${devicename} Uptime Sec"
    id: uptime_sec
    internal: true

  - platform: uptime
    name: "${devicename} Uptime Sensor"
    id: ${devicename}_uptime_raw
    update_interval: ${update_interval_s}
    icon: mdi:clock-start
    on_raw_value:
      then:
        - logger.log:
            format: "Raw Value of Uptime sensor: %f"
            args: ['id(${devicename}_uptime_raw).raw_state']
            level: INFO
        - text_sensor.template.publish:
            id: ${devicename}_uptime
            state: !lambda |-
              int seconds = round(id(${devicename}_uptime_raw).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;
              if ( days ) {
                return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
              } else if ( hours ) {
                return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
              } else if ( minutes ) {
                return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
              } else {
                return { (String(seconds) +"s").c_str() };
              }
  - platform: template
    id: uptime_timestamp
    name: "${devicename} Uptime"
    device_class: "timestamp"
    accuracy_decimals: 0
    update_interval: never
    lambda: |-
      static float timestamp = (
        id(current_time).utcnow().timestamp - id(uptime_sec).state
      );
      return timestamp;
      
text_sensor:
  - platform: template
    name: ${devicename} Uptime
    id: ${devicename}_uptime
    icon: mdi:clock-start
#################################################################

Here is the log file (shortened):

[18:02:00][C][scd4x:094]: scd4x:
[18:02:00][C][scd4x:095]:   Address: 0x62
[18:02:00][W][scd4x:099]: Communication failed! Is the sensor connected?
[18:02:00][C][scd4x:112]:   Automatic self calibration: ON
[18:02:00][C][scd4x:121]:   Ambient pressure compensation disabled
[18:02:00][C][scd4x:122]:   Altitude compensation: 418m
[18:02:00][C][scd4x:130]:   Measurement mode: low power periodic (30s)
[18:02:00][C][scd4x:139]:   Temperature offset: 4.00 °C
[18:02:00][C][scd4x:140]:   Update Interval: 60.0s
[18:02:00][C][scd4x:141]:   CO2 'CO2'
[18:02:00][C][scd4x:141]:     Device Class: 'carbon_dioxide'
[18:02:00][C][scd4x:141]:     State Class: 'measurement'
[18:02:00][C][scd4x:141]:     Unit of Measurement: 'ppm'
[18:02:00][C][scd4x:141]:     Accuracy Decimals: 0
[18:02:00][C][scd4x:141]:     Icon: 'mdi:molecule-co2'
[18:02:00][C][scd4x:142]:   Temperature 'Temperature Airquality03'
[18:02:00][C][scd4x:142]:     Device Class: 'temperature'
[18:02:00][C][scd4x:142]:     State Class: 'measurement'
[18:02:00][C][scd4x:142]:     Unit of Measurement: '°C'
[18:02:00][C][scd4x:142]:     Accuracy Decimals: 2
[18:02:00][C][scd4x:142]:     Icon: 'mdi:thermometer'
[18:02:00][C][scd4x:143]:   Humidity 'Humidity Airquality03'
[18:02:00][C][scd4x:143]:     Device Class: 'humidity'
[18:02:00][C][scd4x:143]:     State Class: 'measurement'
[18:02:00][C][scd4x:143]:     Unit of Measurement: '%'
[18:02:00][C][scd4x:143]:     Accuracy Decimals: 2
[18:02:00][C][scd4x:143]:     Icon: 'mdi:water-percent'
[18:02:00][E][component:082]:   Component scd4x.sensor is marked FAILED

maybe you intended:

i2c:
  sda: GPIO4
  scl: GPIO5

(esp8266 I2C pins)

I’ve tried it. Nothing changed. Also Tried 4 and 5. Same result :frowning:
Bildschirmfoto 2025-01-20 um 20.35.23

But the Error in the Log is Gone:

[20:37:12][C][scd4x:094]: scd4x:
[20:37:12][C][scd4x:095]:   Address: 0x62
[20:37:12][C][scd4x:112]:   Automatic self calibration: ON
[20:37:12][C][scd4x:121]:   Ambient pressure compensation disabled
[20:37:12][C][scd4x:122]:   Altitude compensation: 418m
[20:37:12][C][scd4x:130]:   Measurement mode: low power periodic (30s)
[20:37:12][C][scd4x:139]:   Temperature offset: 4.00 °C
[20:37:12][C][scd4x:140]:   Update Interval: 60.0s
[20:37:12][C][scd4x:141]:   CO2 'CO2'
[20:37:12][C][scd4x:141]:     Device Class: 'carbon_dioxide'
[20:37:12][C][scd4x:141]:     State Class: 'measurement'
[20:37:12][C][scd4x:141]:     Unit of Measurement: 'ppm'
[20:37:12][C][scd4x:141]:     Accuracy Decimals: 0
[20:37:12][C][scd4x:141]:     Icon: 'mdi:molecule-co2'
[20:37:12][C][scd4x:142]:   Temperature 'Temperature Airquality03'
[20:37:12][C][scd4x:142]:     Device Class: 'temperature'
[20:37:12][C][scd4x:142]:     State Class: 'measurement'
[20:37:12][C][scd4x:142]:     Unit of Measurement: '°C'
[20:37:12][C][scd4x:142]:     Accuracy Decimals: 2
[20:37:12][C][scd4x:142]:     Icon: 'mdi:thermometer'
[20:37:12][C][scd4x:143]:   Humidity 'Humidity Airquality03'
[20:37:12][C][scd4x:143]:     Device Class: 'humidity'
[20:37:12][C][scd4x:143]:     State Class: 'measurement'
[20:37:12][C][scd4x:143]:     Unit of Measurement: '%'
[20:37:12][C][scd4x:143]:     Accuracy Decimals: 2
[20:37:12][C][scd4x:143]:     Icon: 'mdi:water-percent'

For sure something it change!
D4 is GPIO2 and D5 is GPIO14.
I don’t know where you have physically sensor connected though…
ps. observe the I2C scan on your log to start with…

Here is the log from the beginning:

INFO ESPHome 2024.12.4
INFO Reading configuration /config/esphome/airquality03.yaml...
INFO Starting log output from 10.10.41.13 using esphome API
INFO Successfully connected to airquality03 @ 10.10.41.13 in 0.011s
INFO Successful handshake with airquality03 @ 10.10.41.13 in 2.658s
[20:58:06][I][app:100]: ESPHome version 2024.12.4 compiled on Jan 20 2025, 20:32:43
[20:58:06][C][wifi:600]: WiFi:
[20:58:06][C][wifi:428]:   Local MAC: ...
[20:58:06][C][wifi:433]:   SSID: [redacted]
[20:58:06][C][wifi:436]:   IP Address: ...
[20:58:06][C][wifi:439]:   BSSID: [redacted]
[20:58:06][C][wifi:441]:   Hostname: 'airquality03'
[20:58:06][C][wifi:443]:   Signal strength: -39 dB ▂▄▆█
[20:58:06][C][wifi:447]:   Channel: 1
[20:58:06][C][wifi:448]:   Subnet: ...
[20:58:06][C][wifi:449]:   Gateway: ...
[20:58:06][C][wifi:450]:   DNS1: ...
[20:58:06][C][wifi:451]:   DNS2: 0.0.0.0
[20:58:06][C][logger:185]: Logger:
[20:58:06][C][logger:186]:   Level: DEBUG
[20:58:06][C][logger:188]:   Log Baud Rate: 115200
[20:58:06][C][logger:189]:   Hardware UART: UART0
[20:58:06][C][i2c.arduino:071]: I2C Bus:
[20:58:06][C][i2c.arduino:072]:   SDA Pin: GPIO4
[20:58:06][C][i2c.arduino:073]:   SCL Pin: GPIO5
[20:58:06][C][i2c.arduino:074]:   Frequency: 50000 Hz
[20:58:06][C][i2c.arduino:086]:   Recovery: bus successfully recovered
[20:58:06][I][i2c.arduino:096]: Results from i2c bus scan:
[20:58:06][I][i2c.arduino:102]: Found i2c device at address 0x62

And that’s my physical setup:

oh damn… i sondert D8 instead of GND

and it works.
oh boy, sorry ^^

1 Like

At least your I2C pins are correct… less resoldering :+1:

1 Like