Skip to content

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 LabelGPIO PinConnected Device
CLKGPIO18TM1637 clock line
DIOGPIO19TM1637 data line

TM1637 uses a two-wire protocol (I2C-like), powered by 3.3V or 5V.

JSON Configuration Example ​

json
{
  "peripherals": [
    {
      "id": "tm1637_01",
      "name": "TM1637 Seven-Segment",
      "type": 47,
      "enabled": false,
      "pins": [18, 19],
      "params": {
        "brightness": 3
      }
    }
  ]
}

Parameter Description ​

ParameterDescriptionRange
brightnessDisplay brightness0~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

  1. Click Peripheral Execution in the left menu
  2. Click New Rule button
  3. Fill in basic configuration:
    • Rule Name: Display Temperature
    • Report Data: ✅ Enable
    • Enabled: ✅ Enable

Step 3: Configure Trigger

  1. Click Add Trigger button

  2. Fill in trigger configuration:

    FieldValueDescription
    Trigger TypeSelect Timer TriggerPeriodically update display
    Timer ModeSelect Fixed IntervalBy millisecond interval
    Interval Time2000Update every 2 seconds

Step 4: Configure Action

  1. Click Add Action button

  2. Fill in:

    • Action Type: Select Display Value
    • Target Peripheral: Select tm1637_01
    • Data Source: Select sensor temperature value
  3. 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 ​

  1. Create rule, name: Display Time
  2. Trigger configuration:
    • Trigger Type: Select Timer Trigger
    • Timer Mode: Select Fixed Interval
    • Interval Time: 1000 (1 second)
  3. Action configuration:
    • Action Type: Select Display Time
    • Target Peripheral: Select tm1637_01
    • Show Colon: ✅ Enable (colon blinking)
  4. Click Save

Seven-Segment Display Reference ​

Action TypeFunctionUse Case
Display ValueShow numbers (-999~9999)Temperature, humidity, counts, etc.
Display TimeShow clock (HH:MM)Real-time clock display
Display SegmentCustom segment codeSpecial symbols

Notes ​

  1. Pin Order: First pin in the array is CLK, second is DIO
  2. Brightness Range: 0 is dimmest, 7 is brightest, recommend 3-4 for indoor use
  3. Display Digits: Standard module has 4 digits, display range -999~9999
  4. Refresh Rate: No need for high-frequency refresh, 1-2 seconds update is sufficient
  5. Colon Display: The colon between the middle two digits can be independently controlled, ideal for time display

FastBee | fastbee.cn