ESP-home & pi pico W ->problem setting up SPI for thermocouple temp.measurement

`Hello there,

I’m fairly new to home assistant (4weeks in). But i’ve been playing mostly with the esp-home and my raspberry pi pico W. I’ve managed to read out two dallas sensors via 1 wire, and display them on my dashboard.

But now i cant seem to get the spi to work with a thermocouple & max6675 via esp-home. Here is my connection schematic, my yaml code and my log.

Can someone point me in the right direction? I’m not a programmer, most of the stuff i use on the esp is copy-paste-modified from fora and youtube :slight_smile:
`

yaml:

esphome:
  name: pico-w-vergasser
  friendly_name: Pico-w-vergasser


rp2040:
  board: rpipicow

# Enable logging
logger:

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

ota:
  - platform: esphome
    password: "mypass"

wifi:
  ssid: !secret Main_AP
  password: !secret Main_AP_password
  
  # Enable fallback hotspot in case wifi connection fails
  ap:
    ssid: !secret Second_AP
    password: !secret Second_AP_password

#one_wire:
#  - platform: gpio
#    pin: GPIO04
#    id: bus1
#  - platform: gpio
#    pin: GPIO22
#    id: bus2
    
spi:
  clk_pin: GPIO13
  miso_pin: GPIO15

sensor:
  - platform: max6675
    name: "Living Room Temperature"
    cs_pin: GPIO14
    update_interval: 60s
    unit_of_measurement: °C
    accuracy_decimals: 1 

Log file:

INFO ESPHome 2025.2.0-dev
INFO Reading configuration /config/esphome/pico-w-vergasser.yaml...
ERROR Unexpected exception while reading configuration:
Traceback (most recent call last):
  File "/usr/local/bin/esphome", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/esphome/esphome/__main__.py", line 1049, in main
    return run_esphome(sys.argv)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/__main__.py", line 1027, in run_esphome
    config = read_config(dict(args.substitution) if args.substitution else {})
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/config.py", line 1095, in read_config
    res = load_config(command_line_substitutions)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/config.py", line 949, in load_config
    return _load_config(command_line_substitutions)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/config.py", line 939, in _load_config
    return validate_config(config, command_line_substitutions)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/config.py", line 863, in validate_config
    result.run_validation_steps()
  File "/esphome/esphome/config.py", line 142, in run_validation_steps
    task.step.run(self)
  File "/esphome/esphome/config.py", line 562, in run
    validated = schema(self.conf)
                ^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/voluptuous_schema.py", line 35, in __call__
    res = super().__call__(data)
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/voluptuous/schema_builder.py", line 281, in __call__
    return self._compiled([], data)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/voluptuous/validators.py", line 251, in _run
    return self._exec(self._compiled, value, path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/voluptuous/validators.py", line 379, in _exec
    v = func(path, v)
        ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/voluptuous/schema_builder.py", line 855, in validate_callable
    return schema(data)
           ^^^^^^^^^^^^
  File "/esphome/esphome/components/spi/__init__.py", line 202, in validate_spi_config
    if not validate_hw_pins(spi):
           ^^^^^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/components/spi/__init__.py", line 173, in validate_hw_pins
    list(filter(lambda s: clk_pin_no in s[CONF_CLK_PIN], RP_SPI_PINSETS))[0]
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

Please post your code and logs using code tags:
image

image

Should be fine now.

At least SPI pins are incorrect. Try wiring like this:
clk_pin: GPIO14
miso_pin: GPIO12

cs_pin: GPIO13

I’ll try that, thanks. I thought you could program every gpio pin to do whatever.

That’s the case with Esp32, but I doubt you can freely mux with PI.
But it has many options for SPI0 and SPI1

That did it.

Works now, thanks a bunch! :smiley:

1 Like

You’re welcome!