Home Elements Boards Recipes

TM1637 Element

The TM1637 is a chip that allows using 7-segment displays up to 6 digits.

TM1637 based display

There are many different TM1637 based displays on the market and some also include input. This Element supports displays with 4-digits that can display time as it has colon leds in the middle. The decimal dots (when existing) are not wired and cannot be used.

Element Configuration

The following properties are available for configuration of the element.

value - The displayed value. This can be used to initialize the display until a valid value is passed by a value-action.

brightness - The brightness factor can be used to dim the light in general. The brightness value must be in the range 0…8. The default is 2.

clockpin - Specifies the output pin that is used for the clock signal to the chip.

datapin - Specifies the output pin that is used for the data signal to the chip.

enabled - to enable / disable the light without loosing the current value and brightness.

From the base element implementation the following properties are available for configuration:

title – Caption text for the element. Used by the element specific cards on the dash boards.

description – A line of text that gives a short description of the device used in the web UI.

room – The location of the device.

loglevel – This property holds the element specific log level. The default value is LOGGER_LEVEL_ERR == 1.

startup – This property can be used to start the element using a different initialization phase. Possible values are “sys”, “net”, “time”. See The Startup sequence.

Configuration Example

A configuration for a ESP8266 based board can use the GPIO pins D6 and D7:

{
  "tm1637": {
    "0": {
      "title": "Time Display",
      "clockpin": "D6",
      "datapin": "D7",
      "brightness": "4",
      "value": "--:--"
    }
  }
}

A configuration for a ESP32 based board can use the GPIO pins 25 and 26:

{
  "tm1637": {
    "0": {
      "title": "Time Display",
      "clockpin": "26",
      "datapin": "25",
      "brightness": "4",
      "value": "--:--"
    }
  }
}

Element State

The following properties are available with the current values at runtime:

active - Is set to true when the element is active.

value - Current output value of the element.

Example State

The internal value can be seen in the rotary state but should not directly be used as a value.

{
  "my9291/0": {
    "active": "true",
    "value": "11:55"
  }
}

Implementation hints

The TM1637 is controlled using a clock and a data signal. The protocol is similar to I2C protocol. The TM1637 cannot be part of the I2C bus but always needs a one-to-one connectivity.

The protocol implementation is present in the tm1637.h file and supports only displaying 4 digits and the colon right now.

See also

Tags

Element Light