M5Stack Core ESP32 GPIO Pinout Reference

Physical GPIO Ranges

Available pins: 0-19, 21-23, 25-27, 32-39

These correspond to actual ESP32 GPIO pin numbers. Many boards use their own logical pin numbering (D0, D1, etc.) — this doc maps logical to physical.

Reserved Pins (Do Not Use for Custom I/O)

PinReserved ForNotes
0Boot / ButtonPulldown at boot — unsafe for output
1TX0Debug serial
2Boot / ButtonPulldown at boot
3RX0Debug serial
6-11Flash SPIInternal flash memory — do not use
12Boot / GPIOPulldown at boot — unsafe for output
18, 19, 23SPI (LCD + TF Card)Shared with display and SD card
25SpeakerConnected to internal speaker amplifier
21, 22I2C (Grove port)SDA/SCL — available if Grove not used

Safe GPIO for Custom Use

PinSafe UseNotes
4General I/OSafe if speaker not used
5General I/OSafe
13General I/OSafe
14General I/OSafe
15General I/OSafe (also MTDO)
16General I/OSafe
17General I/OSafe
26Analog input12-bit ADC (also digital I/O)
27Analog input12-bit ADC (also digital I/O)
32-39Analog input12-bit ADC — best for sensor readings

I2C Bus (Grove Port)

  • SDA: GPIO 21
  • SCL: GPIO 22

If Grove port is not in use, pins 21/22 are available as general GPIO.

SPI Bus

Default SPI (for LCD + SD card): GPIO 18 (CLK), 19 (MISO), 23 (MOSI). These are shared — using them for other devices may conflict with display.

Second SPI available on other pins if needed.

Communication Protocols

  • UART: TX on GPIO 1, RX on GPIO 3. Can remap to other pins.
  • I2C: Default on 21/22. Can remap with machine.SoftI2C
  • SPI: Default on 18/19/23. Can remap with machine.SPI

Analog (ADC)

ESP32 has two ADC units:

  • ADC1: pins 32-39 (best for sensors)
  • ADC2: pins 0, 2, 4, 12-15 (conflicts with WiFi)

12-bit resolution (0-4095). Max input: 3.3V.

For Chris’s Projects

Based on typical M5Stack setups:

  • Grove connectors use I2C (21/22) — leave available if using Grove sensors
  • Display conflict means 18/19/23 are unavailable in most setups
  • Speaker on 25 — disable speaker if you need that pin
  • Analog sensors (temperature, pressure, gas) work well on 32-39

Common Pinouts for Chris’s Projects

ProjectPins UsedNotes
TILT replacement (I2C sensor)21 (SDA), 22 (SCL), 3.3V, GNDUses Grove I2C
OLED display (I2C)21 (SDA), 22 (SCL)0.96” SSD1306 typical
Stepper motor (ULN2003)Any safe GPIO x 44 control pins
ServoGPIO 4 or 550Hz PWM
DS18B20 temp sensorAny GPIO (1-wire)Single wire + pullup

Research from web search — ESP32 GPIO mapping for M5Stack Core Queue: research complete — moved to wiki