M5Stick C Plus - Failure to Compile Firmware Image

I’ve spent a bit of time now trying to figure this out, to no avail. The template found here: M5Stack M5StickC PLUS | devices.esphome.io

…will not compile to a working install. The two issues that seem to be apparent are

  1. remote_transmitter - This has been documented in a few places that it causes compile time issues, so I commented this out.

  2. ...
    Building .pioenvs/m5stickcplus-00/bootloader.bin
    Creating esp32 image...
    Successfully created esp32 image.
    Generating partitions .pioenvs/m5stickcplus-00/partitions.bin
    Compiling .pioenvs/m5stickcplus-00/lib369/AsyncTCP-esphome/AsyncTCP.cpp.o
    <unicode string>: In lambda function:
    <unicode string>:128:31: error: 'ST77XX_WHITE' was not declared in this scope
    *** [.pioenvs/m5stickcplus-00/src/main.cpp.o] Error 1
    ========================= [FAILED] Took 34.83 seconds =========================
    

    In this case I’m not exactly sure what the issue is. I’ve looked for the error as outlined above, but it also seems like the firmware image was created successfully.

I’ve tried to compile with different board types and also by including and excluding the arduino framework configuration. Changing those variables seems to make no difference with the error above.

The ESPHome version is: 2023.12.8 (current as of this writing). Any help is much appreciated!

Here is the YAML in question:

esphome:
  name: m5stickcplus-00
  friendly_name: m5stickcplus-00

esp32:
  board: m5stick-c
  #board: m5stack-core-esp32
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: !secret api_encryption_m5stickcplus-00

ota:
  password: !secret ota_password

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "d31-00-esphome"
    password: !secret fallback_password

captive_portal:

# Enable Web Interface with Auth
web_server:
  port: 80
  auth:
    username: !secret web_server_username
    password: !secret web_server_password

external_components:
  - source: github://martydingo/esphome-axp192
    components: [axp192]

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

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO37
      inverted: true
    name: ${upper_devicename} Button A
    on_press:
      then:
        - light.turn_on: led1
    on_release:
      then:
        - light.turn_off: led1

  - platform: gpio
    pin:
      number: GPIO39
      inverted: true
    name: ${upper_devicename} Button B
    on_press:
      then:
        - light.turn_on: led1
    on_release:
      then:
        - light.turn_off: led1

light:
  - platform: monochromatic
    output:  builtin_led
    name: ${upper_devicename} Led
    id: led1

output:
  - platform: ledc
    pin: 10
    inverted: true
    id: builtin_led

#############################
### Causes compilation error
##
#remote_transmitter:
#  - pin:
#      number: GPIO9
#    carrier_duty_percent: 50%
#    id: internal
##
###

spi:
  clk_pin: GPIO13
  mosi_pin: GPIO15

i2c:
   - id: bus_a
     sda: GPIO21
     scl: GPIO22
     scan: True

font:
  - file: "gfonts://Roboto"
    id: roboto
    size: 12

# 1.14 inch, 135*240 Colorful TFT LCD, ST7789v2
display:
  - platform:  st7789v
    model: TTGO TDisplay 135x240
    cs_pin: GPIO5
    dc_pin: GPIO23
    reset_pin: GPIO18
    rotation: 270
    lambda: |-
      it.print(80, 0, id(roboto), ST77XX_WHITE, TextAlign::TOP_CENTER, "M5Stick Test");

i2s_audio:
  id: bus_i2s
  i2s_lrclk_pin: G26
  i2s_bclk_pin: G0

microphone:
  - platform: i2s_audio
    i2s_din_pin: GPIO34
    i2s_audio_id: bus_i2s
    adc_type: external
    pdm: true
    id: mic

I think I figured out my own ignorance of the display section - which is where the error was originating from. In the example I’m not exactly sure where the ST77XX_WHITE comes from, but that seems to be the root of the problem. I’ve successfully compiled the image by replacing the display section with the following:

color:
  - id: my_red
    red: 100%
    green: 3%
    blue: 5%
  - id: my_black
    red: 100%
    green: 100%
    blue: 100%

# 1.14 inch, 135*240 Colorful TFT LCD, ST7789v2
display:
  - platform:  st7789v
    model: TTGO TDisplay 135x240
    cs_pin: GPIO5
    dc_pin: GPIO23
    reset_pin: GPIO18
    rotation: 270
    lambda: |-
      it.fill(id(my_black));
      it.print(80, 0, id(roboto), id(my_red), TextAlign::TOP_CENTER, "TEST");

I haven’t tested on the device quite yet, but wanted to provide an update before anyone spent any time replying.

1 Like

Thanks, this worked for me too!

Now to figure out how to use the display within Home Assistant. :stuck_out_tongue:

Hi,
it’s also possible to do something like:

    lambda: |-
      auto mycolor = Color(255, 100, 100);
      it.print(0, 0, id(font1), mycolor, TextAlign::TOP_LEFT, "text");