pdf-icon

Arduino Quick Start

2. Devices & Examples

M5Unified Library Data Definitions

Boards

M5.getBoard()

Enumerated values of development board types obtainable via M5.getBoard():

namespace boards
  { // Be careful not to change existing board numbers when adding values.
    enum board_t
    { board_unknown = 0
    , board_M5Stack
    , board_M5StackCore2
    , board_M5StickC
    , board_M5StickCPlus
    , board_M5StickCPlus2
    , board_M5StackCoreInk
    , board_M5Paper
    , board_M5Tough
    , board_M5Station
    , board_M5StackCoreS3
    , board_M5AtomS3
    , board_M5Dial
    , board_M5DinMeter
    , board_M5Cardputer
    , board_M5AirQ
    , board_M5VAMeter
    , board_M5StackCoreS3SE
    , board_M5AtomS3R
    , board_M5PaperS3
    , board_M5CoreMP135
    , board_M5StampPLC
    , board_M5Tab5
/// non display boards 
    , board_M5AtomLite = 128
    , board_M5ATOM __attribute__ ((deprecated)) = board_M5AtomLite
    , board_M5Atom __attribute__ ((deprecated)) = board_M5AtomLite
    , board_M5AtomPsram
    , board_M5AtomU
    , board_M5Camera
    , board_M5TimerCam
    , board_M5StampPico
    , board_M5StampC3
    , board_M5StampC3U
    , board_M5StampS3
    , board_M5AtomS3Lite
    , board_M5AtomS3U
    , board_M5Capsule
    , board_M5NanoC6
    , board_M5AtomMatrix
    , board_M5AtomEcho
    , board_M5AtomS3RExt
    , board_M5AtomS3RCam
/// external displays
    , board_M5AtomDisplay = 192
    , board_M5ATOMDisplay = board_M5AtomDisplay
    , board_M5UnitLCD
    , board_M5UnitOLED
    , board_M5UnitMiniOLED
    , board_M5UnitGLASS
    , board_M5UnitGLASS2
    , board_M5UnitRCA
    , board_M5ModuleDisplay
    , board_M5ModuleRCA
    , board_FrameBuffer = 512
    };
  }

Configs

M5.config()

Global configuration parameters

Parameter Name Type Description Default Applicable Conditions
serial_baudrate uint32_t USB serial baud rate 115200 Arduino-esp32 platform only
clear_display bool Clear the screen on startup true Valid only for devices with a display
output_power bool External 5 V power output switch true Devices equipped with an AXP192 PMIC only
pmic_button bool Enable PMIC button true Devices equipped with an AXP192 PMIC only
internal_imu bool Enable built-in IMU true Devices with an IMU module only
internal_rtc bool Use built-in RTC true Devices with an RTC module only
internal_mic bool Use built-in microphone true Devices with a microphone only
internal_spk bool Use built-in speaker true Devices with a speaker only
external_imu bool Use external IMU/accelerometer unit false Supported devices:
Unit IMU
Unit Accel
Unit Mini IMU
Unit Mini IMU Pro
external_rtc bool Use external RTC unit false Supported devices:
Unit RTC
disable_rtc_irq bool Disable RTC interrupt request bit at startup true Devices with an RTC module only
led_brightness uint8_t Built-in LED brightness (0-255) 0 Monochrome LED devices only (no effect on RGB LEDs)

external_speaker

External speaker enable parameters. Choose either of the following two. Use in the form external_speaker.<device_name>.

Parameter Name Type Description Default Applicable Conditions
external_speaker_value uint16_t Enable external speaker, bit-wise 0xFFFF See member definitions in the structure below
external_speaker struct Enable external speaker. Members (device_name):
(1 bit each unless otherwise noted)
module_display
atom_display
unit_oled
unit_mini_oled
unit_lcd
unit_glass
unit_glass2
unit_rca
module_rca
reserve (7 bits reserved)
0xFFFF Devices defined in the member list
Supported external devices:
Hat SPK
Hat SPK2
Atomic Echo Base
Atomic SPK Base

external_display

External display enable parameters. Choose either of the following two. Use in the form external_display.<device_name>.

Parameter Name Type Description Default Applicable Conditions
external_display_value uint16_t Enable external display, bit-wise 0xFFFF See member definitions in the structure below
external_display struct Enable external display. Members (device_name):
(1 bit each unless otherwise noted)
module_display
atom_display
unit_oled
unit_mini_oled
unit_lcd
unit_glass
unit_glass2
unit_rca
module_rca
reserve (7 bits reserved)
0xFFFF Devices defined in the member list

Related external devices:

M5.Speaker.config()

Speaker configuration parameters

Parameter Name Type Description Default Note
pin_data_out int I2S data out pin (speaker) -1 Specify GPIO number
pin_bck int I2S bit/serial clock pin (BCK/SCLK) -1
pin_mck int I2S master clock pin (MCLK) -1
pin_ws int I2S channel select pin (WS/LRCK) -1
sample_rate uint32_t Sampling rate (Hz) 48000
stereo bool Enable stereo false
buzzer bool Use buzzer output false Only data_out pin needs to be set when enabled
use_dac bool Use built-in DAC output false Only data_out pin needs to be set when enabled; ESP32 supports I2S_NUM_0, GPIO25/26 only
dac_zero_level uint8_t DAC zero-level reference 0 0 means auto-adjust
magnification uint8_t Output gain 16
dma_buf_len size_t I2S DMA buffer length 256 Maximum 1024
dma_buf_count size_t I2S DMA buffer count 8
task_priority uint8_t Audio playback task priority 2
task_pinned_core uint8_t CPU core bound to the audio playback task -1
i2s_port i2s_port_t I2S port used I2S_NUM_0 I2S0 or I2S1

Buttons

GPIO mapping of buttons for each device model:

Device Model BtnA BtnB BtnC BtnPWR BtnEXT
M5Basic/Gray/Go/Fire GPIO39 GPIO38 GPIO37 - -
M5Core2 TouchA TouchB TouchC -
M5Stick C/CPlus GPIO39 GPIO37 - AXP192 -
M5StickCPlus2 GPIO37 GPIO39 GPIO35 - -
M5CoreInk GPIO37(Up) GPIO38(Press) GPIO39(Down) GPIO27 GPIO5
M5Paper GPIO37(Up) GPIO38(Press) GPIO39(Down) - -
M5Station GPIO37 GPIO38 GPIO39 AXP192 -
M5Tough - - - AXP192 -
M5AirQ GPIO0 GPIO8 - - -
M5Atom-Lite/Matrix GPIO39 - - - -
M5AtomS3/S3-Lite GPIO41 - - - -
M5Capsule GPIO42 - - - -
M5Cardputer GPIO0 - - - -
M5Dial GPIO42 - - - -
M5DinMeter GPIO42 - - - -
M5StampPico GPIO39 - - - -
M5StampC3/C3U GPIO3 - - - -
M5StampS3/S3A GPIO0 - - - -
M5StamPLC P2 P1 P0 - -
On This Page