Skip to content

Example 52: TM1637 Seven-Segment Temp/Humidity Display ​

Scenario Overview ​

Use a DHT11/DHT22 temperature and humidity sensor to collect data, and alternately display temperature and humidity values on a TM1637 four-digit seven-segment display. Suitable for scenarios requiring long-distance data observation (e.g., greenhouse, server room temperature monitoring).

Required Hardware ​

ModuleModelPurpose
Temp & Humidity SensorDHT11 / DHT22Collect temperature and humidity
Seven-Segment DisplayTM1637 Four-DigitDisplay values
ESP32 Dev BoardPuzhong ESP32Main controller

Hardware Wiring ​

DHT11 Wiring ​

DHT11 PinESP32 GPIODescription
VCC3.3VPower
DATAGPIO 32Data pin
GNDGNDGround

TM1637 Seven-Segment Wiring ​

TM1637 PinESP32 GPIODescription
VCC3.3V / 5VPower
GNDGNDGround
CLKGPIO 18Clock pin
DIOGPIO 19Data pin

Peripheral Execution Linkage Configuration ​

Scenario 1: Alternate Display of Temperature and Humidity (Timer Trigger) ​

Function: Alternate display every 6 seconds (temperature 3s, humidity 3s)

Web Interface Configuration Steps ​

Rule 1: Display Temperature

  1. Click Peripheral Execution in the left menu

  2. Click Add Rule button

  3. Fill in basic configuration:

    • Rule Name: Display Temperature
    • Report Data: ✅ Enabled
    • Enable: ✅ Enabled
  4. Configure trigger:

    • Trigger Type: Select Timer Trigger
    • Timer Mode: Select Fixed Interval
    • Interval: 6000 (6 seconds)
    • Time Offset: 0 (0 second offset)
  5. Configure actions (2 actions required):

    • Action 1: Select Sensor Read, target dht1
    • Action 2: Select Seven-Segment Display, target tm1637_1, template {dht1.temperature}
  6. Click Save button

Rule 2: Display Humidity

  1. Create another rule, name: Display Humidity
  2. Trigger configuration:
    • Trigger Type: Select Timer Trigger
    • Interval: 6000 (6 seconds)
    • Time Offset: 3000 (3 second offset, staggered from temperature)
  3. Action configuration:
    • Action 1: Select Sensor Read, target dht1
    • Action 2: Select Seven-Segment Display, target tm1637_1, template {dht1.humidity}
  4. Click Save

Function: Seven-segment display blinks and buzzer triggers when temperature exceeds 35°C

Configuration Steps:

  1. Create a rule, name: High Temp Blink
  2. Trigger configuration:
    • Trigger Type: Select Poll Trigger
    • Target Peripheral: Select dht1
    • Data Field: temperature
    • Operator: >
    • Threshold: 35
    • Poll Interval: 5000
  3. Action configuration (2 actions required):
    • Action 1: Select Seven-Segment Display, target tm1637_1, template {dht1.temperature}, ✅ Enable blink
    • Action 2: Select HIGH, target buzzer1 (buzzer must be configured in advance)
  4. Click Save

Complete Configuration Import ​

json
[
  {
    "id": "dht1",
    "name": "DHT11 Temp & Humidity",
    "type": 38,
    "enabled": false,
    "pins": [32],
    "params": {
      "driver": "DHT",
      "model": "DHT11",
      "interval": 3000
    }
  },
  {
    "id": "tm1637_1",
    "name": "Four-Digit Seven-Segment",
    "type": 47,
    "enabled": false,
    "pins": [18, 19],
    "params": {
      "brightness": 4,
      "colon": true
    }
  }
]

Display Output ​

TM1637 four-digit seven-segment display:

Temperature mode: 25.3 (shows 25.3, colon blinks to indicate active sampling)
Humidity mode: 60.5 (shows 60.5)
  • Supports displaying values from 0-9999
  • Supports one decimal point
  • Colon can indicate status (blinking = normal, steady = alarm)

Comparison with OLED Solution ​

FeatureTM1637 Seven-SegmentSSD1306 OLED
Display ContentNumbers onlyText + graphics
Viewing DistanceFar (5-10m)Near (< 1m)
Power ConsumptionHigherVery low
Suitable ScenariosFactory/greenhouse/server roomDesktop/portable devices
Information CapacityLow (4 digits)High (multi-line text)

Notes ​

  1. Display Precision: TM1637 has only 4 digits, temperature shows 25.3, humidity 60.5
  2. Data Format: Sensor values are automatically truncated to displayable digits
  3. Brightness Adjustment: Adjust brightness parameter per ambient light (0=dimmest, 7=brightest)
  4. Refresh Rate: Recommend ≥ 1000ms refresh interval, too fast causes flickering
  5. Pin Conflict: CLK/DIO can use any GPIO, avoid conflict with SPI devices

FastBee | fastbee.cn