feature-requests icon indicating copy to clipboard operation
feature-requests copied to clipboard

Support for ILI9342C display (M5 stack Core 2 display)

Open sj3fk3 opened this issue 4 years ago • 40 comments

Describe the problem you have/What new integration you would like The dev branch currently does support ILI9341 (but) the new M5Stack Core 2 device uses the slightly different ILI9342C display drivers. I would very much like to use the M5stack Core2 with ESPhome.

From what I have read, it is really similar to the ILI9341 with some some small changes.

http://www.buydisplay.com/download/ic/ILI9342.pdf

Please describe your use case for this integration and alternatives you've tried:

I cannot get the M5stack Core 2 display to work with the ILI9341 settings, it might need some slight changes to also support ILI9342C or it might also be that the changes from the old m5stack to the "core 2" are interfering. Notably setting of the display led is not done by a gpio pin, but by an AXP192?

https://docs.m5stack.com/#/en/core/core2?id=pinmap

Additional context This discussion could help: https://www.eevblog.com/forum/microcontrollers/2-4-tft-screen-ili9342-problems-help-me-please-!/

and: https://forum.arduino.cc/index.php?topic=473885.0

sj3fk3 avatar Jan 07 '21 13:01 sj3fk3

I would love to see this as well. I don't have time at the moment, but may take a look at getting this implemented at some point in the next few weeks.

kelchm avatar Feb 04 '21 23:02 kelchm

I would love to see this as well. I don't have time at the moment, but may take a look at getting this implemented at some point in the next few weeks.

Do you have a Core 2? I'd be willing to ship you one if needed

sj3fk3 avatar Feb 15 '21 21:02 sj3fk3

I think it's more than just the display. The Core 2 also has a touch controller.

marcvl64 avatar Mar 09 '21 01:03 marcvl64

Yes, the support of ILI9342C would be highly desirable maybe even without a touch screen as a first step.

dummylabs avatar Mar 12 '21 15:03 dummylabs

Planned as one of the next components as I have some m5core2 here....

Not on the top list...but it also requires AXP PMIOC support as some of the control lines for the display run over this PMIC chip...

richardklingler avatar May 17 '21 11:05 richardklingler

Would be wonderful to have Core2 support as its a very neat boxed product ready to go... any chance of this in the near future? Tasmota now has the display part of this but not the AXP PMIOC...

scargill avatar Oct 03 '21 18:10 scargill

+1 for support for AXP 192, the various libraries (custom_components) I have searched and tested across github & gitlab all result in odd and unexpected behaviour.

Without this, half the functionality of the M5Stack Core2, M5Stick-C (and the respective PLUS model), and perhaps some other M5Stack boards, is completely missing, which makes the entire platform unusable.

The M5Stack line of products seem to be making microelectronics more accessible to the general public, it really does make a lot of sense to add support

martydingo avatar Dec 07 '21 22:12 martydingo

Could not agree more. It would be very nice when Nabu Casa and M5Core would do a joint venture. IMHO it's the missing link.

sj3fk3 avatar Dec 08 '21 06:12 sj3fk3

I think the main issue is the reset for the display on the Core2 is done on a GPIO line of the axp192 instead of the esp32, so there needs to be some way for the display functions to reset the display via the axp192. I've been able to take some axp192 m5 stick code and alter it to power up the display, power the motor on and off, as well as send resets to the display, but I am not sure how to get the existing display library to use the axp192 code to reset the display. In looking at the aurdino library that works with the core2 display, they appear to be using ili9341 library with this display other than the reset method.

granvillebarker avatar Dec 17 '21 04:12 granvillebarker

+1 for M5Stack Core 2 support

trunneml avatar Jan 08 '22 15:01 trunneml

I've recently been able to get the core2 to work using the standard ili9341 driver and a custom axp192 component, but it only works from power up. Any reboot display is lost.

granvillebarker avatar Jan 08 '22 16:01 granvillebarker

I've recently been able to get the core2 to work using the standard ili9341 driver and a custom axp192 component, but it only works from power up. Any reboot display is lost.

Could you share your code? I'm currently trying the same. 😀

trunneml avatar Jan 08 '22 16:01 trunneml

There's a custom axp192 component on gitlab that works with the M5 Stick C Plus. Seems to work well.

https://gitlab.com/geiseri/esphome_extras/-/tree/main/components/axp192

cmet7 avatar Jan 08 '22 23:01 cmet7

@granvillebarker I tried the turn on the display but failed. Could you share your axp192 component?

trunneml avatar Jan 09 '22 19:01 trunneml

I think the main issue is the reset for the display on the Core2 is done on a GPIO line of the axp192 instead of the esp32, so there needs to be some way for the display functions to reset the display via the axp192.

This is an annoyance with Core2. However the hard reset does not necessarily need be in the display functions. You can do it while initialising the board and then later do only soft reset in the display functions. This is not optimal but atleast there is no need to add axp192 dependency to the display functions.

tuupola avatar Jan 10 '22 12:01 tuupola

I think the main issue is the reset for the display on the Core2 is done on a GPIO line of the axp192 instead of the esp32, so there needs to be some way for the display functions to reset the display via the axp192.

This is an annoyance with Core2. However the hard reset does not necessarily need be in the display functions. You can do it while initialising the board and then later do only soft reset in the display functions. This is not optimal but atleast there is no need to add axp192 dependency to the display functions.

I do believe the obstacle is the path, and the obstacle is adding in support for the AXP192 modules, so it can interface with other modules. We shouldn't be trying to add in code for the AXP192 across loads of modules, rather modules should be able to invoke the AXP192 module to achieve their respective ends.

martydingo avatar Jan 26 '22 14:01 martydingo

I do believe the obstacle is the path, and the obstacle is adding in support for the AXP192 modules, so it can interface with other modules. We shouldn't be trying to add in code for the AXP192 across loads of modules, rather modules should be able to invoke the AXP192 module to achieve their respective ends.

I've seen where an axp192 module is in the works by one of the devs, but I don't think that has anything to do with the display issues. The ili9341 driver works for me, if you power the module off and back on, but not if the soft reboots or the reset button is pressed, example on my github. Other projects like openhasp work, so it's gotta be something simple.

granvillebarker avatar Jan 26 '22 14:01 granvillebarker

I do believe the obstacle is the path, and the obstacle is adding in support for the AXP192 modules, so it can interface with other modules. We shouldn't be trying to add in code for the AXP192 across loads of modules, rather modules should be able to invoke the AXP192 module to achieve their respective ends.

I've seen where an axp192 module is in the works by one of the devs, but I don't think that has anything to do with the display issues. The ili9341 driver works for me, if you power the module off and back on, but not if the soft reboots or the reset button is pressed, example on my github. Other projects like openhasp work, so it's gotta be something simple.

AXP192 is a power management device. You are seeing issues with power management. Interfacing with the display may work using the ILI9341 driver, as after all, it is the driver. However, if the display is not in a state where the AXP192 needs to be communicated with to then interact with the ILI9341, then it won't work, the AXP192 will need initializing to then communicate with the ILI9341, as far as I understand.

This has been the case on every M5 device I've used with ESPHome with an AXP192. I do believe interfacing with an AXP192 if one exists, before proceeding with any initialisation of the ILI9341, is what's required.

martydingo avatar Jan 26 '22 16:01 martydingo

+1

DarkBeardRUS avatar Apr 02 '22 15:04 DarkBeardRUS

ESP is awesome right up until you want to put one in the Wife's living areas and she think's its dumb looking. these don't look bad at all. especially the stack. definitely excited for movement on this.

kpurintun avatar Apr 10 '22 03:04 kpurintun

I cannot help... but found this https://github.com/m5stack/M5Unified Maybe can push the integration into esphome?

Thanks

codedmind avatar Apr 25 '22 12:04 codedmind

+1 here... bought this M5stack development kit not realizing it doesn't work with esphome :(

ultimateguy avatar May 07 '22 03:05 ultimateguy

Check out Openhasp, it's one way to integrate the M5Core2 with Home Assistant until support is added.

granvillebarker avatar May 07 '22 13:05 granvillebarker

I can't help integrate it into Esphome, but if someone can development tasmota version already have an auto configuration option for m5stack tough that works

codedmind avatar May 07 '22 13:05 codedmind

Still trying to get this to work without much luck. Please add support for M5 Stack core 2!!

RamEliC avatar Jun 04 '22 01:06 RamEliC

https://github.com/esphome/feature-requests/issues/1721

nagyrobi avatar Jul 01 '22 11:07 nagyrobi

Does anyone have this partially working?

KTibow avatar Jul 10 '22 13:07 KTibow

+1 from me. As per the feedback this is a bigger issue, a lot of the M5 devices include a high density of really useful sensors and features and are well packaged, however most of these features can only be enabled via the axp192 power managment chip, (screen, touch, microphone, amplifier, speaker, etc. Also some of these are only accessiable via a p192 GPIO pins which can’t be referenced without the axp192 component.

I have tried a number of custom components for my M5core2 and have managed to get some components to work, however there are always unexpected results that make the solution unworkable, (the solution in the feed above allows speakers and less to work but switches on a constant vibration module).

There is real potential to use the M5Core2 as a couscous assistant (i2s microphone, built in speaker media players for genie/ acorn - combined with screen, sensors and built in leds) but until the power management is fixed these can’t be accessed)

rasclatt-dot-com avatar Aug 06 '22 00:08 rasclatt-dot-com

+1 from me. As per the feedback this is a bigger issue, a lot of the M5 devices include a high density of really useful sensors and features and are well packaged, however most of these features can only be enabled via the axp192 power managment chip, (screen, touch, microphone, amplifier, speaker, etc. Also some of these are only accessiable via a p192 GPIO pins which can’t be referenced without the axp192 component.

I have tried a number of custom components for my M5core2 and have managed to get some components to work, however there are always unexpected results that make the solution unworkable, (the solution in the feed above allows speakers and less to work but switches on a constant vibration module).

There is real potential to use the M5Core2 as a couscous assistant (i2s microphone, built in speaker media players for genie/ acorn - combined with screen, sensors and built in leds) but until the power management is fixed these can’t be accessed)

I have gotten this to work with the display now, without that horrendous vibration.

In axp192.cpp, on line 10, there is the following:

void AXP192Component::setup() 
{
  begin(false, false, false, false, false);
}

Each false corresponds to a disableLDO variable. The vibration motor is on LDO2 on the Core2, so you can disable the motor by updating that line to the following:

void AXP192Component::setup() 
{
  begin(false, true, false, false, false);
}

My configuration is as follows:

esphome:
  name: m5stack-core2
  platform: ESP32
  board: m5stack-core-esp32

  includes:
   - /config/custom_components/axp192/axp192.h

wifi:
  ssid: "xxx"
  password: "xxx"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "M5Stack-Core2 Fallback Hotspot"
    password: "x"

substitutions:
  devicename: m5core2
  upper_devicename: M5Core2 

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

web_server:

# AXP192 power management - must be present to initialize TFT power on
sensor:
  - platform: axp192
    address: 0x34
    i2c_id: bus_a
    update_interval: 30s
    battery_level:
      name: "M5Core2 Battery Level"
      id: "m5core2_batterylevel"

  - platform: wifi_signal
    name: ${upper_devicename} WiFi Signal
    id: wifi_dbm
  - platform: uptime
    name: ${upper_devicename} Uptime

spi:
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO38
  
i2c:
   - id: bus_a
     sda: GPIO21
     scl: GPIO22
     scan: True

font:
  - file: 'fonts/arial.ttf'
    id: font1
    size: 8

# # builtin 80x160 TFT
display:
  - platform: ili9341
    model: M5STACK
    cs_pin: 5
    dc_pin: 15
    lambda: |-
      it.print(80, 0, id(font1), TextAlign::TOP_CENTER, "M5Stick Test");

And it works!

martydingo avatar Sep 03 '22 10:09 martydingo

And it works!

Just tried this and it's still not working after reboot.

cmet7 avatar Sep 03 '22 15:09 cmet7