Wierd I2C Issues

Recently purchased a Kincony KC868-A2 esp32 and have been developing the yaml code to run a climate controller.

I connected an SHT40 and AHT20 temperature sensors via the I2C interface. Everything was looking great, until I went into the logs and found below.

INFO ESPHome 2024.3.2
INFO Reading configuration /config/esphome/esp-a2-studio-climate.yaml...
INFO Starting log output from <REDACTED> using esphome API
INFO Successfully connected to esp-a2-studio-climate @ <REDACTED> in 0.002s
INFO Successful handshake with esp-a2-studio-climate @ <REDACTED> in 0.149s
[10:28:47][I][app:102]: ESPHome version 2024.3.2 compiled on Apr 14 2024, 11:10:09
[10:28:47][C][logger:166]: Logger:
[10:28:47][C][logger:167]:   Level: DEBUG
[10:28:47][C][logger:169]:   Log Baud Rate: 115200
[10:28:47][C][logger:170]:   Hardware UART: UART0
[10:28:47][C][i2c.arduino:059]: I2C Bus:
[10:28:47][C][i2c.arduino:060]:   SDA Pin: GPIO4
[10:28:47][C][i2c.arduino:061]:   SCL Pin: GPIO16
[10:28:47][C][i2c.arduino:062]:   Frequency: 50000 Hz
[10:28:47][C][i2c.arduino:065]:   Recovery: bus successfully recovered
[10:28:47][I][i2c.arduino:075]: Results from i2c bus scan:
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x08
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x09
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x0A
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x0B
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x0C
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x0D
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x0E
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x0F
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x10
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x11
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x12
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x13
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x14
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x15
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x16
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x17
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x18
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x19
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x1A
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x1B
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x1C
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x1D
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x1E
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x1F
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x20
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x21
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x22
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x23
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x24
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x25
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x26
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x27
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x28
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x29
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x2A
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x2B
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x2C
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x2D
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x2E
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x2F
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x30
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x31
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x32
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x33
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x34
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x35
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x36
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x37
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x38
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x39
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x3A
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x3B
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x3C
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x3D
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x3E
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x3F
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x40
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x41
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x42
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x43
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x44
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x45
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x46
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x47
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x48
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x49
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x4A
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x4B
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x4C
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x4D
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x4E
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x4F
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x50
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x51
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x52
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x53
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x54
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x55
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x56
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x57
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x58
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x59
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x5A
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x5B
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x5C
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x5D
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x5E
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x5F
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x60
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x61
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x62
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x63
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x64
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x65
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x66
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x67
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x68
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x69
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x6A
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x6B
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x6C
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x6D
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x6E
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x6F
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x70
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x71
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x72
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x73
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x74
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x75
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x76
[10:28:47][E][i2c.arduino:083]: Unknown error at address 0x77

When I find the above issues I restart the KC868-A2 and everything is ok for about 24 hours. After that I often see the error above?

The sensor wiring is nothing spectacular… just some short wires from the KC868-A2 I2C port and the two sensors connected. I have also replaced the entire wiring 3 times, so am confident my wiring is not at fault. Not sure if I2C requires shielded cable?

Here’s my yaml code…

esphome:
  name: esp-a2-studio-climate
  platform: esp32
  board: esp32dev
  on_boot:
  - delay: 2s
  - climate.control:
      id: daikin_ac
      mode: 'off'
  - logger.log: "Telling Air Conditioner to STOP"

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "<REDACTED>"

ota:
  password: "<REDACTED>"

ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO17_OUT
  phy_addr: 0

# Optional manual IP
  manual_ip:
    static_ip: <REDACTED>
    gateway: <REDACTED>
    subnet: 255.255.255.0

# MQTT Interface
mqtt:
  broker: !secret mqtt_broker_new
  username: !secret mqtt_login
  password: !secret mqtt_passwd
  port: 1883
  reboot_timeout: 0s
  keepalive: 60s
  discovery: false

i2c:
- id: bus_a
  sda: 4
  scl: 16
  scan: true

dallas:
  - pin: GPIO33
    update_interval: 30s

# IR TRansmitter entry
remote_transmitter:
  pin:
    number: 14
  id: infrared_transmit
  carrier_duty_percent: 50%

sensor:
  - platform: dallas
    address: 0x2d02131b3fdeaa28
    name: 'Test Outside Temperature'
    id: studio_dallas_out_temp
    resolution: 12
    filters:
    - sliding_window_moving_average:
        window_size: 10
        send_every: 3

  - platform: aht10
    variant: AHT20
    address: 0x38
    update_interval: 30s
    temperature:
      name: "AHT20 temp"
      id: studio_aht20_in_temp
      accuracy_decimals: 1
    humidity:
      name: "AHT20 humidity"
      id: studio_aht20_in_humidity
      accuracy_decimals: 1

  - platform: sht4x
    address: 0x44
    update_interval: 30s
    temperature:
      name: "SHT40 Outside Temperature"
      id: studio_sht40_out_temp
      accuracy_decimals: 1
    humidity:
      name: "SHT40 Outside Humidity"
      id: studio_sht40_out_humidity
      accuracy_decimals: 1

#Relay switches
switch:
  - platform: template
    id: do_cooling
    optimistic: true
  - platform: gpio
    pin: 
      number: 15
      ignore_strapping_warning: true
      inverted: false
    id: studio_damper_rly
    name: "Studio Damper Relay"
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: gpio
    pin: 
      number: 2
      ignore_strapping_warning: true
      inverted: false
    id: studio_fan_rly
    name: "Studio Fan Relay"
    restore_mode: RESTORE_DEFAULT_OFF

binary_sensor:
  - platform: template
    id: damper
    lambda: return (id(studio_sht40_out_temp).state < 18) && (id(studio_aht20_in_temp).state <= 24);
    on_press:
      - logger.log: "Telling Damper to OPEN"
      - switch.turn_on: studio_damper_rly
      - mqtt.publish:
          # remove test once confirmed working
          topic: test_HomeAssistant/Studio/Damper/Status
          payload: "OPEN"
    on_release:
      - logger.log: "Telling Damper to CLOSE"
      - switch.turn_off: studio_damper_rly
      - mqtt.publish:
          # remove test once confirmed working
          topic: test_HomeAssistant/Studio/Damper/Status
          payload: "CLOSED"
  - platform: copy
    id: damper_open
    source_id: damper
    filters:
      - delayed_on: 4sec
  - platform: template
    id: fan
    lambda: return id(do_cooling).state && id(damper_open).state;
    on_press:
      - logger.log: "Telling Fan to START"
      - switch.turn_on: studio_fan_rly
      - mqtt.publish:
          # remove test once confirmed working
          topic: test_HomeAssistant/Studio/Fan/Status
          payload: "OFF"
    on_release:
      - logger.log: "Telling Fan to STOP"
      - switch.turn_off: studio_fan_rly
      - mqtt.publish:
          # remove test once confirmed working
          topic: test_HomeAssistant/Studio/Fan/Status
          payload: "OFF"
  - platform: template
    id: ac
    lambda: "return (id(do_cooling).state && !id(damper).state);"
    on_press:
      - logger.log: "Telling Air Conditioner to START"
      - climate.control:
          id: daikin_ac
          mode: 'cool'
          fan_mode: AUTO
          target_temperature: 23 °C
    on_release:
      - logger.log: "Telling Air Conditioner to STOP"
      - climate.control:
          id: daikin_ac
          mode: 'off'

# Studio Climate Control
climate:
  - platform: daikin
    name: "Daikin Aircon"
    id: daikin_ac
    supports_heat: false
    transmitter_id: infrared_transmit

  - platform: thermostat
    name: "Fan Climate Control"
    sensor: studio_aht20_in_temp
    min_cooling_off_time: 120s
    min_cooling_run_time: 120s
    min_idle_time: 30s
    id: fan_climate_control
    cool_action:
      - switch.turn_on: do_cooling
      - logger.log: "The studio fan is ON"
    idle_action:
      - switch.turn_off: do_cooling
      - logger.log: "The studio fan is OFF"
    default_preset: Studio
    preset:
      - name: Studio
        default_target_temperature_high: 22 °C
        mode: COOL

Any suggestions appreciated. I will also reach out to the Kincony forum to see if there’s something I am missing?

Is there any reason you are not using the default pin out of 21 and 22? How long is wire carrying the i2c signal? They are only good for a few feet/couple of meters before you need to use a signal booster.

Hi Mike,

Thanks for replying. The i2c pins on the Kincony KC868-A2 are hard coded, see here which makes the choices limited.

I will explore a signal booster to see if that is the issue.

I use one of these at the esp for 15’/5 meter run.

Thanks again Mike. Was going to ask what you use for an extender. Much appreciated.

One other thing to check is the frequency range of the sensors. Slowing down the speed can improve distance. It could also be too fast. Use the frequency key for the i2c component, in the link in my first post.

How short?

It does not. However you should be careful with crosstalk between SCL and SDA. See my notes here: Outdoor Lux Sensor