esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 36 forks source link

Wemos D1 mini broken WiFi with SSD13xx I2C display #1920

Closed wwebers closed 3 years ago

wwebers commented 3 years ago

Operating environment/Installation (Hass.io/Docker/pip/etc.):

Windows 10, python 3.9, pip

ESP (ESP32/ESP8266, Board/Sonoff):

ESP8266, Wemos D1 mini

ESPHome version (latest production, beta, dev branch)

1.16.2

Affected component:

WiFi: https://esphome.io/components/wifi.html SSD1327_I2C: https://esphome.io/components/display/ssd1327.html

Description of problem: With the display component enabled the Wemos D1 is unable to connect to my WiFi AP. Its cannot even create the fallback AP.

Problem-relevant YAML-configuration entries:

esphome:
  name: moonclock
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: "on"

  manual_ip:
    static_ip: !secret clock_ip
    gateway: !secret gw
    subnet: !secret netmask

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: !secret clock_ap
    password: !secret clock_ap_pw

captive_portal:

# Enable logging
logger:
  level: DEBUG

# Enable Home Assistant API
api:
  password: !secret api_password

ota:
  password: !secret ota_password

time:
  - platform: sntp
    id: sntp_time

light:
  - platform: fastled_clockless
    chipset: WS2812B
    pin: D5
    num_leds: 30
    rgb_order: GRB
    name: "Moonclock"
    id: moonclock
    effects:
      - random:
      - addressable_rainbow:
          width: 30

i2c:
  sda: 4
  scl: 5

font:
  - file: "DoppioOne-Regular.ttf"
    id: my_font
    size: 12

display:
  - platform: ssd1327_i2c
    model: "SSD1327 128x128"
    id: clock_display
    address: 0x3D
    lambda: |-
      it.strftime( 0, 0, id(my_font),  "%Y-%m-%d %H:%M:%S", id(sntp_time).now());

pcf8574:
  - id: 'pcf8574_hub'
    address: 0x20
    pcf8575: False

binary_sensor:
  - platform: gpio
    name: "Menu button"
    pin:
      pcf8574: pcf8574_hub
      number: 0
      mode: INPUT

  - platform: gpio
    name: "Up button"
    pin:
      pcf8574: pcf8574_hub
      number: 1
      mode: INPUT

  - platform: gpio
    name: "Down button"
    pin:
      pcf8574: pcf8574_hub
      number: 2
      mode: INPUT

Logs (if applicable):

←[32mINFO Running:  esptool.py --before default_reset --after hard_reset --baud 460800 --chip esp8266 --port COM4 write_flash 0x0 '.\moonclock\.pioenvs\moonclock\firmware.bin'←[0m
esptool.py v2.8
Serial port COM4
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 84:0d:8e:8a:7f:6e
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 462720 bytes to 318601...
Wrote 462720 bytes (318601 compressed) at 0x00000000 in 7.2 seconds (effective 513.9 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
←[32mINFO Successfully uploaded program.←[0m
←[32mINFO Starting log output from COM4 with baud rate 115200←[0m
[14:08:03]rl d\x9c\x9e| \x8cl\xe0<♥♀♦♀\x8c♦l\xe4♀#|\x87\x83♥\xec←\xdbs\xdbc\xc4♀#\x8c\xf3og\x9flno\x9c\xe3\xe4♀c∟8\x84\x87lrl;lp\xf2'\xe0↑♥♦♀\x83♀d♀\x84\x9c♀♦♀b♀'\xe3|♥\xe4l\x8f♀\x8ec\x8c\xfbg'\xe7 l\xc4\xc7d`♥\x98‼←'o♀$`♥☼♥'{\x8f\x93\x9bo♦♦c♥l`♥{ۓo♀♦b♥l`♥\x9cb♦♀\x8e∟♥\x93$s\x9b`♥\xfc\x83o\xdc♥[I][logger:166]: Log initialized
[14:08:03][C][ota:366]: There have been 5 suspected unsuccessful boot attempts.
[14:08:03][I][app:029]: Running through setup()...
[14:08:03][C][pcf8574:010]: Setting up PCF8574...
[14:08:03][C][fastled:010]: Setting up FastLED light...
[14:08:03][D][binary_sensor:034]: 'Menu button': Sending initial state OFF
[14:08:03][D][binary_sensor:034]: 'Up button': Sending initial state OFF
[14:08:03][D][binary_sensor:034]: 'Down button': Sending initial state OFF
[14:08:03][C][light:097]: Setting up light 'Moonclock'...
[14:08:03][D][light:265]: 'Moonclock' Setting:
[14:08:03][D][light:278]:   Brightness: 100%
[14:08:03][D][light:287]:   Red=100%, Green=100%, Blue=100%
[14:08:03][C][ssd1327_i2c:010]: Setting up I2C SSD1327...
[14:08:05][C][wifi:033]: Setting up WiFi...
[14:08:05][I][wifi:194]: WiFi Connecting to 'myHomeIOT'...
[14:08:36][W][wifi:479]: Timeout while connecting to WiFi.
[14:08:36][I][wifi:194]: WiFi Connecting to 'myHomeIOT'...
[14:09:06][I][wifi:116]: Starting fallback AP!
[14:09:06][C][wifi:161]: Setting up AP...
[14:09:06][C][wifi:163]:   AP SSID: 'Moonclock AP'
[14:09:06][C][wifi:164]:   AP Password: 'moonclock'
[14:09:06][C][wifi:167]:   AP Static IP: '192.168.10.210'
[14:09:06][C][wifi:168]:   AP Gateway: '192.168.10.1'
[14:09:06][C][wifi:169]:   AP Subnet: '255.255.255.0'
[14:09:07][C][wifi:173]:   IP Address: 192.168.10.210
[14:09:09][W][wifi:479]: Timeout while connecting to WiFi.
[14:09:14][I][wifi:194]: WiFi Connecting to 'myHomeIOT'...
[14:09:46][W][wifi:479]: Timeout while connecting to WiFi.
[14:09:46][I][wifi:194]: WiFi Connecting to 'myHomeIOT'...
[14:10:17][W][wifi:479]: Timeout while connecting to WiFi.
[14:10:23][I][wifi:194]: WiFi Connecting to 'myHomeIOT'...
[14:10:54][W][wifi:479]: Timeout while connecting to WiFi.
[14:10:54][I][wifi:194]: WiFi Connecting to 'myHomeIOT'...
[14:11:26][W][wifi:479]: Timeout while connecting to WiFi.
[14:11:31][I][wifi:194]: WiFi Connecting to 'myHomeIOT'...
[14:12:03][W][wifi:479]: Timeout while connecting to WiFi.
[14:12:03][I][wifi:194]: WiFi Connecting to 'myHomeIOT'...
[14:12:35][W][wifi:479]: Timeout while connecting to WiFi.
[14:12:40][I][wifi:194]: WiFi Connecting to 'myHomeIOT'...
[14:13:12][W][wifi:479]: Timeout while connecting to WiFi.
[14:13:12][I][wifi:194]: WiFi Connecting to 'myHomeIOT'...
[14:13:43][W][wifi:479]: Timeout while connecting to WiFi.
[14:13:49][I][wifi:194]: WiFi Connecting to 'myHomeIOT'...

Additional information and things you've tried: As soon as I disable the display component everything works fine. Including other I2C devices,

wwebers commented 3 years ago

I found the cause of the problem:

The display used the I2C protokoll. Maximum rate for the Wemos D1 seem to bee 100khz, which seem to be too slow to keep the default display refresh rate at 5s! As a result, it looks like this breaks the hard requirement of the ESPHome "scheduler" to not spend more than 10ms. In the end, the other components don't get a chance to handle their loops.

Solution:

Increase the update_interval to e.g. 10s.

  - platform: ssd1327_i2c
    model: "SSD1327 128x128"
    update_interval: 10s
    id: clock_display
    address: 0x3D
    lambda: |-
      it.strftime( 0, 0, id(my_font),  "%Y-%m-%d %H:%M:%S", id(sntp_time).now());

Alternatively, one could try to connect the display to the SPI-bus.