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:
Please install the "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
LED Module | Raspberry Pi |
---|---|
CLK | Pin#5 |
DIO | Pin#3 |
GND | GND |
5V or 3V3 | 3V3 |
(Use the next table if you are not running this on a Raspberry Pi)
git clone https://github.com/nopnop2002/python-periphery-tm1637
cd python-periphery-tm1637/
vi tm1637.py
If you use this module on something other than Raspberry Pi, you should change the following:
_DEF_TM1637_CLK = ## # Default GPIO for CLK
_DEF_TM1637_DIO = ## # Default GPIO for DIO
These default names are loaded as implicit parameters on creation of an instance of TM1637, but other values can be passed as well to manage multiple displays at once. In that case also make sure to export all GPIO pins used as "out" before creation (see the first lines of the __main__).
CLK | DIO | |
---|---|---|
Raspberry Pi | 3 | 2 |
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 |
Other default values can be set for more parameters as well.
_DEF_TM1637_BRIGHT = 0xA # Default brightness from 0x0 to 0xF
_DEF_TM1637_ANIM_DELAY = 0.2 # Default animation delay in seconds
Remember to change your CPU temperature sensor in the script if necessary, inside _demo():
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
Privilege elevation might be required.
sudo -E python3 tm1637.py