Skip to main content

Tire Pressure Monitoring System Python Library

Project description

TPMS

Tire Pressure Monitoring System Python Library

Overview

The TPMS (Tire Pressure Monitoring System) Python library is designed to monitor tire pressure and temperature for vehicles equipped with generic (aliexpress) TPMS sensors. This library supports multiple hardware versions and provides options to configure the serial port, baud rate, temperature units, and pressure units.

Features

  • Supports TY06 and TY05 hardware versions (current versions appear to be all TY06)
  • Configurable serial port and baud rate
  • Temperature units: Celsius, Fahrenheit
  • Pressure units: kPa, psi, bar
  • Continuous monitoring of tire pressure and temperature
  • Logging of tire status events

Installation

Install the TPMS library using pip:

pip install tpms

Usage You can run the TPMS library with default settings or customize the serial port, baud rate, temperature unit, pressure unit, and hardware version.

Default Usage To run the TPMS library with default settings:

tpms

Custom Usage To specify custom settings:

tpms --port COM3 --baudrate 19200 --temp_unit Fahrenheit --pressure_unit psi --hardware_version TY06

Example Code Below is an example of how to use the TPMS library in a Python script:

from tpms import TPMS

def main():
    # Initialize TPMS with the desired settings
    tpms = TPMS(
        port='/dev/ttyUSB0',       # Replace with your serial port
        baudrate=19200,
        temp_unit='Celsius',       # Options: 'Celsius', 'Fahrenheit'
        pressure_unit='kPa',       # Options: 'kPa', 'psi', 'bar'
        hardware_version='TY06'    # Options: 'TY06', 'TY05'
    )

    # Connect to the TPMS device
    tpms.connect()

    # Start monitoring the tire pressure and temperature
    tpms.heartbeat()  # Start sending heartbeat signals

    # Infinite loop to read data from the TPMS device
    while True:
        try:
            raw_data = tpms.ser.read(256)  # Read up to 256 bytes at a time
            if raw_data:
                tpms.incoming_buffer.extend(raw_data)
                frames, tpms.incoming_buffer = tpms.protocol_frame_filter(tpms.incoming_buffer)
                for frame in frames:
                    event = tpms.decode_frame(frame)
                    if event:
                        tpms.on_event(event)
        except (serial.SerialException, serial.SerialTimeoutException):
            logger.error("Serial port unavailable, reconnecting...")
            tpms.ser.close()
            tpms.connect()
        except KeyboardInterrupt:
            if tpms.ser is not None:
                tpms.ser.close()
                logger.info("Port closed!")
            logger.info("KeyboardInterrupt detected, exiting...")
            break

if __name__ == "__main__":
    main()

Functions Initialization

tpms = TPMS(
    port='/dev/ttyUSB0',       # Replace with your serial port
    baudrate=19200,
    temp_unit='Celsius',       # Options: 'Celsius', 'Fahrenheit'
    pressure_unit='kPa',       # Options: 'kPa', 'psi', 'bar'
    hardware_version='TY06'    # Options: 'TY06', 'TY05'
)

Connect Connect to the TPMS device:

tpms.connect()

Heartbeat Send periodic heartbeat signals:

tpms.heartbeat()

Pairing Sensors Pair sensors to specific tire positions:

tpms.pair_back_left()
tpms.pair_back_right()
tpms.pair_front_left()
tpms.pair_front_right()
tpms.pair_spare()

Stop Pairing Stop pairing process:

tpms.stop_pairing()

Initiate Tire Exchange Initiate a tire exchange between two tires:

tpms.initiate_tire_exchange(tire1, tire2)

License This project is licensed under the MIT License - see the LICENSE file for details.

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

tpms-0.1.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

tpms-0.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file tpms-0.1.0.tar.gz.

File metadata

  • Download URL: tpms-0.1.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.6

File hashes

Hashes for tpms-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1e71b4b6feff9cb6bb6bdc7b95dcc9d00c4ae77deaf7c4df25eb2320b78eb97b
MD5 a690dba32c0f5c0ef4cdc814140522bb
BLAKE2b-256 d2b037f32375a2c875bd0a30bc93302cb2d737acdf6e6edf15f5a5c653842158

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tpms-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.6

File hashes

Hashes for tpms-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c10cc9019018d8cb893c3f8bb0b7797c2dff96f4486e0472467fdc302c259967
MD5 37e0513023480bc58ec930cf43d6a56f
BLAKE2b-256 5e1e840e1f6a18a50f75d3c4a532096fe56aca1110d9cb5f3a45903ca2232fd3

See more details on using hashes here.

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