esphome / issues

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

ESP32S2 - DAC problem #3787

Open SmartieBjelovar opened 1 year ago

SmartieBjelovar commented 1 year ago

The problem

DAC function is not available for ESP32S2 modules. Internal DAC pins for ESP32S2 are GPIO17 and GPIO18 but esphome allows pins GPIO25 and GPIO26.

Am I doing something wrong, is there any other way to use an internal DAC on ESP32S2?

Which version of ESPHome has the issue?

2022.10.2

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2022.11.2

What platform are you using?

ESP32-IDF

Board

esp32-s2-saola-1

Component causing the issue

esp32_dac

Example YAML snippet

esp32:
  board: esp32-s2-saola-1
  framework:
    type: esp-idf
    version: recommended
  variant: esp32s2

output:
  - platform: esp32_dac
    pin: GPIO17
    id: fan_speed

Anything in the logs that might be useful for us?

output.esp32_dac: [source /config/esphome/fan-controller.yaml:12]
  platform: esp32_dac

  Unknown value '17', valid options are '25', '26'.
  pin: GPIO17
  id: fan_speed

Additional information

No response

Bart-1992 commented 1 year ago

Did you managed to solve this? I currently have the same problem.... I need a DAC output on my ESP32-S2, but unfortunately not supported (yet?)

SmartieBjelovar commented 1 year ago

We gave up and made a new PCB with ESP32 Wroom, works without a problem now :)

uto, 14. velj 2023. u 19:14 Bart-1992 @.***> napisao je:

Did you managed to solve this? I currently have the same problem.... I need a DAC output on my ESP32-S2, but unfortunately not supported (yet?)

— Reply to this email directly, view it on GitHub https://github.com/esphome/issues/issues/3787#issuecomment-1430173391, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZTOB5TJ63QKOOHH2UNGRHLWXPDPLANCNFSM6AAAAAAR7WAFSU . You are receiving this because you authored the thread.Message ID: @.***>

hppi-johnsson commented 1 year ago

I got it working by modifying the references to GPIO25 & 26 in these two files:

...\Lib\site-packages\esphome\components\esp32_dac\output.py

def valid_dac_pin(value):
    num = value[CONF_NUMBER]
    cv.one_of(17, 18)(num)
    return value

...\Lib\site-packages\esphome\components\esp32_dac\esp32dac.cpp `auto channel = pin->get_pin() == 17 ? DAC_CHANNEL_1 : DAC_CHANNEL_2;`

RealDoublejan commented 11 months ago

@jesserockz can the above named fix be added to the Output component?

RaceNJason commented 4 months ago

Your standard HAOS install on a Pi doesn't allow access to the esp32_dac.cpp files. Would be nice if the ESPHome developers just put this in their code and updated the integration.

Anyway, shouldn't auto channel = pin_->get_pin() == 17 ? DAC_CHANNEL_1 : DAC_CHANNEL_2;

be instead (to make sure people who still use the GPIO25 and GPIO26 pins to not break)? auto channel = ((pin_->get_pin() == 17 || pin_->get_pin() == 25) ? DAC_CHANNEL_1 : DAC_CHANNEL_2);