This module contains methods to drive the TM1637 display module as well as clock, scrolling ASCII text and system information functionality. Attaching this to a SBC can give useful insight on the system status or just keep time.
TM1637 8 segment, 4 digit LED examples:
TM1637 8 segment 0.36INCH Digital Display Tube 4 digit LED module:
python-periphery library.
sudo apt update
sudo apt install git python3-pip python3-setuptools
git clone https://github.com/vsergeev/python-periphery.git
cd python-periphery/
python3 -m pip install python-periphery
python-periphery is a highly compatible library.
Available for most Pi boards.
LED Module | Raspberry Pi | |
---|---|---|
CLK | Pin#5 | (*1) |
DIO | Pin#3 | (*1) |
GND | GND | |
5V | 3V3 | (*2) |
(*1)
You can use any GPIO with startup arguments.
(*2)
RPi reads data from DIO, so it must be 3V3.
cd $HOME
git clone https://github.com/nopnop2002/python-periphery-tm1637
cd python-periphery-tm1637/
python3 tm1637.py
If you use this module on something other than Raspberry Pi, you will need to change the GPIO.
$ python3 tm1637.py --help
usage: tm1637.py [-h] [--clk CLK] [--dio DIO] [--text TEXT]
optional arguments:
-h, --help show this help message and exit
--clk CLK CLK GPIO
--dio DIO DIO GPIO
--text TEXT
If you use Pin#3 and Pin#5, it will be as follows.
CLK(Pin#5) | DIO(Pn#3) | ||
---|---|---|---|
Raspberry Pi | 3 | 2 | Default |
Orange Pi Allwinner H2+ | 11 | 12 | |
Orange Pi Allwinner H3 | 11 | 12 | |
Orange Pi Allwinner H5 | 11 | 12 | |
Orange Pi Allwinner A64 | 226 | 227 | |
Orange Pi 3 | 121 | 122 | |
Orange Pi Lite2 | 229 | 230 | |
Orange Pi OnePlus | 229 | 230 | |
Orange Pi RK3399 | 44 | 43 | |
Orange Pi 4 | 65 | 64 | |
Nano Pi Allwinner H3 | 11 | 12 | |
Nano Pi Allwinner H5 | 11 | 12 |
Other default values are set as follows:
_DEF_TM1637_BRIGHT = 0xA # Default brightness from 0x0 to 0xF
_DEF_TM1637_ANIM_DELAY = 0.2 # Default animation delay in seconds
If you want to display the CPU temperature, you need to change the following depending on the board.
show_on_high_cpu_thermal(tm, 50, "/sys/devices/virtual/thermal/thermal_zone0/temp")
# Please change your cpu sensor path if different
python3 tm1637.py
When specifying GPIO.
python3 tm1637.py --clk=11 --dio=12
Privilege elevation might be required.
sudo -E python3 tm1637.py
python3 tm1637.py --text="any_text"
When specifying GPIO.
python3 tm1637.py --text="any_text" --clk=11 --dio=12
Privilege elevation might be required.
sudo -E python3 tm1637.py --text="any_text"