Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Lilygo T5-4.7 inch e-paper module #1109

Open
lbonherbe opened this issue Feb 2, 2021 · 387 comments
Open

Add support for Lilygo T5-4.7 inch e-paper module #1109

lbonherbe opened this issue Feb 2, 2021 · 387 comments

Comments

@lbonherbe
Copy link

lbonherbe commented Feb 2, 2021

Describe the problem you have/What new integration you would like
The Lyligo T5-4.7inch is a great e-paper module based on an ESP32. It has a resolution of 960*540, 16 gray level and support partial refresh. I would be great to have it integrated in ESPHome the same / similar way Waveshare e-paper screens and modules are.

Please describe your use case for this integration and alternatives you've tried:
To date there is no support for this module in ESPHome. The only support given by the maker is through Arduino IDE

Additional context
This is the maker's GitHub for this product: https://github.com/Xinyuan-LilyGO/LilyGo-EPD47

@jeremypoulter
Copy link

Would someone be able to give me some hints in to what this actually involves? I assume mainly just adding support for the actual e-paper display?

@DomoYop
Copy link

DomoYop commented Mar 24, 2021

It seems that it dont use the same driver as the Waveshare e-paper series does...
it use this one: EPDiy E-Paper Driver which support the ED047TC1 E-Ink Display.

from my (limited) comprehension, it's much closer to the Inkplate which is already supported in esphome.

here is what i found analyzing the schematics: LilyGo-EPD47.pdf

8 pin for data:
IO33 -> EP_D0
IO32 -> EP_D1
IO4 -> EP_D2
IO19 -> EP_D3
IO2 -> EP_D4
IO27 -> EP_D5
IO21 -> EP_D6
IO22 -> EP_D7
 
and some direct control pin:
IO26 -> EP_STH
IO25 -> EP_CKV
IO5 -> EP_CKH

connection to shift register (74HC4094)
IO0 -> strobe
IO23 -> data
IO18 -> clock
with the corresponding output :
q0 -> EP_LE
q7 -> EP_OE
q6 -> EP_MODE
q4 -> EP_STV

it's all i have :-)

@Mitchy6
Copy link

Mitchy6 commented Mar 25, 2021

I attempted to port the Inkplate driver;
Haven't been fully successful yet, Likely I goofed a timer or something, No scope at the moment so I'm flying blind in making sure the driver signalling/timing is how it should be.

Things to note:
Inkplate uses the MCP23017 i2c IO extender.
EPD47 uses a 74HCT4094 shift register, I modified/forked the SN74HC595 component to get it working with the reversed shift logic for the 4094 this will let you substitute the IO Call in your yaml file. the 4094 is trivial to control, May submit my fork to at least have the 4094 able to be controlled in the future.

The inkplate code has i2c enabled/forced, this is mapped to GPIO 21/22, so you'll get boot loops if you try to use it with the EPD (As GPIO 21 & 22 are used in the parallel connection for the display). You'll need to modify the component and disable the i2c call.

Inkplate has several control IO signals that aren't used on the EPD47, I've deleted these, or used them in similar functions (power enable)

That said, the sample code by vroland (https://github.com/vroland/epdiy) is a work of art, and far exceeds that of the inkplate base code by using the built in timer and I2S Parallel driver function of the ESP32.
I've pivoted and I've been trying to port the base driver much like martinberlin (martinberlin/cale-idf#27) has done for his Cale software, but Its only a past time, and I suck at C/C++
I'm assuming the Display buffer output is compatible. It's definitely doable and not far out, Someone can whip up the code pretty quick
I'll continue to mess about when I can.

What should happen is the EPD driver should be ported, and made universal to consume the inkplate and all other EPDiy type boards. This should let anyone use any of the EPDiy based board/display combos (Link above in vroland's github)

@Chrismelba-Instaclustr
Copy link

Any update on this? I could have a go if you've got some work anywhere?

@Plawasan
Copy link

Just adding a +1 here for the port, would be great to have this natively supported in ESPHome

@tiaanv
Copy link

tiaanv commented Dec 1, 2021

I put something together using the edp_display drivers from Lilygo. I tried using a more generic approach for all displays supported by epdiy, but got frustrated and resorted to basic support.

The display component only supports full draw, and not partials... Partial updates in general are bad news, but I might look into support at some later stage. This was NOT thoroughly tested and it might stop working at any time... your mileage may vary.

https://github.com/tiaanv/esphome-components

Enjoy.

PS. I also tried doing this in the more correct "external_components" model, but for some reason it no longer worked when I did that.... So custom_component it is.....
image

@Plawasan
Copy link

Plawasan commented Dec 4, 2021

Great! I tried to test this, not sure where I'm going wrong. I've cloned the repo to the base of my esphome config and renamed the folder to custom_components otherwise I was getting errors even recognizing the platform

~/esphome$ git clone https://github.com/tiaanv/esphome-components.git
~/esphome$ mv esphome-components/ custom_components

I've added a very basic definition of the display into my yaml:

display:
  - platform: t547
    id: t5_display
    update_interval: 30s
    lambda: |-
      it.line(0, 0, 50, 50);

but I'm hitting this error when trying to compile it:

Compiling .pioenvs/esp-display/lib9aa/ESPAsyncWebServer-esphome/WebAuthentication.cpp.o
src/main.cpp:36:1: error: 't547' does not name a type
 t547::T547 *t5_display;
 ^
src/main.cpp: In function 'void setup()':
src/main.cpp:1608:3: error: 't5_display' was not declared in this scope
   t5_display = new t547::T547();
   ^
src/main.cpp:1608:20: error: 't547' does not name a type
   t5_display = new t547::T547();
                    ^
*** [.pioenvs/esp-display/src/main.cpp.o] Error 1
========================== [FAILED] Took 4.77 seconds ==========================

Any pointers? Thanks again for the effort, I've been using this display for a while with the code borrowed from here - https://github.com/rbaron/eink-ha but I would still prefer native ESPHome integration.

Any chance you can also post the sample yaml? Thanks!

Edit:
I've added the header to my config:

esphome:
  includes:
    - custom_components/t547/t547.h

now I'm missing the driver.. I cloned the repo but being the noob I am I'm not sure where to place it for esphome to find it..

Compiling .pioenvs/esp-display/src/main.cpp.o
In file included from src/main.cpp:43:0:
src/t547.h:7:24: fatal error: epd_driver.h: No such file or directory

@tiaanv
Copy link

tiaanv commented Dec 4, 2021

remove the includes statement... I got the same issue... What you are trying here is the "external_components" model... That does not work... What you need is to locate the esphome folder in your config dir in HomeAssistant... Then create the "custom_components" folder in there if you don't already have one.. then make sure to copy the T547 folder into that folder. On my system I'm accessing it via a samba share from my windows machine..

effective folder structure:
\config\esphome\custom_components\t547

with all the files in there...

This method works for me... Other that that, I'm afraid I haven't spent enough time with development of custom components to know why I can't get it to work as an "external component"

@Plawasan
Copy link

Plawasan commented Dec 4, 2021

I probably should have mentioned that I have ESPHome running on a completely different machine (a laptop) than Home Assistant, that's running in a docker container on my RPi, not on Hass

but.. I also have a VM with hass.io running on the laptop, I used the terminal add-on to clone the git repo to config/esphome/, renamed esphome-components to custom_components, then I got no errors in the yaml editor..

image

but it still won't compile:

Compiling /data/esp-display/.pioenvs/esp-display/src/esphome/core/util.cpp.o
Compiling /data/esp-display/.pioenvs/esp-display/src/main.cpp.o
src/main.cpp:34:1: error: 't547' does not name a type
 t547::T547 *t5_display;
 ^
src/main.cpp: In function 'void setup()':
src/main.cpp:354:3: error: 't5_display' was not declared in this scope
   t5_display = new t547::T547();
   ^
src/main.cpp:354:20: error: 't547' does not name a type
   t5_display = new t547::T547();
                    ^
*** [/data/esp-display/.pioenvs/esp-display/src/main.cpp.o] Error 1

@tiaanv
Copy link

tiaanv commented Dec 4, 2021

I don't have enough experience in this regard. I'm sorry I can't help more... Perhaps one of the smarter people can figure it out... that sees this post.... I'm not near my dev PC, but perhaps tomorrow I will give the external components route a go again... then it should work... until then, I hope you figure something out..

@osresearch
Copy link

image

I was getting the same t547 does not name a type errors and determined that what was needed is an empty __init__.py in the custom_components/t547 directory. Not sure why; this was based on looking at the difference to the waveshare_epaper component.

Here is a working example:

esphome:
  name: t547demo
  platform: esp32
  board: esp32dev
  platformio_options:
    upload_speed: 1500000

wifi:
  ssid: "YOUR-SSID"
  password: "*********"

time:
  - platform: sntp
    id: ntp

font:
  - file: 'IBMPlexMono-Bold.ttf'
    id: din_big
    glyphs: "+-0123456789.:"
    size: 300
  - file: 'IBMPlexMono-Bold.ttf'
    id: din_med
    size: 100

display:
  - platform: t547
    rotation: 180
    update_interval: 60s
    lambda: |-
      it.strftime(15, 310, id(din_big), TextAlign::BASELINE_LEFT, "%H:%M", id(ntp).now());
      it.strftime(50, 500, id(din_med), TextAlign::BASELINE_LEFT, "%Y-%m-%d %a", id(ntp).now());

The redraw is full screen, which is fairly slow. Using the sample code from Lilygo I was able to do partial updates, so it should be possible to enable.

@Plawasan
Copy link

martin@EliteBook:~/esphome/custom_components/t547$ touch __init__.py

That's all it took.. now I have work to do over the weekend to create a decent dashboard but it should be pretty straightforward from here.. thanks!

image

@tiaanv
Copy link

tiaanv commented Dec 11, 2021

The Init.py issue was because the file in my local source failed to upload to github. It skips empty files... I added a single blank space to correct that issue. I guess in theory I can now try the proper external components approach again... Will make it easier for most to implement, and it will be pulled from git automatically...

@NeroWard
Copy link

The redraw is full screen, which is fairly slow. Using the sample code from Lilygo I was able to do partial updates, so it should be possible to enable.

Share the code with which you were able to do a partial update? Sorry for my English.

@osresearch
Copy link

@NeroWard the sample code is here https://github.com/Xinyuan-LilyGO/LilyGo-EPD47/blob/master/examples/demo/demo.ino although it is built and installed with Arduino, and the partial update functions aren't compatible (yet) with the esphome display class. It allows individual regions to be forced to white by flashing them several times, and then drawing the black pixels.

It might be possible to remove the call to epd_clear() in T457::display() https://github.com/tiaanv/esphome-components/blob/main/t547/t547.cpp#L82 and to track damage to the display buffer rather than drawing the full one, although it looks like the other epd with partial update still send the full image, but with a different LUT. The code from lilly go has a function to update the LUT with some comments that might be helpful https://github.com/tiaanv/esphome-components/blob/main/t547/epd_driver.c#L267

@Plawasan
Copy link

Plawasan commented Dec 22, 2021

I took me a bit of time to fine-tune it to my liking but I'm pretty happy with the outcome:

yaml is here - https://gist.github.com/Plawasan/4ae826b05aaa7812f3a191714ca47a50 - keep in mind I'm no programmer so it may not be as clean as it could be but it works reliably.

I have yet to see how long will the battery last, right now I have it configured to refresh every 20 minutes during the day and then sleep for 6h after midnight. There is a period of time after the ESP wakes up from deep sleep (and resets the display) until new data comes from HA when the display is blank - I didn't find a way to easily disable it so I at least raised a feature request for it - #1555

It's obviously configured for my specific use case and entities but the yaml should be simple enough to adjust.

image

@vbaksa
Copy link

vbaksa commented Jan 1, 2022

I'm sharing one more implementation that I developed a while ago. I'm using it for a least one month and so far haven't experienced any issues.

I'm utilizing vroland/epdiy library which supports partial screen update and display orientation.

Pretty much all ESPHome display features are supported.

Minimal usage example

external_components:
  - source:
      type: git
      url: https://github.com/vbaksa/esphome
      ref: dev
    components: [lilygo_t5_47_display]

display:
  - platform: lilygo_t5_47_display
    lambda: |-
      it.line(0, 0, 100, 50);
      it.rectangle(50, 60, 30, 42);
      it.filled_rectangle(50, 60, 30, 42);
      it.filled_circle(250, 250, 100);
      it.circle(450, 450, 50);

A bit more complex usage example

external_components:
  - source:
      type: git
      url: https://github.com/vbaksa/esphome
      ref: dev
    components: [lilygo_t5_47_display]

display:
  - platform: lilygo_t5_47_display
    id: mypaperscreen 
    landscape: true
    temperature: 23
    clear: false
    update_interval: 4s
    pages:
      - id: page1
        lambda: |-
          id(mypaperscreen).clear();
          it.line(0, 0, 100, 50);

@Plawasan
Copy link

Plawasan commented Jan 2, 2022

lilygo_t5_47_display

Tested, works!

  • 'clear: false' is exactly what I needed to keep the display from going blank when the ESP wakes up from deep sleep, that's awesome however
  • the redraw "routine" seems to only fill the screen once with blank/fill and then draws the text, on my display that for some reason leaves the parts of the screen that are supposed be blank about 20% dark (after a couple secs) - this happens regardless of whether i use 'clear: false' or not. With the component provided by tiaanv this doesn't happen - it refreshes the screen about 4 times and the display then stays completely clear (I mean the parts that are supposed to be clear) even after the esp goes to deep sleep
  • for some reason that I don't really understand I get nonsensical values for battery voltage when using your display component:

This is how I get the values:

  - platform: adc
    pin: GPIO36
    name: "${esp_name} Battery Voltage"
    id: batt_volt
    attenuation: 11db
    update_interval: never
    filters:
      - multiply: 2

  - platform: template
    name: "${esp_name} Battery"
    id: batt
    unit_of_measurement: "%"
    accuracy_decimals: 0
    device_class: battery
    lambda: |-
      int y = (1-(4.1-id(batt_volt).state)/(4.1-3.3))*100;
      if (y < 100) {return y;} else {return 100;};
    update_interval: never

and this is what I get with lilygo_t5_47_display:

[08:57:32][D][sensor:113]: 'ESP Display Battery Voltage': Sending state 0.28400 V with 2 decimals of accuracy
[08:57:32][D][sensor:113]: 'ESP Display Battery': Sending state -376.00000 % with 0 decimals of accuracy

Simply changing platform back to tiaanv's t547 gives me the correct readings again:

[08:59:59][D][sensor:113]: 'ESP Display Battery Voltage': Sending state 3.94200 V with 2 decimals of accuracy
[08:59:59][D][sensor:113]: 'ESP Display Battery': Sending state 80.00000 % with 0 decimals of accuracy

So very selfishly the ideal solution for me would be implementing the 'clear: false' option in tiaanv's version of t547 :)

@tiaanv
Copy link

tiaanv commented Jan 2, 2022

I find that even with my component when I power off the display, the ink begins to "bleed" I think this has to do with the the way the display works... I have tested @vbaksa s version, and I think it works much better. The only funny thing I notice is that the update cycle takes 4 seconds, even though it/s partial, which should be very quick... Haven't looked at the code...

As far as the clear setting is concerned, I don't think it would really work well with my version, as I do a full display redraw in any event...
potentially, what you can do as a workaround to "clear" the screen is to draw a full-screen rectangle on/off/on/off. basically simulating a clear...

I think it would be good to invest further development effort into his version. I will play around a bit with deep sleep and see what can be done. As far as the Voltage is concerned. I'm pretty sure somewhere in the code, the EPDY library messes with the VREF because for some displays it uses temp sensor. Perhaps that's the cause for the voltage ref. Irrespective.. should be simple to work around that also... simply use the scaling factor, until we can figure it out... Provided it's actually reading the correct pin etc...

@vbaksa
Copy link

vbaksa commented Jan 2, 2022

One more update.

I added separate battery voltage measurement component "lilygo_t5_47_battery". It is based on EPDY library code. As @tiaanv mentioned before - it is messing up VREF, so keeping it as separate component.

Usage sample below:

external_components:
  - source:
      type: git
      url: https://github.com/vbaksa/esphome
      ref: dev
    components: [lilygo_t5_47_battery]

sensor:
  - platform: lilygo_t5_47_battery
    update_interval: 5s
    voltage:
      name: "Battery Voltage"

@Plawasan
Copy link

Plawasan commented Jan 2, 2022

Updated my config to:

external_components:
  - source:
      type: git
      url: https://github.com/vbaksa/esphome
      ref: dev
    components: [lilygo_t5_47_display, lilygo_t5_47_battery]

I was getting errors about missing init.py in my local repo, had to temporarily add a refresh: 5s line to the component definition to force it to get the repo again..

I've updated my battery voltage sensor to use the platform, got this error:

/home/martin/esphome/esp-display.yaml:248:34: error: 'class esphome::lilygo_t5_47_battery::Lilygot547Battery' has no member named 'state'
       int y = (1-(4.1-id(batt_volt).state)/(4.1-3.3))*100;

When I got rid of the lines that work with the sensor I can see it returns the correct value but it seems to be missing the members that allow it to be used same as other sensors.. i think?

[15:49:34][D][sensor:113]: 'ESP Display Battery Voltage': Sending state 4.06435 V with 2 decimals of accuracy

Bleeding issue is still there...

@vbaksa
Copy link

vbaksa commented Jan 2, 2022

@Plawasan - try something like below for templating battery voltage measurements

sensor:
  - platform: lilygo_t5_47_battery
    id: battery
    voltage:
      name: "Battery Voltage"
  - platform: template
    name: "${esp_name} Battery"
    id: batt
    unit_of_measurement: "%"
    accuracy_decimals: 0
    device_class: battery
    lambda: |-
      int y = (1-(4.1-id(battery).voltage->state)/(4.1-3.3))*100;
      if (y < 100) {return y;} else {return 100;};

@Plawasan
Copy link

Plawasan commented Jan 2, 2022

@vbaksa - OK, that worked (after I remembered to refresh the repo again...).. thanks!

So really the only issue I see now is the display bleeding, I created 2 additional pages, one blank, one all black and I have the display cycle through them before displaying the main page - the bleeding still occurs. I don't think this is the issue, even without this the display always starts perfectly clear after the update and then it fades. I can't figure out whether it happens when the ESP goes to deep sleep but it seems to me it has something to do with power, it's never an issue when I have the display connected via USB, it only happens when it's running on battery power (even 100% charged)

btw I wanted to return my display back to the previous config (- platform: t547) but keep using your component for the battery, now I'm getting a ton of errors of duplicate definitions - is that solvable?

@vbaksa
Copy link

vbaksa commented Jan 2, 2022

Few more updates:

  • Updated init order, so display is initialized much earlier. Should fix delay on startup.
  • Fixed shutdown hook and added epd_deinit() function call. This should ensure display shutdown before deep sleep.

@Plawasan - regarding display "bleeding" issue you are getting. Is it the same as vroland/epdiy#92

@Plawasan
Copy link

Plawasan commented Jan 2, 2022

Few more updates:

  • Updated init order, so display is initialized much earlier. Should fix delay on startup.
  • Fixed shutdown hook and added epd_deinit() function call. This should ensure display shutdown before deep sleep.

@Plawasan - regarding display "bleeding" issue you are getting. Is it the same as vroland/epdiy#92

Yep, sounds like exactly the same issue... I never had that problem using @tiaanv 's driver..

@geekuillaume
Copy link

I also have the same issue of display "bleeding", not a lot when running with USB-C but more pronounced when using a battery. Everything else seems to run fine.

I tried using the new ESP-IDF mode in my configuration but got a problem related to a header from epdiy not being found. I couldn't understand why.

Here's a preview of my setup:
IMG_20220105_135320

@NeilS1966
Copy link

I have the touch panel for this display. What would be required to implement touch into this build?
It would be pretty awesome to be able to place a few ON/OFF buttons.

@kaweksl
Copy link

kaweksl commented Jan 8, 2022

Screen bleeding is caused by switching screen off to early. This board is designed in a way that if there is USB power then screen has power all the time ( indicated by blue led) but on battery, power to screen is controlled by driver.

Simply delay must be added before epd_poweroff, or maybe there is way to ask if refresh is completed

@vbaksa
Copy link

vbaksa commented Jan 8, 2022

Screen bleeding is caused by switching screen off to early. This board is designed in a way that if there is USB power then screen has power all the time ( indicated by blue led) but on battery, power to screen is controlled by driver.

Simply delay must be added before epd_poweroff, or maybe there is way to ask if refresh is completed

@kaweksl - thanks for the info. A delay can be added quite easily. However, the question is - how long it should be delayed before calling epd_poweroff ?

@rafuz
Copy link

rafuz commented Dec 22, 2023

Anyone else having issues building with 2023.12.x ?

<snip>

  File "/data/external_components/256a5785/esphome/components/lilygo_t5_47/display/__init__.py", line 37, in to_code
    await display.register_display(var, config)
  File "/esphome/esphome/components/display/__init__.py", line 119, in register_display
    await cg.register_component(var, config)
  File "/esphome/esphome/cpp_helpers.py", line 56, in register_component
    raise ValueError(
ValueError: Component ID t5_display was not declared to inherit from Component, or was registered twice. Please create a bug report with your configuration.

Yes I have the same problem with @ashald component.

@llamaonaskateboard
Copy link

llamaonaskateboard commented Dec 23, 2023

2023.12.x apparently changed how display components need to be implemented.
Here's an example of another external_component being fixed: landonr/lilygo-tdisplays3-esphome#46

Until @ashald does an update, you'll need to manually edit your local tree, eg. for me it was under .esphome/external_components/192a75c5/esphome/components/lilygo_t5_47/display/.
In addition to the same changes as the linked PR, you'll also need to add one more line to the top of __init__.py:
from esphome.const import __version__ as ESPHOME_VERSION

Edit: Turns out I'm actually using @kasdk3's component but the changes above would still apply for @ashald's component.

@daernsinstantfortress
Copy link

daernsinstantfortress commented Dec 25, 2023

@llamaonaskateboard Thank you, that's extremely useful. I've fixed in my local fork and raised a pull request for @ashald so hopefully he can merge this for others to be able to use.

If anyone else is impatient and doesn't want to wait for this merge, they can use my repo in the meantime:

external_components:
  - source: github://daernsinstantfortress/esphome-lilygo-t5-47@lilygo-t5-47
    components:
      - lilygo_t5_47

Please note - I am not maintaining this going forward, it's simply here as a convenience for building my own devices!

@lukbe
Copy link

lukbe commented Dec 29, 2023

@llamaonaskateboard Thank you, that's extremely useful. I've fixed in my local fork and raised a pull request for @ashald so hopefully he can merge this for others to be able to use.

If anyone else is impatient and doesn't want to wait for this merge, they can use my repo in the meantime:

external_components:
  - source: github://daernsinstantfortress/esphome-lilygo-t5-47@lilygo-t5-47
    components:
      - lilygo_t5_47

Please note - I am not maintaining this going forward, it's simply here as a convenience for building my own devices!

With your fork i have old issue with discplaybuffer :(

INFO ESPHome 2023.12.5
INFO Reading configuration /config/esphome/esp-display.yaml...
INFO Detected timezone 'Europe/Prague'
INFO Generating C++ source...
Traceback (most recent call last):
File "/usr/local/bin/esphome", line 33, in
sys.exit(load_entry_point('esphome', 'console_scripts', 'esphome')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/esphome/esphome/main.py", line 1041, in main
return run_esphome(sys.argv)
^^^^^^^^^^^^^^^^^^^^^
File "/esphome/esphome/main.py", line 1028, in run_esphome
rc = POST_CONFIG_ACTIONS[args.command](args, config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/esphome/esphome/main.py", line 407, in command_compile
exit_code = write_cpp(config)
^^^^^^^^^^^^^^^^^
File "/esphome/esphome/main.py", line 192, in write_cpp
generate_cpp_contents(config)
File "/esphome/esphome/main.py", line 204, in generate_cpp_contents
CORE.flush_tasks()
File "/esphome/esphome/core/init.py", line 679, in flush_tasks
self.event_loop.flush_tasks()
File "/esphome/esphome/coroutine.py", line 246, in flush_tasks
next(task.iterator)
File "/esphome/esphome/main.py", line 184, in wrapped
await coro(conf)
File "/data/external_components/7ad5742f/esphome/components/lilygo_t5_47/display/init.py", line 48, in to_code
config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'esphome.components.display' has no attribute 'DisplayBufferRef'. Did you mean: 'DisplayBuffer'?

@Micha-Btz
Copy link

Has anyone a working fork? I can't get mine working again.

@wryandginger
Copy link

Here's my current working config that compiled this morning:

esphome:
  name: paper1
  friendly_name: Paper1Screen
  platformio_options:
    board_build.f_flash: 80000000L
    #board_upload.flash_size: 16MB
    board_build.flash_mode: qio
    board_build.psram_type: opi
    board_build.partitions: default_16MB.csv
    board_build.arduino.memory_type: qio_opi

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino
    version: latest
  flash_size: 16MB

i2c:
  sda: GPIO17
  scl: GPIO18
  # There is some problems with i2c scan so turn scan off if problem appear on your board
  scan: false
  id: bus_a

external_components:
  - source: github://bvarick/esphome-lilygo-t547plus
    components: ["t547"]
  - source: github://kaeltis/esphome-lilygo-t547plus
    components: ["lilygo_t5_47_battery"]

@daernsinstantfortress
Copy link

Mine clean building ok with ESPHome 2023.12.9, the above forked library and my own setup. Have you done a clean compile?

@Micha-Btz
Copy link

@daernsinstantfortress

INFO ESPHome 2023.12.9
INFO Reading configuration /config/esphome/lilygo.yaml...
INFO Generating C++ source...
Traceback (most recent call last):
  File "/usr/local/bin/esphome", line 33, in <module>
    sys.exit(load_entry_point('esphome', 'console_scripts', 'esphome')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/__main__.py", line 1041, in main
    return run_esphome(sys.argv)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/__main__.py", line 1028, in run_esphome
    rc = POST_CONFIG_ACTIONS[args.command](args, config)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/__main__.py", line 458, in command_run
    exit_code = write_cpp(config)
                ^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/__main__.py", line 192, in write_cpp
    generate_cpp_contents(config)
  File "/esphome/esphome/__main__.py", line 204, in generate_cpp_contents
    CORE.flush_tasks()
  File "/esphome/esphome/core/__init__.py", line 679, in flush_tasks
    self.event_loop.flush_tasks()
  File "/esphome/esphome/coroutine.py", line 246, in flush_tasks
    next(task.iterator)
  File "/esphome/esphome/__main__.py", line 184, in wrapped
    await coro(conf)
  File "/data/external_components/7ad5742f/esphome/components/lilygo_t5_47/display/__init__.py", line 48, in to_code
    config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void
                           ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'esphome.components.display' has no attribute 'DisplayBufferRef'. Did you mean: 'DisplayBuffer'?

with your fork I have the same error as with my own. I have clean the build files.

@JB10862
Copy link

JB10862 commented Feb 23, 2024

@daernsinstantfortress

INFO ESPHome 2023.12.9
INFO Reading configuration /config/esphome/lilygo.yaml...
INFO Generating C++ source...
Traceback (most recent call last):
  File "/usr/local/bin/esphome", line 33, in <module>
    sys.exit(load_entry_point('esphome', 'console_scripts', 'esphome')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/__main__.py", line 1041, in main
    return run_esphome(sys.argv)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/__main__.py", line 1028, in run_esphome
    rc = POST_CONFIG_ACTIONS[args.command](args, config)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/__main__.py", line 458, in command_run
    exit_code = write_cpp(config)
                ^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/__main__.py", line 192, in write_cpp
    generate_cpp_contents(config)
  File "/esphome/esphome/__main__.py", line 204, in generate_cpp_contents
    CORE.flush_tasks()
  File "/esphome/esphome/core/__init__.py", line 679, in flush_tasks
    self.event_loop.flush_tasks()
  File "/esphome/esphome/coroutine.py", line 246, in flush_tasks
    next(task.iterator)
  File "/esphome/esphome/__main__.py", line 184, in wrapped
    await coro(conf)
  File "/data/external_components/7ad5742f/esphome/components/lilygo_t5_47/display/__init__.py", line 48, in to_code
    config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void
                           ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'esphome.components.display' has no attribute 'DisplayBufferRef'. Did you mean: 'DisplayBuffer'?

with your fork I have the same error as with my own. I have clean the build files.

Mika-Btz, I am also getting the same error as you. Did you find a solution?

@Micha-Btz
Copy link

For me my fork works, but you have to clean the build files.
Clean files in the esphome UI doesn't work. I have done this
https://www.youtube.com/watch?v=aI3Pndv2Oo0

@madimadi
Copy link

madimadi commented Mar 1, 2024

AttributeError: module 'esphome.components.display' has no attribute 'DisplayBufferRef'. Did you mean: 'DisplayBuffer'?

I have a fix on that, it compiles without error:

external_components:
  - source: github://madimadi/esphome-lilygo-t5-47@lilygo-t5-47
    components: ["lilygo_t5_47"]

Since I have no plans to maintain my fork, I have created ashald/esphome#5 . Until the PR gets merged this fork remains for sure.

@JB10862
Copy link

JB10862 commented Mar 11, 2024

I tried madimadi’s fork and it complied with no issues, however it only supports 2 color display. Anyone know of a working fork that supports 16 grayscale? I have the original display and many of the forks don’t seem to go into low power mode when deep sleep is called; madimadi’s does.

@dabalroman
Copy link

dabalroman commented Apr 15, 2024

I tried madimadi’s fork and it complied with no issues, however it only supports 2 color display. Anyone know of a working fork that supports 16 grayscale? I have the original display and many of the forks don’t seem to go into low power mode when deep sleep is called; madimadi’s does.

It works perfectly fine with nickolay fork and standard images / online_image:

esp32:
  variant: esp32s3
  board: lilygo-t5-47-plus

external_components:
  - source: github://nickolay/esphome-lilygo-t547plus
    components: ["t547"]
  - source: github://kaeltis/esphome-lilygo-t547plus
    components: ["lilygo_t5_47_battery"]
  - source: github://guillempages/esphome@online_image_buffer
    components: [online_image]

I'm using lilygo T5 V2.3 with .png images quantized to 16 colors. ESPHome v2024.3.2.

@xxLeoxx93
Copy link

xxLeoxx93 commented May 2, 2024

Hey yall, I've been at working at getting the touch screen to work for a while now and i just figured it out by looking at the schematics.. it's GPIO47!!! not GPIO09. Works perfectly now with ESPHome's lilygo_t5_47 touchscreen component.

GPIO09 was for the RTC. You want to look at the schematic for the touchscreen connector, there you will see the change from IO13 to IO47.

i2c:
  sda: GPIO18
  scl: GPIO17
  id: bus_a

touchscreen:
  - platform: lilygo_t5_47
    id: lilygo_touchscreen
    interrupt_pin: GPIO47
    address: 0x5A
    setup_priority: -100
    on_touch:
      then:
        - display.page.show_next: 't5_display'
        - component.update: 't5_display'

Hey, I'm on my way to get the V2.4 working and my code looks like this:

i2c:
  sda: GPIO18
  scl: GPIO17
  id: bus_a

touchscreen:
  - platform: lilygo_t5_47
    id: lilygo_touchscreen
    interrupt_pin: GPIO47
    address: 0x5A
  #setup_priority: -100
    on_touch:
      - logger.log:
          format: Touch at (%d, %d)
          args: ["touch.x", "touch.y"]

However no luck so far. Am I correct that this "should" work or am I missing something?
Thanks!
image
image

@Plawasan
Copy link

I came back to my code after a while and wanted to make some minor updates but I can't really get any combination of the external components and the display definition to compile.. .can somebody please post the relevant parts of their code that compiles with the latest ESPHome and includes both the display and the battery? Thanks!

@arminecek
Copy link

Hi,
What's your experience with pixel burning? I have sings of burned black/white pixels after one month of use my home dashboard. update_interval : 60s, two pages....
I tried removing it by uploading the firmware created by Xiyuan´s (screen_repair) but unsuccessfully.

Is posible to buy only new screen - without S3 board?

@dabalroman
Copy link

The pixel burn on this display is severe on frequent updates. I advise you to update at most every 5 minutes. When using big fonts it's best to circle the layout around the screen to prevent rendering in the same spot again and again. I've ended up on displaying current time in 4 different corners of the screen switching every 15 minutes. I was not successful in removing
the burn marks in any way.
You can see the burn under the digits in the attached photo.
IMG_20240512_231737356

@Vybo
Copy link

Vybo commented Jun 11, 2024

@dabalroman I have severe burn-in in the display as well, however only when the display/board is sleeping. If you use the display on external power and don't put it in deep sleep, the display will hold the white values properly and the burn-in goes away. However as soon as it enters deep sleep, you'll see the burn-in again.

I've tested running the display on external power for 2 months now to see if it fixes the burn-in more, but it doesn't.

@styphonthal
Copy link

styphonthal commented Jun 11, 2024

I have the lilygo t5-4.7 (not plus). I have tried: https://gist.github.com/Plawasan/f4fdc1480534ca4a50bcfbdf495b9448 but I keep getting a compiling error:

File "/data/external_components/6d3a8382/esphome/components/lilygo_t5_47_display/display.py", line 40, in to_code
await display.register_display(var, config)
File "/esphome/esphome/components/display/init.py", line 123, in register_display
await cg.register_component(var, config)
File "/esphome/esphome/cpp_helpers.py", line 56, in register_component
raise ValueError(
ValueError: Component ID t5_display was not declared to inherit from Component, or was registered twice. Please create a bug report with your configuration.

@dabalroman
Copy link

@styphonthal this works for me:

external_components:
  - source: github://nickolay/esphome-lilygo-t547plus
    components: ["t547"]

  - source: github://kaeltis/esphome-lilygo-t547plus
    components: ["lilygo_t5_47_battery"]

(...)

display:
  - platform: t547
    id: my_display
    rotation: 180
    update_interval: 24h
    lambda: |-

I didn't bother to try to make it work with one repo, maybe there is a way to do that.

@styphonthal
Copy link

@styphonthal this works for me:

external_components:
  - source: github://nickolay/esphome-lilygo-t547plus
    components: ["t547"]

  - source: github://kaeltis/esphome-lilygo-t547plus
    components: ["lilygo_t5_47_battery"]

(...)

display:
  - platform: t547
    id: my_display
    rotation: 180
    update_interval: 24h
    lambda: |-

So this worked for my display, but the battery reports really off numbers.

@fuef
Copy link

fuef commented Aug 30, 2024

EDIT: Tagged the OP @xxLeoxx93

Hey, I'm on my way to get the V2.4 working and my code looks like this:

touchscreen:
    <snip />
    address: 0x5A
    <snip />

V2.4 is lilygo-t547plus (esp32-s3). Solution, published by @alexwide in parallel thread #1960 works well. It uses address: 0x5d instead of 0x5A.

touchscreen log
[23:24:16][C][gt911.touchscreen:028]: Setting up GT911 Touchscreen...
[23:24:16][D][gt911.touchscreen:036]: Read from switches: 0x05
[23:24:16][D][touchscreen:016]: Attach Touch Interupt
[23:24:16][D][gt911.touchscreen:057]: calibration max_x/max_y 540/960
[23:24:16][C][gt911.touchscreen:067]: GT911 Touchscreen setup complete
[23:24:16][I][app:062]: setup() finished successfully!
[23:24:16][W][touchscreen:032]: Touch Polling Stopped. You can safely remove the 'update_interval:' variable from the YAML file.
[23:24:16][I][app:100]: ESPHome version 2024.8.1 compiled on Aug 30 2024, 22:54:45
[23:28:56][V][touchscreen:117]: Touch status: is_touched=1, was_touched=0
[23:28:56][V][touchscreen:120]: Touch status: 0/1: raw:( 210, 454,   0) calc:(373, 255)
[23:28:56][D][main:113]: Touch Screen Touched
[23:28:57][V][touchscreen:117]: Touch status: is_touched=1, was_touched=1
[23:28:57][V][touchscreen:120]: Touch status: 0/2: raw:( 210, 454,   0) calc:(373, 255)
[23:28:57][V][touchscreen:117]: Touch status: is_touched=1, was_touched=1
[23:28:57][V][touchscreen:120]: Touch status: 0/2: raw:( 210, 454,   0) calc:(373, 255)
[23:28:57][V][touchscreen:117]: Touch status: is_touched=1, was_touched=1
[23:28:57][V][touchscreen:120]: Touch status: 0/2: raw:( 210, 454,   0) calc:(373, 255)
[23:28:57][V][touchscreen:117]: Touch status: is_touched=1, was_touched=1
[23:28:57][V][touchscreen:120]: Touch status: 0/2: raw:( 210, 454,   0) calc:(373, 255)
[23:28:57][V][touchscreen:117]: Touch status: is_touched=1, was_touched=1
[23:28:57][V][touchscreen:120]: Touch status: 0/2: raw:( 210, 454,   0) calc:(373, 255)
[23:28:57][V][touchscreen:117]: Touch status: is_touched=1, was_touched=1
[23:28:57][V][touchscreen:120]: Touch status: 0/2: raw:( 210, 454,   0) calc:(373, 255)
[23:28:57][V][touchscreen:117]: Touch status: is_touched=1, was_touched=1
[23:28:57][V][touchscreen:120]: Touch status: 0/2: raw:( 210, 454,   0) calc:(373, 255)
[23:28:57][V][touchscreen:117]: Touch status: is_touched=0, was_touched=1
[23:28:57][V][touchscreen:120]: Touch status: 0/6: raw:( 210, 454,   0) calc:(373, 255)
[23:28:57][V][touchscreen:117]: Touch status: is_touched=0, was_touched=0
[23:28:57][V][touchscreen:117]: Touch status: is_touched=0, was_touched=0

@xxLeoxx93
Copy link

Anyone using the latest Homeassistant + ESPHome Addon configuration? It seems like they changed the file handling. Not it doesn't find the board anymore and the folder structure is completely different.
Anyone managed to get it running?

@daernsinstantfortress
Copy link

Anyone using the latest Homeassistant + ESPHome Addon configuration? It seems like they changed the file handling. Not it doesn't find the board anymore and the folder structure is completely different. Anyone managed to get it running?

Just upgraded to ESPHome 2024.10.0, running HA 2024.10.2 and rebuilt one of my LilyGo screens - built cleanly first time with no issues.

@xxLeoxx93
Copy link

@daernsinstantfortress May I ask where you placed the board file? The original folder structure does not exist for me.

@daernsinstantfortress
Copy link

@daernsinstantfortress May I ask where you placed the board file? The original folder structure does not exist for me.

Below the HA config folder in /esphome/<file>.yaml. Otherwise, nothing exciting:

substitutions:
  esp_name: Office Display #Device Name
  esp_hostname: "office-display"
  run_time: 1min #can be as long as needed to get data 
  sleep_time: 5min # normal sleep time
  night_sleep_time: 6h # 1st sleep time after midnight

esphome:
  name: ${esp_hostname}
  includes:
    - common.h

esp32:
  board: esp32dev
  framework:
    type: arduino

logger:

api:
  encryption:
    key: 

json:

ota:
  - platform: esphome
    password: 

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

external_components:
  - source: github://daernsinstantfortress/esphome-lilygo-t5-47@lilygo-t5-47
    components:
      - lilygo_t5_47

@xxLeoxx93
Copy link

xxLeoxx93 commented Oct 21, 2024

Thanks! I 'll try that.
I always used a custom board in the past - so this is not needed I suppose?

esphome:
  name: liligo-t5-47-epaper-plus
  platformio_options:
    board_dir: boards
    #include https://github.com/Xinyuan-LilyGO/LilyGo-EPD47/blob/master/platformio/boards/lilygo-t5-47-plus.json as custom board
    board: lilygo-t5-47-plus

esp32:
  variant: esp32s3
  board: lilygo-t5-47-plus

@Tasshack
Copy link

Tasshack commented Nov 25, 2024

Checkout this mod on S3 model for fast partial and full refresh using latest version of the EPDiy library.

Xinyuan-LilyGO/LilyGo-EPD47#93 (comment)

@random-0110-dude
Copy link

@dabalroman Love your case! Could your please share 3D files for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests