I’m using classic ESP32 dev board.
The problems are related to ledc (pwm) parts of the code and digitalWrite commands. These are the errors I get on the serial monitor:
[122854][E][esp32-hal-ledc.c:219] ledcDetach(): pin 18 is not attached to LEDC
[122861][E][esp32-hal-gpio.c:166] __digitalWrite(): IO 18 is not set as GPIO.
[122868][E][esp32-hal-ledc.c:63] ledcAttachChannel(): Channel 0 is not available (maximum 16) or already used!
[122878][E][esp32-hal-ledc.c:219] ledcDetach(): pin 4 is not attached to LEDC
[122885][E][esp32-hal-gpio.c:166] __digitalWrite(): IO 4 is not set as GPIO.
[122892][E][esp32-hal-ledc.c:63] ledcAttachChannel(): Channel 1 is not available (maximum 16) or already used!
[122902][E][esp32-hal-ledc.c:219] ledcDetach(): pin 12 is not attached to LEDC
[122909][E][esp32-hal-gpio.c:166] __digitalWrite(): IO 12 is not set as GPIO.
[122916][E][esp32-hal-ledc.c:63] ledcAttachChannel(): Channel 2 is not available (maximum 16) or already used!
[122926][E][esp32-hal-ledc.c:219] ledcDetach(): pin 26 is not attached to LEDC
[122933][E][esp32-hal-gpio.c:166] __digitalWrite(): IO 26 is not set as GPIO.
[122939][E][esp32-hal-ledc.c:63] ledcAttachChannel(): Channel 3 is not available (maximum 16) or already used!
What do you mean by “Full Clean”? It works in ArduinoIDE, so as you said it must be “Arduino 2.x leftovers”. I deleted platform ESP32 6.7.0 I had but that didn’t helped.
I also tried to use platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF5 as a platform in the ini file.
Can you show me how ini file should loook?
This is the minimum code, just in the setup loop:
[ 1020][E][esp32-hal-ledc.c:63] ledcAttachChannel(): Channel 0 is not available (maximum 16) or already used!
[ 1031][E][esp32-hal-ledc.c:63] ledcAttachChannel(): Channel 1 is not available (maximum 16) or already used!
[ 1040][E][esp32-hal-ledc.c:63] ledcAttachChannel(): Channel 2 is not available (maximum 16) or already used!
[ 1050][E][esp32-hal-ledc.c:63] ledcAttachChannel(): Channel 3 is not available (maximum 16) or already used!
First of all: In contrast to the ArduinoIDE, there is no official PlatformIO support for Arduino 3.x yet. Incompatibilities can therefore always occur. There is no guarantee.
There “might be” leftovers if you compiled the sketch before switching to Arduino 3.x.
You can perform a Full Clean either by clicking on the PIO-Icon / Project Tasks / Full-Clean:
or simply delete the .pio/build folder in the current project.
Your platformio.ini file looks okay.
I’m not (yet) familiar with the new Arduino 3.x API’s.
Have you tried ledcAttach instead of ledcAttachChannel ?
After defining the missing constants, this code compiles, uploads and work without errors on the serial monitor:
I need ledcAttachChannel() function because for every of my 4 motoros, I need a different PWM channel. Btw, I tried ledcAttach() just to check that and there are no errors on the Serial with it.
Yes, I know about that but I’ve seen that people had success with it? I find it odd that no one experienced a problem with this ledc function. I did a full clean but that didn’t help.
Any other ideas?
The API has changed with version 3.x! (See link “Migration from 2.x to 3.0” from above).
If you want to use the old API you have to stay with Arduino 2.x!
Have you managed to compile in platformio using the Arduino core 3. I am having shortcomings with ver 2 in that I need to invert the pwm and this is only supported in ver 3.
I understand pwm channels are auto assigned and no longer params for the hal-ledc API in ver 3
This package is breaking my platformio.
I have a project with ESP32 core 2. When I change platform in my ini file to platform = https://github.com/pioarduino/platform-espressif32.git#51.03.04 I’m getting the message : ** The terminal process failed to launch: Path to shell executable “c:\platformio.exe” does not exist.**
I delete my entire C:\Users\<user>\.platformio restart VS Code, everything installs and when I want to build my project I’m getting the same error message.
Plus when build works , can somebody explain why identic code builded for 3.x is +400kB in size vs 2.x ??? Some Mars rover cntrol and bitcoin miner and many more thinks can be in this size.