esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

SPI bus configuration fails on ESP32S2 devices #3450

Open rosterloh opened 2 years ago

rosterloh commented 2 years ago

The problem

While trying to configure a SPI bus on an ESP32S2 using the Arduino framework the build fails due to VSPI not being defined for this platform. For ESP32S2 and ESP32S3 FSPI needs to be used

Which version of ESPHome has the issue?

2022.6.2

What type of installation are you using?

Docker

Which version of Home Assistant has the issue?

N/A

What platform are you using?

ESP32

Board

um_feathers2

Component causing the issue

SPI

Example YAML snippet

esphome:
  name: spi-example

esp32:
  board: um_feathers2
  variant: esp32s2
  framework:
    type: arduino
    version: 2.0.3
    platform_version: 5.0.0

spi:
  clk_pin: GPIO36
  mosi_pin: GPIO35
  miso_pin: GPIO37

Anything in the logs that might be useful for us?

Compiling .pioenvs/office-monitor/src/esphome/components/spi/spi.cpp.o
Compiling .pioenvs/office-monitor/src/main.cpp.o
src/esphome/components/spi/spi.cpp: In member function 'virtual void esphome::spi::SPIComponent::setup()':
src/esphome/components/spi/spi.cpp:79:36: error: 'VSPI' was not declared in this scope
       this->hw_spi_ = new SPIClass(VSPI);  // NOLINT(cppcoreguidelines-owning-memory)
                                    ^~~~
src/esphome/components/spi/spi.cpp:79:36: note: suggested alternative: 'SPI'
       this->hw_spi_ = new SPIClass(VSPI);  // NOLINT(cppcoreguidelines-owning-memory)
                                    ^~~~
                                    SPI

Additional information

Useful Links

nielsnl68 commented 2 years ago

Hi, this is already an known issue. Somehow the VSPI define is not defined under ESP32-c3 and it seems now that it does not for the esp32-s2 as well.

on my github page at https://github.com/nielsnl68/switchplate i have added a temporary fix for it.

you can load it by adding:

external_components:
  - source: github://nielsnl68/SwitchPlate
    components: [ spi ]

the only thing it does is replacing VSPI with 3. And that seems to work.

landonr commented 2 years ago

I can't get the above to work on a T-Display S3 with an esp32s3. It say's spi component not found. Here's my current config

esphome:
  name: s3

spi:
  clk_pin: GPIO12
  mosi_pin: GPIO11

esp32:
  board: esp32-s3-devkitc-1
  variant: esp32s3
  framework:
    type: arduino
    version: 2.0.4
    platform_version: 5.1.1

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "123123"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "S3 Fallback Hotspot"
    password: "123"

color:
  - id: gray
    red: 50%
    green: 50%
    blue: 50%

font:
  - file: "fonts/iosevka.ttf"
    id: iosvetta
    size: 24

display:
  - platform: st7789v
    model: Custom
    offset_height: 0
    offset_width: 0
    height: 170
    width: 320
    backlight_pin: GPIO38
    cs_pin: GPIO6
    dc_pin: GPIO7
    reset_pin: GPIO5
    lambda: |-
      it.print(50, 50, id(iosvetta), "Hello World!");
      it.rectangle(64, 64, 192, 112, id(gray));
github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Jake-Jensen commented 1 year ago

Issue is still present.

pierdr commented 6 months ago

Any updates on this issue?

Nutz-EO commented 3 weeks ago

The ESP32-C3, like the ESP32-S3, does not have a dedicated VSPI peripheral. Instead, it has two general-purpose SPI peripherals, SPI2 and SPI3.

Suggestion: Update VSPI code to use SPI2_HOST or SPI3_HOST.