Add ESP32 compatibility to an existing Arduino Library
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

This bounty was posted in a Github Issue that I opened on the repo of the library. It's a Capacitive Touch library. Some of the possible implementation details are posted in the issue.

In short, this bounty is to add support of this library to the ESP32. Not just so that it compiles, but that I can actually use it for it's intended purposes.

I'm using an ESP32-WROVER specifically. If possible I would love to use this functionality without a multiplexer, but I'm not sure if this is possible.

The ESP should have the needed PWM and ADC functionality I think? But the library seems to specifically use PWM settings from the atmega328p. So this is why I've posted the bounty; I don't know how to make this work on the ESP32.


  • Make it run on the Arduino core for ESP32
  • If possible without the multiplexer
  • If possible by simply forking the library and adding compatibility
awarded to CyteBode

Crowdsource coding tasks.

1 Solution

Winning solution

Since you don't need the multiplexer, you would be better off using a different library. This one should support the ESP32:

Otherwise, if you really want to use MultiTouchKit, setting up PWM on the ESP32 should be as easy as this:

void MultiTouchKit::setupPWM() {
    #define PWM_PIN 3          // Whatever pin it may be
    analogWriteFreq(4000);     // 4 KHz frequency
    analogWrite(PWM_PIN, 255); // 25% Duty cycle

Since the library is just a header and a source file, you could add them to your sketch with the new implementation of setupPWM(), rename them to MultiTouchKit_esp32.hpp and MultiTouchKit_esp32.cpp (to avoid importing the original library), and change the include's to #include "MultiTouchKit_esp32.hpp" in your sketch and in MultiTouchKit_esp32.cpp.

I don't have an ESP32-WROVER to test, so I may be off track, but the rest of the code is generic enough that it should work with an ESP32. It at least compiles in the Arduino IDE with an ESP32 board as a target.

That sounds great! I will test with this on my hardware and report back. I'll probably accept this answer tomorrow. Would you possibly be available for incidental follow-up queries if stuff comes up after accepting the solution?
jwktje 12 months ago
Sure thing! It's the least I could do. You can PM me after clicking on my name.
CyteBode 12 months ago
This solution did push me in the right direction to get the code of the library to compile and run. However in practice it isn't really giving me the result I need yet. So I'm doubting my implementation. I will create a public github repo for this and accept the answer. Hopefully CyteBode wants to help me debug a little further. If it takes crazy amounts of time, additional compensation is ok with me.
jwktje 12 months ago