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