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)
| Pin | Reserved For | Notes |
|---|---|---|
| 0 | Boot / Button | Pulldown at boot — unsafe for output |
| 1 | TX0 | Debug serial |
| 2 | Boot / Button | Pulldown at boot |
| 3 | RX0 | Debug serial |
| 6-11 | Flash SPI | Internal flash memory — do not use |
| 12 | Boot / GPIO | Pulldown at boot — unsafe for output |
| 18, 19, 23 | SPI (LCD + TF Card) | Shared with display and SD card |
| 25 | Speaker | Connected to internal speaker amplifier |
| 21, 22 | I2C (Grove port) | SDA/SCL — available if Grove not used |
Safe GPIO for Custom Use
| Pin | Safe Use | Notes |
|---|---|---|
| 4 | General I/O | Safe if speaker not used |
| 5 | General I/O | Safe |
| 13 | General I/O | Safe |
| 14 | General I/O | Safe |
| 15 | General I/O | Safe (also MTDO) |
| 16 | General I/O | Safe |
| 17 | General I/O | Safe |
| 26 | Analog input | 12-bit ADC (also digital I/O) |
| 27 | Analog input | 12-bit ADC (also digital I/O) |
| 32-39 | Analog input | 12-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
| Project | Pins Used | Notes |
|---|---|---|
| TILT replacement (I2C sensor) | 21 (SDA), 22 (SCL), 3.3V, GND | Uses Grove I2C |
| OLED display (I2C) | 21 (SDA), 22 (SCL) | 0.96” SSD1306 typical |
| Stepper motor (ULN2003) | Any safe GPIO x 4 | 4 control pins |
| Servo | GPIO 4 or 5 | 50Hz PWM |
| DS18B20 temp sensor | Any GPIO (1-wire) | Single wire + pullup |
Research from web search — ESP32 GPIO mapping for M5Stack Core Queue: research complete — moved to wiki