Waveshare e-ink screen unable to init screen after while, only reflash from arduino works

Hello,
I’m using the waveshare library with a 2.13" e-ink screen (GDEY0213Z98 122x250 tri-color). I know the tri-color not working yet, but it’s ok without.
My esp is a esp32doit-devkit-v1, here is it’s pinout:

So far, by using model 2.13in and it nearly works.
The main issue I have is that the library seems to not be able to initalize properly the screen, sometime (after a re-plug) or by testing some parameters (at the begining) the screen was either completely messed up, or esphome was unable to send new data.
In this state, even by trying lot of parameters, the screen doesn’t change anymore whatever I try.
The only way to get out this situation is to re-flash with an Arduino with GxEPD2 library (which supports my screen), and without touching any wires (same pin configuration on esphome and arduino) the screen became alive again.
Then I can reflash with esphome and it “works” like before.
If I could find a way to proper reset the screen, it would “solve” my major issue.

The second issue is the colors are inverted : i need to draw a black rectangle, then print on draw in white, the screen flicker a few times, then finish inverted. The pictures need to be inverted to, like mdi icons.
This is managable.

here is my esphome code for reference:

esphome:
  name: test-display
  friendly_name: test-display
  # on_boot:
  #   priority: 700
  #   then:
  #     - delay: 2sec
  #     - component.update: my_display
  #     - delay: 100ms
  #     - component.update: my_display
  #     - delay: 100ms
  #     - component.update: my_display
  #     - delay: 100ms
  #     - component.update: my_display
  #     - delay: 100ms

esp32:
  #board: esp32dev
  board: esp32doit-devkit-v1
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX="

ota:
  password: "XXXXXXXXXXXXXXXXXXXXX"

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

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

captive_portal:

# external_components:
#   - source:
#       type: git
#       url: https://github.com/esphome/esphome
#       ref: beta
#     components: [ waveshare_epaper ]

time:
  - platform: sntp
    id: esptime

font:
  - file: "gfonts://Roboto"
    id: font1
    size: 24
    glyphs: "!\"%()+=,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyzéèêàïùÉÈÊÀÏÙ"


spi:
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO19 #not connected for using external SPI
  

text_sensor:
  - platform: homeassistant
    id: display_text
    entity_id: input_text.calendrier_text
    on_value:
        - component.update: my_display

image:
  - file: "sapin.png"
    id: sapin
    resize: 80X80
  - file: mdi:heart
    id: heart
    resize: 48x48

qr_code:
  - id: wled_link
    value: "https://play.google.com/store/apps/details?id=com.aircoookie.WLED"

display:
  - platform: waveshare_epaper
    #id: my_text
    cs_pin: GPIO21   #GPIO2
    dc_pin: GPIO5
    busy_pin: GPIO15 #GPIO19
    reset_pin: GPIO4
    id: my_display
    model: 2.13in #pos ok, blikns + fade
    #model: 2.13in-ttgo # pos ok, color inverted, clignotte
    #model: 2.13in-ttgo-b73 #pos ok, clignotte, fond gris
    #model: 2.13in-ttgo-b74 #pos ok blinks
    #model: 2.13in-ttgo-b1 #KO
    
    #model: 2.13in-ttgo-dke # lot of noise, with waveshare beta
    

    #model: 2.90inV2 #pos KO , clignotte
    rotation: 270°
    full_update_every: 1
    update_interval: 60s
    #reset_duration: 10ms # also tryed 2ms, 10ms, 100ms ...
    #update_interval: 2
    #full_update_every: 1
    pages:
      - id: page1
        lambda: |-
          it.filled_rectangle(0,0,250,122, COLOR_ON);
          it.print(2, 2, id(font1), COLOR_OFF, "This is page 1!");
          it.strftime(2, 24, id(font1), COLOR_OFF, "%H:%M:%S", id(esptime).now());
          //it.print(2, 46, id(font1), COLOR_OFF,  id(display_text).state)
          it.image(170, 10, id(sapin));
          it.printf(2, 46, id(font1), COLOR_OFF," %s ", id(display_text).state.c_str());       
          it.image(10, 70, id(heart), COLOR_OFF);
      - id: page2
        lambda: |-
          it.filled_rectangle(0,0,250,122, COLOR_ON);
          it.qr_code(30, 5, id(wled_link), COLOR_OFF, 3);
      - id: page3
        lambda: |-
          it.filled_rectangle(0,0,250,122, COLOR_ON);
    # lambda: |-
    #   it.filled_rectangle(0,0,250,122, COLOR_ON);
    #   it.printf(0, 0, id(font1), "Hello new !", COLOR_OFF);
    #   // Draw the same rectangle, but this time filled.
    #   //it.filled_rectangle(50, 60, 30, 30);
    #   //it.filled_rectangle(70, 80, 30, 30, COLOR_OFF);

#not working
# interval:
#   - interval: 30s
#     then:
#       - display.page.show_next: my_display
#       - component.update: my_display

button:
  - platform: template
    name: "Template Button"
    on_press:
      - logger.log: Button Pressed
      - display.page.show_next: my_display
      - component.update: my_display

I didn’t remove a lot comments to let you know what I already tested

Some help would be appreciated :slight_smile:

Kytrix

I made a test:
I unplug my board for a few minutes, then replug it: and my issue came back:
esphome wasn’t able to init the screen (no update, no fliker … nothing changed on display)

So it seems, when I run the arduino code, the screen is initialyzed, and usable by espHome until it stay on (or off for a short time only) .

So esphome is unable to initialize my screen by itself :confused: