Skip to main content

Control 10-segment mini battery displays on a Raspberry Pi

Project description

RPi Mini Battery Display

Continous Integration PyPI package version Python versions GitHub license

Library and command-line program to control 10-segment mini battery displays based on the TM1651 chip, such as the ones from Open-Smart, on a Raspberry Pi.

System requirements

The rpi-mini-battery-display library is written to run on a Raspberry Pi. It uses the RPi.GPIO library to communicate with the TM1651 chip and is tested on Python 3.6 and higher.

Installation

sudo pip3 install rpi-mini-battery-display

Connections

The mini battery display should be connected like this to the Raspberry Pi's GPIO header:

Mini Battery Display Raspberry Pi
CLK BCM24
DIO BCM23
VCC 5 V
GND GND

See pinout.xyz for the Raspberry Pi GPIO pinout.

The CLK and DIO pin can be connected to other pins on the Raspberry Pi, but these are the default values used by the code. If you change the connections, you have to supply the other pin values as parameters to the software.

Usage

usage: rpi-mini-battery-display [-h] [-c CLOCK_PIN] [-d DATA_PIN]
                                [-b BRIGHTNESS]
                                level

Control a 10 LED mini battery display with TM1651 chip

positional arguments:
  level                 Battery level (range: 0-7)

optional arguments:
  -h, --help            show this help message and exit
  -c CLOCK_PIN, --clock-pin CLOCK_PIN
                        Clock pin in BCM notation (default: 24, range: 0-27)
  -d DATA_PIN, --data-pin DATA_PIN
                        Data pin in BCM notation (default: 23, range: 0-27)
  -b BRIGHTNESS, --brightness BRIGHTNESS
                        Brightness (default: 2, range: 0-7)

Changelog

  • 0.0.1 (2020-01-26): Initial version

TODO

  • Code refactoring, as this project currently is a rather direct Python port of the original C++/Arduino code that came with the mini battery display I bought on AliExpress.
  • Individually address the LED segments instead of only using them as a LED bar (fairly trivial to implement).
  • Add static typing with mypy.
  • Support other versions of the mini battery displays based on the TM1651 chip, for instance the 5-segment one.
  • Support other mini battery displays, such as the Grove LED Bar, which uses the MY9221 chip.

License

This project is provided by Koen Vervloesem as open source software with the MIT license. See the LICENSE file for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rpi-mini-battery-display-0.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

rpi_mini_battery_display-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file rpi-mini-battery-display-0.1.0.tar.gz.

File metadata

  • Download URL: rpi-mini-battery-display-0.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.5

File hashes

Hashes for rpi-mini-battery-display-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c6385d7d63d8bdb47b853f35f7c464a8187fafe99ce2bf3a0e4e819a1bf3dbae
MD5 16c0235be32590da28dd3aee4efc2e17
BLAKE2b-256 21addaafa3ef84e0c904faeadb4ce7c683a4ff04dcb78c02a558b9d71e1718a6

See more details on using hashes here.

Provenance

File details

Details for the file rpi_mini_battery_display-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rpi_mini_battery_display-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.5

File hashes

Hashes for rpi_mini_battery_display-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aceccb62c06600c2df0530d12629ee011bd559bac70c56eaf0f815707bd0c113
MD5 0dcbb35f1d1ad11a6c947e76740afec1
BLAKE2b-256 91eed3b4a498f7417096a4a446d1cc64a91c1e3ab60826e5a87381cf13a02dd3

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page