I am using platformio 3,4,4
I did the migration from version 2 to version 3 and made appropriate changes. The modified program compiled and ran fine yesterday. Now there is a problem with ledcAttach .
When doing a build I now get :
=============================================
Compiling .pio\build\esp32doit-devkit-v1\libb6f\WiFi\WiFiAP.cpp.o
src/main.cpp: In function ‘void setup()’:
src/main.cpp:262:3: error: ‘ledcAttach’ was not declared in this scope
ledcAttach(ledPin1, freq, resolution);
^~~~~~~~~~
src/main.cpp:262:3: note: suggested alternative: ‘ledcAttachPin’
ledcAttach(ledPin1, freq, resolution);
^~~~~~~~~~
ledcAttachPin
*** [.pio\build\esp32doit-devkit-v1\src\main.cpp.o] Error 1
===============================
The suggested alternative is exactly what I have used.
Is something else being changed?
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
monitor_speed = 115200
lib_deps =
ESP Async WebServer
arduino-libraries/Arduino_JSON @ 0.1.0
adafruit/Adafruit BME280 Library @ ^2.1.0
adafruit/Adafruit Unified Sensor @ ^1.1.4
QMC5883LCompass.h
mprograms/QMC5883LCompass@^1.2.3
board_build.filesystem = littlefs
; platform_packages added to enable ledc
;platform_packages=
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.1
; framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.1/esp32-arduino-libs-3.0.1.zip
++++++++++++++++++++++++++++
Platform packages are residual from previous method of getting ledc to work with version 2. They are commented out.
Hi.
Platformio doesn’t support arduino core version 3.
You need to use the old ledc functions supported by core 2.
1. Attach the pin using ledcAttachPin()
ledcAttachPin(ledPin1, channel);
ledPin1 → GPIO pin
channel → LEDC channel (0-15)
2. Set up the LEDC PWM channel using ledcSetup()
ledcSetup(channel, freq, resolution);
channel → LEDC channel (same as in ledcAttachPin)
freq → Frequency in Hz
resolution → Bit resolution (1-16 bits)
3. Write duty cycle using ledcWrite()
ledcWrite(channel, duty);
ledcWrite(channel, duty);
duty → PWM duty cycle
I hope this helps.
ALTERNATIVELY, you can use the pioarduino fork: https://github.com/pioarduino/platform-espressif32
You can see the usage instructions here: https://github.com/pioarduino/platform-espressif32?tab=readme-ov-file#usage
Let me know if you can solve the issue.
Regards,
Sara