esphome / issues

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

LEDC not working with ESP32-C3 and Arduino framework (but with ESP-IDF) #3128

Closed MFlasskamp closed 1 year ago

MFlasskamp commented 2 years ago

The problem

The LEDC output component produces no output with a monochromatic light. The board I'm using has an ESP32-C3 (NodeMCU ESP-C3-13) and is compiled with Arduino framework (cf. example yaml).

No compile errors or errors in the log when light is controlled by Home Assistant.

Which version of ESPHome has the issue?

2022.2.6

What type of installation are you using?

Docker

Which version of Home Assistant has the issue?

2022.3.3

What platform are you using?

ESP32

Board

NodeMCU ESP-C3-13

Component causing the issue

ledc

Example YAML snippet

esphome:
  name: esp32c3-01

esp32:
  board: esp32-c3-devkitm-1
  variant: esp32c3
  framework:

########################################################

### Arduino
    type: arduino
    version: dev
    platform_version: https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream

### IDF
    # type: esp-idf
    # sdkconfig_options:
    #   CONFIG_BT_BLE_42_FEATURES_SUPPORTED: y

########################################################

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_pass
  fast_connect: true
  manual_ip:
    static_ip: 192.168.1.70
    gateway: 192.168.1.1
    subnet: 255.255.255.0

ota:
  password: !secret ota_pass

api:
  password: !secret api_pass

logger:
  level: DEBUG  # WARN DEBUG

output:
  - id: led_18
    platform: ledc
    pin: GPIO18

light:
  - platform: monochromatic
    name: esp32c3-01 led 18
    output: led_18

Anything in the logs that might be useful for us?

No response

Additional information

Framework/toolchain versions: Arduino:

ESP-IDF:

defl commented 2 years ago

Also ran into this, it seems that there is a something working a little but as I've seen a few small pulses from LEDC but it doesn't work as expected indeed.

Matchlighter commented 2 years ago

Observing this as well

MFlasskamp commented 2 years ago

The PR above fixes wrong calculation of the LEDC/PWM resolution. Moreover I had to use the most recent releases of framework and platform. Here is a snippet to give it a try:

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: arduino
    version: 2.0.4
    platform_version: 5.1.1

external_components:
  - source: github://pr#3820
    components: [ ledc ]
Matchlighter commented 2 years ago

@MFlasskamp Hmm. Not working for me. It compiles and uploads, but I end up with a bootloop:

Build:Feb  7 2021
rst:0x7 (TG0WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x40049a42
SPIWP:0xee
mode:QIO, clock div:2
load:0x3fcd6100,len:0x438
ets_loader.c 78 
bls220 commented 2 years ago

This worked for me.

  board: adafruit_feather_esp32s3_nopsram
  variant: esp32s3
  framework:
    type: arduino
    version: dev
    platform_version: ^5.1.1
ssieb commented 2 years ago

variant: esp32s3

That's an S3, not a C3.

MFlasskamp commented 2 years ago

Great! And my PR fixes the esp32s2, too. The current esphome code has the LED PWM timer resolution hard coded to 20 bit. This is only valid for the old esp32. The esp32s2 needs 18 bit, esp32c3 18 bit and esp32s3 14 bit. That's why I changed it to LEDC_TIMER_BIT_MAX defined in esp-idf

kozerscy commented 1 year ago

Why it's not released yet? What's the point in closing issues as long as they are not released?

MFlasskamp commented 1 year ago

The pull request https://github.com/esphome/esphome/pull/3820 is merged into the 2023.2.0 betas: https://github.com/esphome/esphome/releases

kozerskil commented 1 year ago

Great, thank you!