Error compiling code for LCD display

I’m trying to get my ESP32-S2 board to display “Hello World” on a 16x2 LCD screen.

I have set up the i2c and display components as shown in the docs. https://esphome.io/components/display/lcd_display.html

esphome:
  name: lcd-test

esp32:
  board: esp32-s2-saola-1
  framework:
    type: esp-idf

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "mykey"

ota:
  password: "mypass"

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

  # Enable fallback hotspot in case wifi connection fails
  ap:
    ssid: "Lcd-Test Fallback Hotspot"
    password: "2lmMtQiEhCor"
    
i2c:
  sda: 8
  scl: 10
  
display:
  - platform: lcd_pcf8574
    dimensions: 16x2
    address: 0x3F
    lambda: |-
      it.print("Hello World!");

This is the error I get when trying to compile the code:

Compiling .pioenvs/lcd-test/src/esphome/components/lcd_base/lcd_display.o
In file included from src/esphome/components/lcd_base/lcd_display.cpp:1:
src/esphome/components/lcd_base/lcd_display.h:24:54: error: 'vector' in namespace 'std' does not name a template type
   void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
                                                      ^~~~~~
src/esphome/components/lcd_base/lcd_display.h:24:49: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
src/esphome/components/lcd_base/lcd_display.h:11:1:
+#include <vector>
 
src/esphome/components/lcd_base/lcd_display.h:24:49:
   void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
                                                 ^~~
src/esphome/components/lcd_base/lcd_display.h:24:60: error: expected ',' or '...' before '<' token
   void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
                                                            ^
src/esphome/components/lcd_base/lcd_display.h:68:26: error: 'vector' is not a member of 'std'
   std::map<uint8_t, std::vector<uint8_t> > user_defined_chars_;
                          ^~~~~~
src/esphome/components/lcd_base/lcd_display.h:68:26: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
src/esphome/components/lcd_base/lcd_display.h:68:26: error: 'vector' is not a member of 'std'
src/esphome/components/lcd_base/lcd_display.h:68:26: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
src/esphome/components/lcd_base/lcd_display.h:68:40: error: template argument 2 is invalid
   std::map<uint8_t, std::vector<uint8_t> > user_defined_chars_;
                                        ^
src/esphome/components/lcd_base/lcd_display.h:68:40: error: template argument 4 is invalid
src/esphome/components/lcd_base/lcd_display.h:68:42: error: expected unqualified-id before '>' token
   std::map<uint8_t, std::vector<uint8_t> > user_defined_chars_;
                                          ^
src/esphome/components/lcd_base/lcd_display.h: In member function 'void esphome::lcd_base::LCDDisplay::set_user_defined_char(uint8_t, int)':
src/esphome/components/lcd_base/lcd_displa`Preformatted text`y.h:24:85: error: 'class esphome::lcd_base::LCDDisplay' has no member named 'user_defined_chars_'; did you mean 'set_user_defined_char'?
   void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
                                                                                     ^~~~~~~~~~~~~~~~~~~
                                                                                     set_user_defined_char
src/esphome/components/lcd_base/lcd_display.h:24:112: error: 'data' was not declared in this scope
   void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
                                                                                                                ^~~~
src/esphome/components/lcd_base/lcd_display.h:24:112: note: suggested alternative: 'atan'
   void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
                                                                                                                ^~~~
                                                                                                                atan
src/esphome/components/lcd_base/lcd_display.cpp: In member function 'virtual void esphome::lcd_base::LCDDisplay::setup()':
src/esphome/components/lcd_base/lcd_display.cpp:69:40: error: 'class esphome::lcd_base::LCDDisplay' has no member named 'user_defined_chars_'; did you mean 'set_user_defined_char'?
   for (auto &user_defined_char : this->user_defined_chars_) {
                                        ^~~~~~~~~~~~~~~~~~~
                                        set_user_defined_char
*** [.pioenvs/lcd-test/src/esphome/components/lcd_base/lcd_display.o] Error 1
========================== [FAILED] Took 3.27 seconds ==========================

There’s obviously a problem with the lcd_display.h file. These files are generated automatically by ESPHome, so any changes I make are reverted when I compile again.

I’ve tried searching for this problem, however I’m only finding things on Arduino and C++.

Any insight on this? Thanks

Hey, I’m having the same issue…
Relevant config:

display:
  - platform: lcd_gpio
    dimensions: 18x4
    data_pins:
      - GPIO13
      - GPIO12
      - GPIO11
      - GPIO10
    enable_pin: GPIO009
    rs_pin: GPIO008
    lambda: |-
      it.print("Hello World!");

esp32:
  board: esp32-s2-saola-1
  framework:
    type: esp-idf

Errors:

Compiling /data/esp-s2/.pioenvs/esp-s2/src/esphome/components/lcd_gpio/gpio_lcd_display.o
In file included from src/esphome/components/lcd_gpio/gpio_lcd_display.h:4,
                 from src/esphome/components/lcd_gpio/gpio_lcd_display.cpp:1:
src/esphome/components/lcd_base/lcd_display.h:24:54: error: 'vector' in namespace 'std' does not name a template type
   void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
                                                      ^~~~~~
src/esphome/components/lcd_base/lcd_display.h:24:49: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
src/esphome/components/lcd_base/lcd_display.h:11:1:
+#include <vector>
 
src/esphome/components/lcd_base/lcd_display.h:24:49:
   void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
                                                 ^~~
src/esphome/components/lcd_base/lcd_display.h:24:60: error: expected ',' or '...' before '<' token
   void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
                                                            ^
src/esphome/components/lcd_base/lcd_display.h:68:26: error: 'vector' is not a member of 'std'
   std::map<uint8_t, std::vector<uint8_t> > user_defined_chars_;
                          ^~~~~~
src/esphome/components/lcd_base/lcd_display.h:68:26: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
src/esphome/components/lcd_base/lcd_display.h:68:26: error: 'vector' is not a member of 'std'
src/esphome/components/lcd_base/lcd_display.h:68:26: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
src/esphome/components/lcd_base/lcd_display.h:68:40: error: template argument 2 is invalid
   std::map<uint8_t, std::vector<uint8_t> > user_defined_chars_;
                                        ^
src/esphome/components/lcd_base/lcd_display.h:68:40: error: template argument 4 is invalid
src/esphome/components/lcd_base/lcd_display.h:68:42: error: expected unqualified-id before '>' token
   std::map<uint8_t, std::vector<uint8_t> > user_defined_chars_;
                                          ^
src/esphome/components/lcd_base/lcd_display.h: In member function 'void esphome::lcd_base::LCDDisplay::set_user_defined_char(uint8_t, int)':
src/esphome/components/lcd_base/lcd_display.h:24:85: error: 'class esphome::lcd_base::LCDDisplay' has no member named 'user_defined_chars_'; did you mean 'set_user_defined_char'?
   void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
                                                                                     ^~~~~~~~~~~~~~~~~~~
                                                                                     set_user_defined_char
src/esphome/components/lcd_base/lcd_display.h:24:112: error: 'data' was not declared in this scope
   void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
                                                                                                                ^~~~
src/esphome/components/lcd_base/lcd_display.h:24:112: note: suggested alternative: 'atan'
   void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
                                                                                                                ^~~~
                                                                                                                atan
In file included from src/esphome/components/lcd_base/lcd_display.cpp:1:
src/esphome/components/lcd_base/lcd_display.h:24:54: error: 'vector' in namespace 'std' does not name a template type
   void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
                                                      ^~~~~~
src/esphome/components/lcd_base/lcd_display.h:24:49: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
src/esphome/components/lcd_base/lcd_display.h:11:1:
+#include <vector>
 
src/esphome/components/lcd_base/lcd_display.h:24:49:
   void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
                                                 ^~~
src/esphome/components/lcd_base/lcd_display.h:24:60: error: expected ',' or '...' before '<' token
   void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
                                                            ^
src/esphome/components/lcd_base/lcd_display.h:68:26: error: 'vector' is not a member of 'std'
   std::map<uint8_t, std::vector<uint8_t> > user_defined_chars_;
                          ^~~~~~
src/esphome/components/lcd_base/lcd_display.h:68:26: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
src/esphome/components/lcd_base/lcd_display.h:68:26: error: 'vector' is not a member of 'std'
src/esphome/components/lcd_base/lcd_display.h:68:26: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
src/esphome/components/lcd_base/lcd_display.h:68:40: error: template argument 2 is invalid
   std::map<uint8_t, std::vector<uint8_t> > user_defined_chars_;
                                        ^
src/esphome/components/lcd_base/lcd_display.h:68:40: error: template argument 4 is invalid
src/esphome/components/lcd_base/lcd_display.h:68:42: error: expected unqualified-id before '>' token
   std::map<uint8_t, std::vector<uint8_t> > user_defined_chars_;
                                          ^
src/esphome/components/lcd_base/lcd_display.h: In member function 'void esphome::lcd_base::LCDDisplay::set_user_defined_char(uint8_t, int)':
src/esphome/components/lcd_base/lcd_display.h:24:85: error: 'class esphome::lcd_base::LCDDisplay' has no member named 'user_defined_chars_'; did you mean 'set_user_defined_char'?
   void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
                                                                                     ^~~~~~~~~~~~~~~~~~~
                                                                                     set_user_defined_char
src/esphome/components/lcd_base/lcd_display.h:24:112: error: 'data' was not declared in this scope
   void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
                                                                                                                ^~~~
src/esphome/components/lcd_base/lcd_display.h:24:112: note: suggested alternative: 'atan'
   void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
                                                                                                                ^~~~
                                                                                                                atan
*** [/data/esp-s2/.pioenvs/esp-s2/src/esphome/components/lcd_gpio/gpio_lcd_display.o] Error 1
src/esphome/components/lcd_base/lcd_display.cpp: In member function 'virtual void esphome::lcd_base::LCDDisplay::setup()':
src/esphome/components/lcd_base/lcd_display.cpp:69:40: error: 'class esphome::lcd_base::LCDDisplay' has no member named 'user_defined_chars_'; did you mean 'set_user_defined_char'?
   for (auto &user_defined_char : this->user_defined_chars_) {
                                        ^~~~~~~~~~~~~~~~~~~
                                        set_user_defined_char
*** [/data/esp-s2/.pioenvs/esp-s2/src/esphome/components/lcd_base/lcd_display.o] Error 1
========================== [FAILED] Took 4.21 seconds ==========================