How to debug ESPhome

Hi, I am new to ESPHome so perhaps there is a simple answer to my question.
I am wondering how to debug ESPHome code? The compiler crash often and I suspect it is due to my faulty code, but I get no feedback so it’s a bit hard to learn the new system/code.
In this specific example I try to display a text on the display of a ESP32 using a text_sensor, but whenever I make small changes to the code the compiler crashes. After removing all camera related code I can compile the following code:

esphome:
  name: ttgo-cam1

esp32:
  board: esp-wrover-kit
  framework:
    type: arduino
.
.
.

text_sensor:
  - platform: homeassistant
    name: "displaytext"
    entity_id: sensor.displaytext 
    id: displaytext

binary_sensor:
  - platform: gpio
    device_class: motion
    name: "PIR Sensor"
    pin: GPIO33

i2c:
  sda: 21
  scl: 22

font:
  - file: "Arial_Black.ttf"
    id: arial
    size: 20

display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x64"
    address: 0x3C
    rotation: 0
    lambda: |-
      it.print(0, 0, id(arial), "Hello World");

However the text_sensor is not visible in HA. My goal is to replace “Hello World” with text from the text_sensor.

Running on Home Assistant OS Raspberrypi4 with 1GB RAM and 64 GB SDcard:
Home Assistant 2022.9.7
Supervisor 2022.09.1
Operating System 9.0
Frontend 20220907.2 - latest
ESPHome is 2022.9.1

Thanks for your input.

You need to have created a sensor.displaytext in ha.

I created an input text entity in HA ( input_text.other_text) where I can write text, however I can’t figure out how to get the content visible on the ESP display. I tried different references id(displaytext).value .state etc. but it don’t work, see code below.

text_sensor:
  - platform: homeassistant
    name: "displaytext"
    entity_id: input_text.other_text
    id: displaytext

display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x64"
    address: 0x3C
    rotation: 0
    lambda: |-
        it.print(64, 54, id(arial), TextAlign::BASELINE_CENTER, id(displaytext));

The compiler crashes reported earlier were all related to limited memory on the machine, see https://community.home-assistant.io/t/esphome-killing-home-assistant/325939/15

Found the solution: id(displaytext).state.c_str());