1. Home
  2. Boards
  3. Which pins can do PWM?

Which pins can do PWM?

Almost all IO on an ESP32 can do PWM – they are no specific IO reserved for this.

You are generally free to pick any free pins on the header of an Unexpected Maker board and setup PWM for it, but not all ESP32 chips have the same PWM implementation!

ESP32-PICO-D4

The origional ESP32 has 16 PWM channels, grouped into 2 sets of 8, but, each group of 8 channels only has 4 timers each, so IO in that group will share timers in pairs.

ESP32-S2 and ESP32-S3

The S2 and S3 range of ESP32 MCUs only have 8 PWM channels, grouped into 4 sets of timers, so the same rule applies that when using all channels, they will be paired with shared timers.

In both sets of ESP32 implementation (16 channel and 8 channel), Shared timers means it’s possible to end up with 2 IO that you want different frequencies on, but they share the same timer, so they wont work as expected.

If you need a lot of PWM channels, all with specific timing, you might need to look at adding an external PWM controller to your project that has more channels or dedicated timers for each channel.

Random Nerd has a great Arduino tutorial on using PWM on the original ESP32 which also works great on the S2 and S3, so long as you remember to stay within the 8 channel limit.

Updated on August 5, 2023

Related Articles