ESP32-H2 and PWM

Hello,

I’m using the H2-devkit platform from Jason2866 git and I encountered an issue while compiling the ledc functions to drive PWM.

Here is my platformio.ini:
[env:esp32-h2-devkitm-1]
platform = GitHub - Jason2866/platform-espressif32: Tasmota Espressif 32: development platform for PlatformIO
board = esp32-h2-devkitm-1
framework = arduino
upload_port = /dev/cu.usbmodem323101
monitor_speed = 460800
build_flags =
-D ARDUINO_USB_MODE=1
-D ARDUINO_USB_CDC_ON_BOOT=1

Here is a simple code to try the function:
#include <Arduino.h>

void setup()
{
ledcAttachPin(18, 0); // broche 18, canal 0.
ledcSetup(0, 5000, 12); // canal = 0, frequence = 5000 Hz, resolution = 12 bits
ledcWrite(0, 2048); // canal = 0, rapport cyclique = 2048
}

void loop()
{
}

I got an error on the ledcAttachPin, ledcSetup functions :
src/main.cpp: In function ‘void setup()’:
src/main.cpp:5:3: error: ‘ledcAttachPin’ was not declared in this scope; did you mean ‘ledcAttach’?
5 | ledcAttachPin(18, 0); // broche 18, canal 0.
| ^~~~~~~~~~~~~
| ledcAttach
src/main.cpp:6:3: error: ‘ledcSetup’ was not declared in this scope
6 | ledcSetup(0, 5000, 12); // canal = 0, frequence = 5000 Hz, resolution = 12 bits
| ^~~~~~~~~
*** [.pio\build\esp32-h2-devkitm-1\src\main.cpp.o] Error 1

And if I remove #include <Arduino.h>, I also have the error on ledcWrite:
src/main.cpp: In function ‘void setup()’:
src/main.cpp:5:3: error: ‘ledcAttachPin’ was not declared in this scope
5 | ledcAttachPin(18, 0); // broche 18, canal 0.
| ^~~~~~~~~~~~~
src/main.cpp:6:3: error: ‘ledcSetup’ was not declared in this scope
6 | ledcSetup(0, 5000, 12); // canal = 0, frequence = 5000 Hz, resolution = 12 bits
| ^~~~~~~~~
src/main.cpp:7:3: error: ‘ledcWrite’ was not declared in this scope
7 | ledcWrite(0, 2048); // canal = 0, rapport cyclique = 2048
| ^~~~~~~~~

Is it something to be done to correct this library access (?) issue?

Regards

This is based on Arduino 3.0.0-alpha and IDF 5.1.2 which brings some major changes! Also ledc functions are affected by this release:

Breaking changes of 3.0.0 Release

This version introduce breaking changes in this particular APIs:

  • ADC
  • BLE
  • Hall Sensor (not supported)
  • I2S
  • LEDC
  • RMT
  • SigmaDelta
  • Timer
  • UART (HardwareSerial)

For more details please refer to Migration Guide from version 2.x to 3.0.

For details see

I just noticed that your’re using the ESP32-H2 which makes you dependend to this release. So all you have to do is to change your code accordingly to the new API’s of this release.

Thank you very much!