MT25C serial commands reference
MT25C is operated via a virtual serial interface (USB CDC‑ACM). Users may control the device either with the provided GUI or directly through this documented protocol.
This document provides a reference for the most basic way to communicate with the MT25C. To get started quickly, we recommend using the provided MT25C-Term GUI application, which allows you to easily generate packets and test them on a connected MT25C device. The GUI also provides a convenient way to visualize the results of your commands.
Packet format
Header | Size (LSB, MSB) | Command | Payload | CRC (LSB, MSB) |
---|---|---|---|---|
0x55 | byte‑count of Command + Payload + CRC | 1 byte | N bytes | 2 bytes |
Every command sent by the host is acknowledged by the MT25C with the same command code and a zero‑length payload.
CRC‑16‑CCITT calculation
All packets include a 16‑bit CRC calculated over the Command byte and the Payload bytes only (header 0x55
and size field are excluded).
Parameter | Value |
---|---|
Polynomial | 0x1021 |
Init value | 0xFFFF |
Reflection | None |
Final XOR | None |
POLY = 0x1021
INIT = 0xFFFF
def crc16_ccitt(data: bytes) -> int:
crc = INIT
for b in data:
crc ^= b << 8
for _ in range(8):
crc = ((crc << 1) ^ POLY) if (crc & 0x8000) else (crc << 1)
crc &= 0xFFFF
return crc
Pin states
Context | State | Value | Description |
---|---|---|---|
Static measurement | LED‑A | 0x01 | LED anode |
LED‑C | 0x02 | LED cathode | |
LED‑AC | 0x03 | Bidirectional LED | |
SHORT | 0x04 | Short circuit | |
COM | 0x05 | Common pin | |
Mechanical button | BUT0 | 0x10 | Button released |
BUT1 | 0x11 | Button pressed | |
Capacitive button | TCH0 | 0x20 | Touch released |
TCH1 | 0x21 | Touch pressed |
Serial command list
Request ID
Command name: ID
Command code: 0x00
Description: Sent by the host to identify the connected MT25C. The device replies with the ASCII string "MT25C"
(0x4D 0x54 0x32 0x35 0x43
).
Payload size: 0
Example frame: 55 00 03 00 E1 F0
Load configuration
Command name: CFG
Command code: 0x01
Description: Configure operating parameters.
Payload size: 3 • Byte 1 – Maximum contact resistance (Ω, 0‑255) • Byte 2 – Capacitive threshold (0‑128) • Byte 3 – Buzzer volume (0‑100)
Example frame: (contact resistance: 50 Ω, capacitive threshold: 32, volume: 100) 55 00 06 01 32 20 64 73 75
Set insertion detection mode
Command name: DETECT_INSERT
Command code: 0x02
Description: Puts the MT25C in keypad‑insertion detection mode.
Payload size: 0
Example frame: 55 00 03 02 C1 B2
Keypad inserted event (device → host)
Command name: ON_INSERT
Command code: 0x03
Description: Emitted when a keypad is detected.
Payload size: 0
Example frame: 55 00 03 03 D1 93
Request static measurement
Command name: MES_STATIC
Command code: 0x04
Description: Launch a static measurement (LEDs, shorts, opens).
Payload size: 0
Example frame: 55 00 03 04 A1 74
Static measurement event (device → host)
Command name: ON_STATIC_MES
Command code: 0x05
Description: Returns N measurement pairs. Each pair is 6 bytes: Pin1, State1, Pin2, State2, Vdrop12, Vdrop21 (20 mV/LSB).
Payload size: 6 × N
Example frame: (one pair 1‑2) 55 00 09 05 01 01 02 02 05 07 6B 82
Request mechanical button scan
Command name: MES_BUTTON_MECH
Command code: 0x06
Description: Enables mechanical button scanning; events are reported with ON_BUTTON_MECH.
Payload size: 0
Example frame: 55 00 03 06 81 36
Mechanical button event (device → host)
Command name: ON_BUTTON_MECH
Command code: 0x07
Description: Indicates a mechanical button press/release.
Payload size: 6
Example frame: (button 1‑2 pressed) 55 00 09 07 01 10 02 11 00 00 30 4B
Request capacitive button scan
Command name: MES_BUTTON_CAP
Command code: 0x08
Description: Enables capacitive button scanning; events are reported with ON_BUTTON_CAP.
Payload size: 0
Example frame: 55 00 03 08 60 F8
Capacitive button event (device → host)
Command name: ON_BUTTON_CAP
Command code: 0x09
Description: Indicates a capacitive pad touch/release.
Payload size: 4
Example frame: (pad 1‑2 touched) 55 00 07 09 01 20 02 21 1B 23
Set removal detection mode
Command name: DETECT_REMOVE
Command code: 0x0A
Description: Puts the MT25C in keypad‑removal detection mode.
Payload size: 0
Example frame: 55 00 03 0A 40 BA
Keypad removal event (device → host)
Command name: ON_REMOVE
Command code: 0x0B
Description: Emitted when a keypad is removed.
Payload size: 0
Example frame: 55 00 03 0B 50 9B