Example 15: Seven-Segment Display (TM1637)
About 2 min
Example 15: Seven-Segment Display (TM1637)
Experiment Overview
Control a 4-digit seven-segment display via TM1637 driver chip to show numbers, temperature and other data. FastBee has a built-in TM1637 peripheral type (type: 47), supporting numeric display and custom segment codes.
Hardware Wiring
| Board Label | GPIO Pin | Connected Device |
|---|---|---|
| CLK | GPIO18 | TM1637 clock line |
| DIO | GPIO19 | TM1637 data line |
TM1637 uses a two-wire protocol (I2C-like), powered by 3.3V or 5V.
JSON Configuration Example
{
"peripherals": [
{
"id": "tm1637_01",
"name": "TM1637 Seven-Segment",
"type": 47,
"enabled": false,
"pins": [18, 19],
"params": {
"brightness": 3
}
}
]
}Parameter Description
| Parameter | Description | Range |
|---|---|---|
| brightness | Display brightness | 0~7 |
Peripheral Execution Linkage
Scenario 1: Periodic Temperature Display (Timer Trigger)
Function: Read temperature sensor every 2 seconds and display on seven-segment display
Web Interface Configuration Steps
Step 1: Ensure temperature sensor is configured
- Peripheral ID:
dht11_sensor - Type: DHT11 temperature/humidity sensor
Step 2: Create Rule
- Click left menu Peripheral Configuration → Switch to Peripheral Execution Management tab
- Click New Rule button
- Fill in basic configuration:
- Rule Name:
Display Temperature - Report Data: ✅ Enable
- Enabled: ✅ Enable
- Rule Name:
Step 3: Configure Trigger
Click Add Trigger button
Fill in trigger configuration:
Field Value Description Trigger Type Select Timer Trigger Periodically update display Timer Mode Select Fixed Interval By millisecond interval Interval Time 2000Update every 2 seconds
Step 4: Configure Action
Click Add Action button
Fill in:
- Action Type: Select Display Value
- Target Peripheral: Select
tm1637_01 - Data Source: Select sensor temperature value
Click Save button
Scenario 2: Display Time (Timer Trigger)
Function: Update seven-segment display with current time every second (with colon blinking)
Web Interface Configuration Steps
- Create rule, name:
Display Time - Trigger configuration:
- Trigger Type: Select Timer Trigger
- Timer Mode: Select Fixed Interval
- Interval Time:
1000(1 second)
- Action configuration:
- Action Type: Select Display Time
- Target Peripheral: Select
tm1637_01 - Show Colon: ✅ Enable (colon blinking)
- Click Save
Seven-Segment Display Reference
| Action Type | Function | Use Case |
|---|---|---|
| Display Value | Show numbers (-999~9999) | Temperature, humidity, counts, etc. |
| Display Time | Show clock (HH:MM) | Real-time clock display |
| Display Segment | Custom segment code | Special symbols |
Notes
- Pin Order: First pin in the array is CLK, second is DIO
- Brightness Range: 0 is dimmest, 7 is brightest, recommend 3-4 for indoor use
- Display Digits: Standard module has 4 digits, display range -999~9999
- Refresh Rate: No need for high-frequency refresh, 1-2 seconds update is sufficient
- Colon Display: The colon between the middle two digits can be independently controlled, ideal for time display
