Touchpads in Micropython mit ESP32 - erste Versuche

Aus Micropython Referenz
Zur Navigation springen Zur Suche springen

Die Informationslage ist sehr dürftig.

Arduino IDE

Für Arduino IDE habe ich bei [1] folgendes gefunden:

#define numSW 12 //define number of touch SWs
int TOUCH_PIN[numSW] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13 }; //define GPIO number for.each touchSW
.....
void serialPrintThresh() { //読み取り値と閾値を列記
for (int touchNum = 0; touchNum < numSW; touchNum++) {
USBSerial.print(touchNum + 1); //+1してピン番号に換算
USBSerial.print(": ");
USBSerial.print(touchRead(TOUCH_PIN[touchNum]));
USBSerial.print(" / ");
USBSerial.print(threshold[touchNum]);
USBSerial.println(" ");
}
}

......serial print result:
......many GPIO pins show big number, not only #3
......only #1 pin can detect touch well, BUT others can not !

1: 13859 / 2764
2: 13998 / 2799
3: 2443023 / 488604
4: 2783227 / 556645
5: 4178149 / 835629
6: 1179519 / 235903
7: 4060029 / 812005
8: 1920687 / 384137
9: 4003023 / 800604
10: 893757 / 178751
11: 3026140 / 605228
12: 3399653 / 679930

_____________modified program, exchange #3 to #12

int TOUCH_PIN[numSW] = { 1, 2, 12, 4, 5, 6, 7, 8, 9, 10, 11, 13 }; //define GPIO number for.each touchSW
..........all pins shows similar number
..........each pin detect touch well !

1: 13840 / 2758
2: 13982 / 2796
3: 13921 / 2770 // #12GPIO pin
4: 13443 / 2680
5: 12204 / 2434
6: 12192 / 2427
7: 12522 / 2495
8: 11920 / 2377
9: 12530 / 2501
10: 12662 / 2533
11: 20303 / 4060
12: 13899 / 2779

M5Stack Micropython

Für Micropython in der M5Community:

from machine import Pin, TouchPad
t8 = 0
touch8 = TouchPad(Pin(33))
t8 = touch8.read()

Micropython.org

Unter docs.micropython.org finden sich zum ESP32 die folgenden Informationen: