[RESOLVED] First ESP gets sensor data, second one gets nothing

I managed to get a little display going with a D1 mini and thanks to the help on the forum it works amazingly well.

I’ve now tried to build a second one, source code almost identical, but there’s simply no HA sensor data going to it. If I look at the logs, I can see the blue reports of HA data arriving at ESP #1. If I look at ESP #2’s logs, there is no such data, and no errors either.

I’m probably missing something stupid, I’m still learning.

Any ideas how I can try to debug the issue? Herewith the code. There are some differences, I’m not sure how it happened but the one has an API key and the other (which is working fine) does NOT have an API key.

Device 1 (Working):

substitutions:
  name: "esphome-micro-display"
  friendly_name: ESPHome Micro Display

esphome:
  name: ${name}
  friendly_name: ${friendly_name}
  name_add_mac_suffix: false
  project:
    name: esphome.web
    version: '1.0'

esp8266:
  board: d1_mini

# Enable logging
logger:

# Enable Home Assistant API
api:

# Allow Over-The-Air updates
ota:

# Allow provisioning Wi-Fi via serial
improv_serial:

wifi:
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:

dashboard_import:
  package_import_url: github://esphome/example-configs/esphome-web/esp8266.yaml@main
  import_full_config: true

# To have a "next url" for improv serial
web_server:

# Example configuration entry
i2c:
  scl: D1
  sda: D2

#font:
#    # gfonts://family[@weight]
#  - file: "gfonts://Roboto"
#    id: roboto_20
#    size: 20

font:
  - file: "gfonts://B612 Mono"
    id: font_small
    size: 10
  - file: "gfonts://Reddit Mono"
    id: font_mono_medium
    size: 14

image:
  - file: "mdi:battery"
    id: img_batt
    resize: 14x14
  - file: "mdi:power-plug"
    id: img_load
    resize: 14x14
  - file: "images/dollar_red.png"
    id: img_grid
  - file: "mdi:arrow-down-bold"
    id: img_down
    resize: 14x14
  - file: "mdi:arrow-up-bold"
    id: img_up
    resize: 14x14

sensor:
  - platform: homeassistant
    id: sensor_soc
    entity_id: sensor.deye_sunsynk_sol_ark_battery_state_of_charge
    internal: true
  - platform: homeassistant
    id: sensor_load
    entity_id: sensor.deye_sunsynk_sol_ark_load_power
    internal: true
  - platform: homeassistant
    entity_id: sensor.deye_sunsynk_sol_ark_grid_power
    id: sensor_grid      
    internal: true
  - platform: homeassistant
    entity_id: sensor.deye_sunsynk_sol_ark_battery_power
    id: sensor_battery_power     
    internal: true
    
time:
  - platform: homeassistant
    id: esptime

display:
  - platform: ssd1306_i2c
    model: "SSD1306 64x48"
    reset_pin: 0
    address: 0x3C
    lambda: |-
      if (id(sensor_battery_power).state < -100) {
        it.image(50,0,id(img_down));
      }
      if (id(sensor_battery_power).state > 100) {
        it.image(50,0,id(img_up));
      }
      it.image(0,0,id(img_batt));
      it.printf(14,0, id(font_small), "%.0f%%", id(sensor_soc).state);
      it.image(0,15,id(img_load));
      it.printf(14,15, id(font_small), "%.2f% KW", id(sensor_load).state/1000.0);
      it.image(0,30,id(img_grid));
      it.printf(14,30, id(font_small), "%.2f% KW", id(sensor_grid).state/1000.0);

    # lambda: |-
    #   it.printf(0, 0, id(font_small), "BATT:%.0f%%", id(soc).state);
    #   it.printf(0, 15, id(font_small), "LOAD:%.1f%KW", id(load).state/1000.0);

Device 2 (Not working, only displaying glyphs):

esphome:
  name: micro-display-2
  friendly_name: Micro Display 2

esp8266:
  board: d1_mini

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "+/tmvHqLdFLzAT/j3PktzstBIPrfges2kRyvRrfq+8E="

ota:
  password: "c559deb501aa55f599ad496935a16b0d"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Micro-Display-2 Fallback Hotspot"
    password: "abc0000000"

captive_portal:
    
i2c:
  scl: D1
  sda: D2

font:
  - file: "gfonts://B612 Mono"
    id: font_small
    size: 10
  - file: "gfonts://Reddit Mono"
    id: font_mono_medium
    size: 14

image:
  - file: "mdi:battery"
    id: img_batt
    resize: 14x14
  - file: "mdi:power-plug"
    id: img_load
    resize: 14x14
  - file: "images/dollar_red.png"
    id: img_grid
  - file: "mdi:arrow-down-bold"
    id: img_down
    resize: 14x14
  - file: "mdi:arrow-up-bold"
    id: img_up
    resize: 14x14

sensor:
  - platform: homeassistant
    id: sensor_soc
    entity_id: sensor.deye_sunsynk_sol_ark_battery_state_of_charge
    internal: true
  - platform: homeassistant
    id: sensor_load
    entity_id: sensor.deye_sunsynk_sol_ark_load_power
    internal: true
  - platform: homeassistant
    entity_id: sensor.deye_sunsynk_sol_ark_grid_power
    id: sensor_grid      
    internal: true
  - platform: homeassistant
    entity_id: sensor.deye_sunsynk_sol_ark_battery_power
    id: sensor_battery_power     
    internal: true

time:
  - platform: homeassistant
    id: esptime

display:
  - platform: ssd1306_i2c
    model: "SSD1306 64x48"
    reset_pin: 0
    address: 0x3C
    lambda: |-
      if (id(sensor_battery_power).state < -100) {
        it.image(50,0,id(img_up));
      }
      if (id(sensor_battery_power).state > 100) {
        it.image(50,0,id(img_down));
      }
      it.image(0,0,id(img_batt));
      it.printf(14,0, id(font_small), "%.0f%%", id(sensor_soc).state);
      it.image(0,15,id(img_load));
      it.printf(14,15, id(font_small), "%.2f% KW", id(sensor_load).state/1000.0);
      it.image(0,30,id(img_grid));
      it.printf(14,30, id(font_small), "%.2f% KW", id(sensor_grid).state/1000.0);

Do You see ESP#2 API connection is established ?

I don’t see it I don’t think, here’s the complete log:

INFO ESPHome 2024.3.1
INFO Reading configuration /config/esphome/micro-display-2.yaml...
INFO Detected timezone 'Africa/Johannesburg'
INFO Starting log output from 192.168.0.158 using esphome API
INFO Successfully connected to micro-display-2 @ 192.168.0.158 in 0.088s
INFO Successful handshake with micro-display-2 @ 192.168.0.158 in 2.912s
[19:38:38][I][app:102]: ESPHome version 2024.3.1 compiled on Apr  3 2024, 18:32:38
[19:38:38][C][wifi:580]: WiFi:
[19:38:38][C][wifi:408]:   Local MAC: 5C:CF:7F:77:83:70
[19:38:38][C][wifi:413]:   SSID: 'Kantoor'[redacted]
[19:38:38][C][wifi:416]:   IP Address: 192.168.0.158
[19:38:38][C][wifi:419]:   BSSID: 60:22:32:D6:FA:9D[redacted]
[19:38:38][C][wifi:421]:   Hostname: 'micro-display-2'
[19:38:38][C][wifi:423]:   Signal strength: -50 dB ▂▄▆█
[19:38:38][C][wifi:427]:   Channel: 6
[19:38:38][C][wifi:428]:   Subnet: 255.255.255.0
[19:38:38][C][wifi:429]:   Gateway: 192.168.0.8
[19:38:38][C][wifi:430]:   DNS1: 1.1.1.1
[19:38:38][C][wifi:431]:   DNS2: 1.0.0.1
[19:38:38][C][logger:166]: Logger:
[19:38:38][C][logger:167]:   Level: DEBUG
[19:38:38][C][logger:169]:   Log Baud Rate: 115200
[19:38:38][C][logger:170]:   Hardware UART: UART0
[19:38:38][C][i2c.arduino:059]: I2C Bus:
[19:38:38][C][i2c.arduino:060]:   SDA Pin: GPIO4
[19:38:38][C][i2c.arduino:061]:   SCL Pin: GPIO5
[19:38:38][C][i2c.arduino:062]:   Frequency: 50000 Hz
[19:38:38][C][i2c.arduino:065]:   Recovery: bus successfully recovered
[19:38:38][I][i2c.arduino:075]: Results from i2c bus scan:
[19:38:38][I][i2c.arduino:081]: Found i2c device at address 0x3C
[19:38:38][C][homeassistant.time:010]: Home Assistant Time:
[19:38:38][C][homeassistant.time:011]:   Timezone: 'SAST-2'
[19:38:38][C][ssd1306_i2c:023]: I2C SSD1306
[19:38:38][C][ssd1306_i2c:023]:   Rotations: 0 °
[19:38:38][C][ssd1306_i2c:023]:   Dimensions: 64px x 48px
[19:38:38][C][ssd1306_i2c:024]:   Address: 0x3C
[19:38:38][C][ssd1306_i2c:025]:   Model: SSD1306 64x48
[19:38:38][C][ssd1306_i2c:026]:   Reset Pin: GPIO0
[19:38:38][C][ssd1306_i2c:027]:   External VCC: NO
[19:38:38][C][ssd1306_i2c:028]:   Flip X: YES
[19:38:38][C][ssd1306_i2c:029]:   Flip Y: YES
[19:38:38][C][ssd1306_i2c:030]:   Offset X: 0
[19:38:38][C][ssd1306_i2c:031]:   Offset Y: 0
[19:38:38][C][ssd1306_i2c:032]:   Inverted Color: NO
[19:38:38][C][ssd1306_i2c:033]:   Update Interval: 1.0s
[19:38:38][W][component:232]: Component display took a long time for an operation (119 ms).
[19:38:38][W][component:233]: Components should block for at most 30 ms.
[19:38:38][C][captive_portal:088]: Captive Portal:
[19:38:38][C][mdns:115]: mDNS:
[19:38:38][C][mdns:116]:   Hostname: micro-display-2
[19:38:38][C][ota:096]: Over-The-Air Updates:
[19:38:38][C][ota:097]:   Address: micro-display-2.local:8266
[19:38:38][C][ota:100]:   Using Password.
[19:38:38][C][ota:103]:   OTA version: 2.
[19:38:38][C][api:139]: API Server:
[19:38:38][C][api:140]:   Address: micro-display-2.local:6053
[19:38:38][C][api:142]:   Using noise encryption: YES
[19:38:38][C][homeassistant.sensor:030]: Homeassistant Sensor 'sensor_soc'
[19:38:38][C][homeassistant.sensor:030]:   State Class: ''
[19:38:38][C][homeassistant.sensor:030]:   Unit of Measurement: ''
[19:38:38][C][homeassistant.sensor:030]:   Accuracy Decimals: 1
[19:38:38][C][homeassistant.sensor:031]:   Entity ID: 'sensor.deye_sunsynk_sol_ark_battery_state_of_charge'
[19:38:38][C][homeassistant.sensor:030]: Homeassistant Sensor 'sensor_load'
[19:38:38][C][homeassistant.sensor:030]:   State Class: ''
[19:38:38][C][homeassistant.sensor:030]:   Unit of Measurement: ''
[19:38:38][C][homeassistant.sensor:030]:   Accuracy Decimals: 1
[19:38:38][C][homeassistant.sensor:031]:   Entity ID: 'sensor.deye_sunsynk_sol_ark_load_power'
[19:38:38][C][homeassistant.sensor:030]: Homeassistant Sensor 'sensor_grid'
[19:38:38][C][homeassistant.sensor:030]:   State Class: ''
[19:38:38][C][homeassistant.sensor:030]:   Unit of Measurement: ''
[19:38:38][C][homeassistant.sensor:030]:   Accuracy Decimals: 1
[19:38:38][C][homeassistant.sensor:031]:   Entity ID: 'sensor.deye_sunsynk_sol_ark_grid_power'
[19:38:38][C][homeassistant.sensor:030]: Homeassistant Sensor 'sensor_battery_power'
[19:38:38][C][homeassistant.sensor:030]:   State Class: ''
[19:38:38][C][homeassistant.sensor:030]:   Unit of Measurement: ''
[19:38:38][C][homeassistant.sensor:030]:   Accuracy Decimals: 1
[19:38:38][C][homeassistant.sensor:031]:   Entity ID: 'sensor.deye_sunsynk_sol_ark_battery_power'
[19:38:39][W][component:232]: Component display took a long time for an operation (119 ms).
[19:38:39][W][component:233]: Components should block for at most 30 ms.
[19:38:40][W][component:232]: Component display took a long time for an operation (118 ms).
[19:38:40][W][component:233]: Components should block for at most 30 ms.
[19:38:41][W][component:232]: Component display took a long time for an operation (119 ms).
[19:38:41][W][component:233]: Components should block for at most 30 ms.
[19:38:42][W][component:232]: Component display took a long time for an operation (118 ms).
[19:38:42][W][component:233]: Components should block for at most 30 ms.
[19:38:43][W][component:232]: Component display took a long time for an operation (118 ms).
[19:38:43][W][component:233]: Components should block for at most 30 ms.
[19:38:44][W][component:232]: Component display took a long time for an operation (119 ms).
[19:38:44][W][component:233]: Components should block for at most 30 ms.
[19:38:45][W][component:232]: Component display took a long time for an operation (119 ms).
[19:38:45][W][component:233]: Components should block for at most 30 ms.
[19:38:46][W][component:232]: Component display took a long time for an operation (118 ms).
[19:38:46][W][component:233]: Components should block for at most 30 ms.
[19:38:47][W][component:232]: Component display took a long time for an operation (118 ms).
[19:38:47][W][component:233]: Components should block for at most 30 ms.
[19:38:48][W][component:232]: Component display took a long time for an operation (119 ms).
[19:38:48][W][component:233]: Components should block for at most 30 ms.
[19:38:49][W][component:232]: Component display took a long time for an operation (119 ms).
[19:38:49][W][component:233]: Components should block for at most 30 ms.
[19:38:50][W][component:232]: Component display took a long time for an operation (118 ms).
[19:38:50][W][component:233]: Components should block for at most 30 ms.
[19:38:51][W][component:232]: Component display took a long time for an operation (118 ms).
[19:38:51][W][component:233]: Components should block for at most 30 ms.
[19:38:52][W][component:232]: Component display took a long time for an operation (119 ms).
[19:38:52][W][component:233]: Components should block for at most 30 ms.
[19:38:53][W][component:232]: Component display took a long time for an operation (118 ms).
[19:38:53][W][component:233]: Components should block for at most 30 ms.
[19:38:54][W][component:232]: Component display took a long time for an operation (119 ms).
[19:38:54][W][component:233]: Components should block for at most 30 ms.
[19:38:55][W][component:232]: Component display took a long time for an operation (119 ms).
[19:38:55][W][component:233]: Components should block for at most 30 ms.
[19:38:56][W][component:232]: Component display took a long time for an operation (119 ms).
[19:38:56][W][component:233]: Components should block for at most 30 ms.
[19:38:57][W][component:232]: Component display took a long time for an operation (119 ms).
[19:38:57][W][component:233]: Components should block for at most 30 ms.
[19:38:58][W][component:232]: Component display took a long time for an operation (118 ms).
[19:38:58][W][component:233]: Components should block for at most 30 ms.
[19:38:59][W][component:232]: Component display took a long time for an operation (118 ms).
[19:38:59][W][component:233]: Components should block for at most 30 ms.
[19:39:00][W][component:232]: Component display took a long time for an operation (118 ms).
[19:39:00][W][component:233]: Components should block for at most 30 ms.
[19:39:01][W][component:232]: Component display took a long time for an operation (119 ms).
[19:39:01][W][component:233]: Components should block for at most 30 ms.
[19:39:02][W][component:232]: Component display took a long time for an operation (118 ms).
[19:39:02][W][component:233]: Components should block for at most 30 ms.
[19:39:03][W][component:232]: Component display took a long time for an operation (119 ms).
[19:39:03][W][component:233]: Components should block for at most 30 ms.
[19:39:04][W][component:232]: Component display took a long time for an operation (118 ms).
[19:39:04][W][component:233]: Components should block for at most 30 ms.
[19:39:05][W][component:232]: Component display took a long time for an operation (118 ms).
[19:39:05][W][component:233]: Components should block for at most 30 ms.
[19:39:06][W][component:232]: Component display took a long time for an operation (119 ms).
[19:39:06][W][component:233]: Components should block for at most 30 ms.
[19:39:07][W][component:232]: Component display took a long time for an operation (119 ms).
[19:39:07][W][component:233]: Components should block for at most 30 ms.
[19:39:08][W][component:232]: Component display took a long time for an operation (119 ms).
[19:39:08][W][component:233]: Components should block for at most 30 ms.
[19:39:09][W][component:232]: Component display took a long time for an operation (119 ms).
[19:39:09][W][component:233]: Components should block for at most 30 ms.
[19:39:10][W][component:232]: Component display took a long time for an operation (118 ms).
[19:39:10][W][component:233]: Components should block for at most 30 ms.
[19:39:11][W][component:232]: Component display took a long time for an operation (119 ms).
[19:39:11][W][component:233]: Components should block for at most 30 ms.
[19:39:12][W][component:232]: Component display took a long time for an operation (119 ms).
[19:39:12][W][component:233]: Components should block for at most 30 ms.
[19:39:13][W][component:232]: Component display took a long time for an operation (118 ms).
[19:39:13][W][component:233]: Components should block for at most 30 ms.
[19:39:14][W][component:232]: Component display took a long time for an operation (118 ms).
[19:39:14][W][component:233]: Components should block for at most 30 ms.
[19:39:15][W][component:232]: Component display took a long time for an operation (118 ms).
[19:39:15][W][component:233]: Components should block for at most 30 ms.
[19:39:16][W][component:232]: Component display took a long time for an operation (119 ms).
[19:39:16][W][component:233]: Components should block for at most 30 ms.
[19:39:17][W][component:232]: Component display took a long time for an operation (119 ms).
[19:39:17][W][component:233]: Components should block for at most 30 ms.
[19:39:18][W][component:232]: Component display took a long time for an operation (118 ms).
[19:39:18][W][component:233]: Components should block for at most 30 ms.
[19:39:19][W][component:232]: Component display took a long time for an operation (118 ms).
[19:39:19][W][component:233]: Components should block for at most 30 ms.
[19:39:20][W][component:232]: Component display took a long time for an operation (118 ms).
[19:39:20][W][component:233]: Components should block for at most 30 ms.
[19:39:21][W][component:232]: Component display took a long time for an operation (119 ms).
[19:39:22][W][component:233]: Components should block for at most 30 ms.
[19:39:22][W][component:232]: Component display took a long time for an operation (119 ms).
[19:39:22][W][component:233]: Components should block for at most 30 ms.
[19:39:23][W][component:232]: Component display took a long time for an operation (119 ms).
[19:39:23][W][component:233]: Components should block for at most 30 ms.
[19:39:24][W][component:232]: Component display took a long time for an operation (119 ms).
[19:39:24][W][component:233]: Components should block for at most 30 ms.
[19:39:25][W][component:232]: Component display took a long time for an operation (119 ms).
[19:39:25][W][component:233]: Components should block for at most 30 ms.
[19:39:26][W][component:232]: Component display took a long time for an operation (119 ms).
[19:39:26][W][component:233]: Components should block for at most 30 ms.
[19:39:27][W][component:232]: Component display took a long time for an operation (119 ms).
[19:39:27][W][component:233]: Components should block for at most 30 ms.

I didn’t realise one has to go to Settings / Devices & Services | Integrations. There the second device was waiting to be configured…Fixed up.