Skip to content

Touches capacitives

reichart edited this page Jan 6, 2026 · 8 revisions

8 dépôts github : exemples-de-montages festisol CROUS-micro-python piano visio anumby jouets developpement-voiture raspberry-pico Blog ateliers numériques Repair Café d'Orsay

Il me manque une interface pour créer des boutons sans mécanique ; cela existe sur des esp ; j'ai testé le fonctionnement des touches capacitives

Touches capacitives esp32

image

C'est magique ; on peut les utiliser pour remplacer les boutons-poussoirs : la fonction touchread donne directement une valeur très faible (ici 270) lorsque je touche le fil

image

les broches capacitives sont en vert

image
  • T0 GPIO 4
  • T1 GPIO 0
  • T2 GPIO 2
  • T3 GPIO 15
  • T4 GPIO 13
  • T5 GPIO 12
  • T6 GPIO 14
  • T7 GPIO 27
  • T8 GPIO 33
  • T9 GPIO 32

https://github.com/espressif/arduino-esp32/blob/master/libraries/ESP32/examples/Touch/TouchRead/TouchRead.ino

/* This is an example how to use Touch Intrrerupts The bigger the threshold, the more sensible is the touch */

int threshold = 0; // if 0 is used, benchmark value is used. Its by default 1,5% change, can be changed by touchSetDefaultThreshold(float percentage)

bool touch1detected = false; bool touch2detected = false;

void gotTouch1() { touch1detected = true; }

void gotTouch2() { touch2detected = true; }

void setup() { Serial.begin(115200); delay(1000); // give me time to bring up serial monitor

//Optional: Set the threshold to 5% of the benchmark value. Only effective if threshold = 0. touchSetDefaultThreshold(5);

Serial.println("ESP32 Touch Interrupt Test"); touchAttachInterrupt(T2, gotTouch1, threshold); touchAttachInterrupt(T3, gotTouch2, threshold); }

void loop() { if (touch1detected) { touch1detected = false; Serial.println("Touch 1 detected"); } if (touch2detected) { touch2detected = false; Serial.println("Touch 2 detected"); } }

Touches capacitives S2

image
  • T0 GPIO4
  • T1 GPIO0
  • T2 GPIO2
  • T3 MTDO
  • T4 MTCK
  • T5 MTDI
  • T6 MTMS
  • T7 GPIO27
  • T8 32K_XN
  • T9 32K_XP

banc de test

Comment fonctionne les touches "capacitives" ? banc de test avec une boucle pour lire la fonction ; les sorties varient de 150 à zéro

image

Code TouchRead

Clone this wiki locally