M5Unified Configuration
Factory: M5.config()
Type: m5::M5Unified::config_t
Before M5Cardputer.begin(), you can customize hardware initialization via M5.config(). This page covers the fields most relevant to M5Cardputer development.
Usage Pattern
auto cfg = M5.config();
cfg.serial_baudrate = 115200;
cfg.output_power = true;
M5Cardputer.begin(cfg, true);
M5Cardputer.begin() calls M5.begin(cfg) internally, then sets up the keyboard.
Key Config Fields for M5Cardputer
| Field | Type | Default | Description |
|---|---|---|---|
serial_baudrate |
uint32_t |
0 |
Serial baud rate. 0 = disabled. Set to 115200 for USB-CDC monitor. |
output_power |
bool |
true |
5V output on Port.A GPIO pins. For external I2C sensors. |
clear_display |
bool |
true |
Clear screen on startup. |
internal_mic |
bool |
true |
Enable internal PDM microphone (GPIO 46 data, GPIO 43 WS). |
internal_spk |
bool |
true |
Enable internal I2S speaker (GPIO 42 data, GPIO 41 BCK, GPIO 43 WS). |
internal_imu |
bool |
true |
Enable IMU. M5Cardputer has no IMU — set to false. |
internal_rtc |
bool |
true |
Enable RTC. M5Cardputer has no RTC — set to false. |
led_brightness |
uint8_t |
0 |
System LED brightness (not the NeoPixel). M5Cardputer has no system LED. |
fallback_board |
board_t |
varies | Board type if auto-detect fails. Useful: m5::board_t::board_M5Cardputer |
M5Cardputer-Specific Hardware Table
I2C Pins
| Board | Internal SCL | Internal SDA | External SCL (Port.A) | External SDA (Port.A) |
|---|---|---|---|---|
| M5Cardputer | — (none) | — (none) | GPIO 2 | GPIO 1 |
| M5Cardputer-ADV | GPIO 9 | GPIO 8 | GPIO 2 | GPIO 1 |
M5Cardputer (standard) has no internal I2C. Only Port.A (Ex_I2C) is available externally.
Audio Pins
| Component | Pin | Signal |
|---|---|---|
| Mic Data | GPIO 46 | PDM microphone |
| Mic WS | GPIO 43 | PDM word select |
| Speaker BCK | GPIO 41 | I2S bit clock |
| Speaker WS | GPIO 43 | I2S word select |
| Speaker DOUT | GPIO 42 | I2S data output |
Display Pins (ST7789 via SPI)
| Signal | GPIO |
|---|---|
| MOSI | 35 |
| SCLK | 36 |
| DC | 34 |
| CS | 37 |
| RST | 33 |
| Backlight PWM | 9 |
Other Pins
| Component | GPIO |
|---|---|
| Button A | 0 |
| SD Card CS | 12 |
| IR LED | 44 |
| NeoPixel RGB | 21 |
| SD SCK | 40 |
| SD MISO | 39 |
| SD MOSI | 14 |
No config_t fields control these pins — they are auto-set by M5Unified board detection.
Recommended M5Cardputer Config Template
#include <M5Cardputer.h>
void setup() {
auto cfg = M5.config();
// === Communication ===
cfg.serial_baudrate = 115200;
// === Power ===
cfg.output_power = true; // Enable 5V on Port.A for I2C devices
// === Audio ===
cfg.internal_mic = true; // PDM mic on GPIO 46/43
cfg.internal_spk = true; // I2S speaker on GPIO 42/41/43
// === Disable unused peripherals ===
cfg.internal_imu = false; // Cardputer has no IMU
cfg.internal_rtc = false; // Cardputer has no RTC
// === Fallback ===
cfg.fallback_board = m5::board_t::board_M5Cardputer;
// === Initialize ===
M5Cardputer.begin(cfg, true); // true = enable keyboard
// === Post-init LCD tweaks ===
M5Cardputer.Display.setBrightness(128);
M5Cardputer.Speaker.setVolume(64);
}
Minimal Config
If unsure, just call M5Cardputer.begin() — the default config works for most cases. Only customize when you need to disable unused hardware or change serial baud rate.