I bought this SAMD21 development board which shows up as an "Arduino/Genuino Zero (Native USB Port)" when plugged in. And I've successfully got a blink sketch running on it all good so far:

SAMD21 development board

The reason I picked up this board was to experiment with the built-in capacitive touch sensor on the SAMD21. In the datasheet for this chip it claims to support a 'Peripheral Touch Controller with 256-Channel capacitive touch and proximity sensing'.

Does anyone know what this exactly means and how I would access this functionality to detect touches in my Arduino code? Obviously there are not 256 IO pins so how would this work? Is there some kind of internal multiplexer?

The 256 channel capacitive touch controller is also mentioned in a Sparkfun video about their SAMD21 board, so it must be possible to access this functionality.

Can someone direct me towards an Arduino library or method and more information on the wiring and pin connections for this. Thanks.

  • 15 dollars at AliExpress. It is the same processor as in the Arduino Zero and Arduino M0. As far as I know there is a small difference for the pins between the Zero and the M0. You can find the complete datasheet here: microchip.com/wwwproducts/en/ATsamd21g18 The pins can be used in a matrix. For using it, they point to the Atmel QTouch library. Someone at Arduino has done a good job by mentioning the PTC pins in the table: github.com/arduino/ArduinoCore-samd/blob/master/variants/… So far I can only find this: github.com/jgilbert20/Libre_PTC
    – Jot
    Aug 14, 2017 at 18:26
  • Thanks for pointing me towards this Libre_PTC library, it looks very promising. I really hope Jeremy continues work on this and adds support for SAMD21 soon. Aug 15, 2017 at 14:25

1 Answer 1


You have three options for the silicon-based PTC (peripheral touch controlller).

  1. LibrePTC - My own library that targets the SAMD11 but should work with some modifications for other SAMD architectures. The README file has lot of information on how the PTC works and how to specify designs for it.
  2. Adafruit FreeTouch - Works only with the SAMD21. Given the high quality of the register documentation, I suspect they may have had inside help from Atmel but I haven't been able to reach Ladyada, their primary contributor, to learn more.
  3. QTouch, which is Atmel's library available in closed source only but is extremely feature-rich. Arduino team decided not to allow closed source stuff in their IDE so its been banned from official distributions. However, it is possible to hack it into the Arduino IDE and I've used it successfully that way. However this requires esoteric modification to boards.txt that are beyond the scope of this answer.

The PTC hardware peripheral on the SAMD chips works on self-capacitance using "Y" lines specified in the data sheet. See the README on LibrePTC for details. Some chip variants have more pins broken out. For instance, the SAMD21G has fewer available Y pins than the SAMD21J, although the J series is not as readily available in breakout boards as of the summer of 2017 and it has limited Arduino IDE support. I personally prefer the SAMD11 because it is cheaper ($1.00) and has way more available Y lines in the QFN package.

As of August 2017, I intend to attempt a merge between the Adafruit and LibrePTC libraries but no guarantees when this will happen. I don't have access to insider documentation so my library was 100% reverse engineered through trial and error.

  • Great. Thanks Jeremy. I’ll start with trying out that Adafruit FreeTouch library, I did’t know Ladyada had written something like this. Then I’ll search for an affordable SAMD11 development board to order and then I'll play around with your library beginning with the SAMD11 and then the SAMD21. And I also really look forward to seeing your updates after merging your’s and the Adafruit libraries. Aug 15, 2017 at 15:55
  • Will do. The AF library does not work out of the box. For anyone following this, you will need to install the Adafruit_ASFCore library too or use my fork here: github.com/jgilbert20/Adafruit_FreeTouch Aug 15, 2017 at 16:35
  • I had a play with your Adafruit_FreeTouch branch on the SAMD21… It’s doing something when I touch an input so that’s a good thing, but it doesn't seem right. Maybe you could advise me in setting it up, I’m getting very noisy readings with the example code. Aug 16, 2017 at 10:48
  • Seems to be easy to include the qtouch library now a days... github.com/arduino-libraries/Arduino_MCHPTouch Jan 22, 2023 at 23:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.