esphome / issues

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

ssd1327_i2c appears to break wifi #1989

Closed tvwerkhoven closed 3 years ago

tvwerkhoven commented 3 years ago

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

pip3 esphome 1.16.2 / esptool 2.8

ESP (ESP32/ESP8266, Board/Sonoff):

Wemos D1 mini pro (ESP8266)

ESPHome version (latest production, beta, dev branch)

esphome 1.16.2 / esptool 2.8 Affected component:

https://esphome.io/components/display/ssd1327.html

Description of problem: When I enable the OLED in the YAML file and upload it, the board either:

  1. does not have OLED working (rest appears fine) - this usually happens after the first time uploading a new config over serial
  2. does not connect to wifi anymore (no ping, no MQTT, no HA). It appears the rest is working (i.e. sensor values can be displayed on the OLED). - this seems to happen all subsequent times of power cycling the board

Problem-relevant YAML-configuration entries:

This works (wifi, no OLED):

esphome:
  name: esp_mobile
  platform: ESP8266
  board: d1_mini_pro

wifi:
  networks:
  - ssid: "SSID1" # not IoT because this one needs WAN access for MQTT
    password: "password"
    hidden: true
  - ssid: "SSID2"
    password: "password"
  - ssid: "SSID3"
    password: "password"
  - ssid: "SSID4"
    password: "password"
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "esphome.io"
    password: "password"

  use_address: "IPv4"
  #fast_connect: True # Required to connect to hidden SSIDs -- only works with one network
  domain: ".lan"
  # Do not reboot if no wifi
  reboot_timeout: 0s

logger:
  baud_rate: 115200

# Enable Home Assistant API - disable for MQTT? And for reboot loop?
api:
  reboot_timeout: 0s

ota:

mqtt:
  broker: IPV4
  port: 1883
  username: username
  password: password
  id: mqtt_client

i2c:
  sda: GPIO4 # = D2 = 4
  scl: GPIO5 # = D1 = 5
  scan: True

When I append the following the wifi or the OLED breaks:

font:
  - file: "slkscr.ttf"
    id: my_font1
    size: 8

display:
  - platform: ssd1327_i2c
    model: "SSD1327 128x128"
    # reset_pin: D0
    address: 0x3C
    # id: oled_128x128
    lambda: |-
      it.print(0, 0, id(my_font1), "Hello World!");

Logs (if applicable):

This is the debug log when wifi fails (and OLED works):

INFO Starting log output from /dev/cu.usbserial-1420 with baud rate 115200
[09:06:51]sdl\x9c\x9f|\x8c$\xe0|\x84d\xecc|\xc7\xc3\xe4\x9br\x9bb\x84#\x8c\xfbo'\x9fdo'\x9c\xe3\xeccp\x8c\x8fl;l;lx\xf3o\xe0\x83l\x8c\x9cbn\xe3|\xecd\x87\x87#\x8c\xf3o'\xe7d\x8c\x8el \x98\033'o$`n;\x87\x9b\x92'#l sۓobl \x9cc\x87\xdbd;\x93`\xfc\x83n\x9c[I][logger:166]: Log initialized
[09:06:51][C][ota:366]: There have been 1 suspected unsuccessful boot attempts.
[09:06:51][I][app:029]: Running through setup()...
[09:06:51][C][ssd1327_i2c:010]: Setting up I2C SSD1327...
[09:06:53][C][wifi:033]: Setting up WiFi...
[09:06:53][D][wifi:324]: Starting scan...
[09:07:24][E][wifi:332]: Scan timeout!
[09:07:30][D][wifi:324]: Starting scan...
[09:07:54][I][wifi:116]: Starting fallback AP!
[09:07:54][C][wifi:161]: Setting up AP...
[09:07:54][C][wifi:163]:   AP SSID: 'esphome.io'
[09:07:54][C][wifi:164]:   AP Password: 'password'
[09:07:55][C][wifi:173]:   IP Address: 192.168.4.1
[09:08:00][E][wifi:332]: Scan timeout!
[09:08:06][D][wifi:324]: Starting scan...
[09:08:37][E][wifi:332]: Scan timeout!
[09:08:42][D][wifi:324]: Starting scan...
[09:09:14][E][wifi:332]: Scan timeout!
[09:09:14][W][wifi:522]: Restarting WiFi adapter...
[09:09:14][W][wifi:522]: Restarting WiFi adapter...
[09:09:20][D][wifi:324]: Starting scan...
[09:09:51][E][wifi:332]: Scan timeout!
[09:09:56][D][wifi:324]: Starting scan...
[09:10:28][E][wifi:332]: Scan timeout!
[09:10:33][D][wifi:324]: Starting scan...
[09:11:05][E][wifi:332]: Scan timeout!
[09:11:10][D][wifi:324]: Starting scan...
[09:11:42][E][wifi:332]: Scan timeout!
[09:11:42][W][wifi:522]: Restarting WiFi adapter...
[09:11:42][W][wifi:522]: Restarting WiFi adapter...
[09:11:47][D][wifi:324]: Starting scan...
[09:12:19][E][wifi:332]: Scan timeout!
[09:12:24][D][wifi:324]: Starting scan...
[09:12:56][E][wifi:332]: Scan timeout!
[09:13:01][D][wifi:324]: Starting scan...
[09:13:33][E][wifi:332]: Scan timeout!
[09:13:38][D][wifi:324]: Starting scan...
[09:14:09][E][wifi:332]: Scan timeout!
[09:14:09][W][wifi:522]: Restarting WiFi adapter...
[09:14:09][W][wifi:522]: Restarting WiFi adapter...

This is the debug log when OLED fails (and wifi works):

[11:36:14][I][app:029]: Running through setup()...
[11:36:14][C][ssd1327_i2c:010]: Setting up I2C SSD1327...
[11:36:14][W][i2c:076]: Unknown transmit error 4 for address 0x3C
[11:36:14][E][component:092]: Component was marked as failed.
[11:36:14][C][wifi:033]: Setting up WiFi...
[11:36:14][I][wifi:194]: WiFi Connecting to 'SSID'...
[11:36:14][D][sensor:092]: 'Uptime': Sending state 0.11300 s with 0 decimals of accuracy
[11:36:18][I][wifi:457]: WiFi Connected!

Additional information and things you've tried: There are multiple sensors connected to the board (1 Dallas, 1 bme280, 1 mh-z19b, 1 SDS011), but these all work fine as long as the oled is disabled (and possible even with the oled enabled). The wifi only breaks when I enable the oled.

mmakaay commented 3 years ago

It's a bit of a long shot, but I recently ran into quite an obscure issue when using font/display, causing the ESP8266 to crash with reboots: what version of the pillow python library do you use? Could you try upgrading pillow (using pip3)?

tvwerkhoven commented 3 years ago

I found a solution: increase the update_interval to e.g. 10s, i.e. this works for me:

display:
  - platform: ssd1327_i2c
    model: "SSD1327 128x128"
    update_interval: 30s
    address: 0x3C
    [...]

Problem (from source): "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."

@mmakaay for the record (I don't think this was it), I have Pillow version 8.1.0.

mmakaay commented 3 years ago

For the record: you are right. That version of pillow has no issue.