Home / ESP32 / GPIO2

ESP32 GPIO2

Everything you need to use this pin correctly: status, alternate functions, boot-time cautions and working code.

StatusUsable
Alternate functionsADC2_CH2TOUCH2
ChipESP32 pinout
Watch out:
  • Strapping pin: its level is latched at power-up to configure boot behaviour. Do not attach anything that changes its reset state.
  • This is an ADC2 channel, which becomes unavailable while Wi-Fi is running — use an ADC1 channel for reliable sampling.

Practical notes

Strapping pin plus ADC2_CH2 / TOUCH2, and the usual home of the on-board blue LED. It must be low or floating at power-up — strapping it high breaks boot.

Sample code

// Arduino
const int PIN = 2;

void setup() {
  Serial.begin(115200);
  analogReadResolution(12);
  // set attenuation before measuring higher voltages
  analogSetAttenuation(ADC_11db);
}

void loop() {
  int raw = analogRead(PIN);
  Serial.println(raw);
  delay(1000);
}
Data verified:2026-10-20 · Cross-checked against Espressif documentation. Always confirm against the official datasheet before finalizing a design. Official docs →

Related