TM1637 Seven-Segment Display
TM1637 Seven-Segment Display
Overview
TM1637 is a 4-digit 7-segment display driver chip that communicates via a 2-wire serial interface (CLK + DIO). Suitable for displaying numbers, time, and simple text.
Supported Peripheral Types
| Type | type Value | Description |
|---|---|---|
| SEVEN_SEGMENT_TM1637 | 47 | TM1637 4-digit display |
Hardware Wiring
| TM1637 Pin | Connection | Description |
|---|---|---|
| VCC | 3.3V / 5V | Power supply |
| GND | GND | Ground |
| CLK | GPIO (any) | Clock line |
| DIO | GPIO (any) | Data line |
Configuration
Method 1: Web Interface Configuration (Recommended)
Before saving TM1637 configuration, verify CLK/DIO pins, digit count, and default brightness.
For TM1637 debugging, first display a fixed number to confirm CLK/DIO pins and brightness, then connect to sensor readings or peripheral execution actions.
Step 1: Navigate to Peripheral Management Page
- Open a browser and navigate to the ESP32 IP address
- After logging in, click Peripheral Configuration in the left menu
Step 2: Add TM1637 Seven-Segment Display Peripheral
Click the Add Peripheral button
Fill in the configuration:
Field Value Description Peripheral ID tm1637_1Unique identifier Name 4-Digit DisplayDisplay name Peripheral Type Seven-Segment Display (type: 47) TM1637 driver CLK Pin 18Clock pin DIO Pin 19Data pin Brightness 40-7 (0=dim, 7=brightest) Click Save
Step 3: Verify Configuration
- Find the newly added peripheral in the peripheral list
- Click the Enable toggle
- The display should show default content
💡 Tip: Recommend using 5V power supply for optimal brightness
Method 2: JSON Configuration File Import
Add the following configuration to the peripherals array in data/config/peripherals.json:
{
"id": "tm1637_1",
"name": "4-Digit Display",
"type": 47,
"enabled": false,
"pins": [18, 19],
"params": {
"brightness": 4
}
}Parameter Description
| Parameter | Description | Range |
|---|---|---|
| brightness | Display brightness | 0-7 (0=dim, 7=brightest) |
pins[0] = CLK pin, pins[1] = DIO pin
Peripheral Execution Integration
Web Interface Configuration Steps
Create Display Rule
- Switch to the Peripheral Execution Management tab
- Click the Add Rule button
- Configure trigger (e.g., timer trigger, 5-second interval)
- Add actions:
- Action 1: Read sensor data
- Action Type: Sensor Read
- Target Peripheral: dht1
- Action 2: Display on seven-segment display
- Action Type: Display Number
- Target Peripheral: tm1637_1
- Enable Use Received Value (display temperature value)
- Action 1: Read sensor data
- Click Save
💡 Tip: Can use "Display Number", "Display Text", or "Clear Screen" actions
JSON Configuration Example
Display Number (ACTION_DISPLAY_NUMBER = 24)
{
"targetPeriphId": "tm1637_1",
"actionType": 24,
"actionValue": "12.34",
"useReceivedValue": false,
"syncDelayMs": 0,
"execMode": 0
}Supported number formats:
"1234"— Display 1234"12.34"— Display 12.34 (with decimal point)"12:34"— Display 12:34 (with colon, suitable for clock)
Display Text (ACTION_DISPLAY_TEXT = 25)
{
"targetPeriphId": "tm1637_1",
"actionType": 25,
"actionValue": "PLAY",
"useReceivedValue": false,
"syncDelayMs": 0,
"execMode": 0
}Only some displayable characters are supported: 0-9, A-F, H, L, P, U, b, d, o, n, r, t, -
Clear Screen (ACTION_DISPLAY_CLEAR = 26)
{
"targetPeriphId": "tm1637_1",
"actionType": 26,
"actionValue": "",
"useReceivedValue": false,
"syncDelayMs": 0,
"execMode": 0
}Display with Received Value
When useReceivedValue: true, the sensor data received at trigger time is displayed directly:
{
"id": "exec_show_temp",
"name": "Display Temperature on Seven-Segment",
"enabled": false,
"execMode": 0,
"triggers": [
{
"triggerType": 1,
"triggerPeriphId": "",
"operatorType": 0,
"compareValue": "",
"timerMode": 0,
"intervalSec": 5,
"timePoint": "",
"eventId": "",
"pollResponseTimeout": 1000,
"pollMaxRetries": 2,
"pollInterPollDelay": 100
}
],
"actions": [
{
"targetPeriphId": "dht1",
"actionType": 19,
"actionValue": "",
"useReceivedValue": false,
"syncDelayMs": 0,
"execMode": 0
},
{
"targetPeriphId": "tm1637_1",
"actionType": 24,
"actionValue": "",
"useReceivedValue": true,
"syncDelayMs": 100,
"execMode": 0
}
],
"protocolType": 0,
"scriptContent": "",
"reportAfterExec": false
}Notes
- Pin Order: In configuration, pins[0] is CLK, pins[1] is DIO; do not reverse
- Character Limit: Only 4 digits displayed; numbers/text exceeding 4 digits will be truncated
- Brightness Adjustment: 0-7 brightness levels adjustable via Web interface or configuration
- Power Supply: Recommend 5V power supply for optimal brightness; 3.3V also works but dimmer
- Refresh Rate: Display updates immediately when content changes; no need to worry about refresh rate
