touchRead command isn't working on some pins

milklizard88
Posts: 3
Joined: Mon Apr 24, 2023 9:00 am

touchRead command isn't working on some pins

Postby milklizard88 » Mon Apr 24, 2023 9:15 am

I have created a bit of simple code to test the functionality of the 10 touch pins on the ESP32.

Code: Select all

void setup()
{
  Serial.begin(115200);
  delay(1000); // give me time to bring up serial monitor
  Serial.println("ESP32 Touch Test");
}

void loop()
{
  Serial.println("");
  Serial.println("");
  Serial.print("T0");
  Serial.print("\t");
  Serial.print("T1");
  Serial.print("\t");
  Serial.print("T2");
  Serial.print("\t");
  Serial.print("T3");
  Serial.print("\t");
  Serial.print("T4");
  Serial.print("\t");
  Serial.print("T5");
  Serial.print("\t");
  Serial.print("T6");
  Serial.print("\t");
  Serial.print("T7");
  Serial.print("\t");
  Serial.print("T8");
  Serial.print("\t");
  Serial.println("T9");
  for (int i = 0; i < 10; i++){
  Serial.print(touchRead(T0));
  Serial.print("\t");
  Serial.print(touchRead(T1));
  Serial.print("\t");
  Serial.print(touchRead(T2));
  Serial.print("\t");
  Serial.print(touchRead(T3));
  Serial.print("\t");
  Serial.print(touchRead(T4));
  Serial.print("\t");
  Serial.print(touchRead(T5));
  Serial.print("\t");
  Serial.print(touchRead(T6));
  Serial.print("\t");
  Serial.print(touchRead(T7));
  Serial.print("\t");
  Serial.print(touchRead(T8));
  Serial.print("\t");
  Serial.println(touchRead(T9));
  delay(100);
  }
}
I uploaded this code to two of my ESP32s and have seen I'm getting a constant reading of 1 on T1 and 0 on T2, regardless of whether the pin is being touched. Screenshot below. This happened ON BOTH separate chips, however the general levels on the other pins were different

I'm using the arduino IDE and the touch readings seem to work on the other pins.

Are the pins known for being unstable? Could it be a manufacturer error?

Image

ESP_Sprite
Posts: 9727
Joined: Thu Nov 26, 2015 4:08 am

Re: touchRead command isn't working on some pins

Postby ESP_Sprite » Tue Apr 25, 2023 3:32 am

Touch0 and touch1 are GPIO0 and GPIO4. GPIO0 is a bootstrap pin and probably has the boot button plus a pullup resistor (plus the logic of an autoreset circuit) attached that messes with the touch detection. I'm not sure what would cause GPIO4 to not work, but there may be a similar thing going on, depending on what devboard you use.

Who is online

Users browsing this forum: jesper and 63 guests