Skip to main content

Interfaces with Pylontech Batteries using RS485 protocol

Project description

python-pylontech

Python lib to talk to pylontech lithium batteries (US2000, US3000, ...) using RS485

What is this lib ?

This lib is meant to talk to Pylontech batteries using RS485. Sadly the protocol over RS485 is not some fancy thing like MODBUS but their own crappy protocol.

How to use this lib ?

First of all, you need a USB to RS485 converter. They are many available online for some bucks.

Then, you simply need to import the lib and start asking values:

>>> import pylontech
>>> p = pylontech.Pylontech()
>>> print(p.get_values())
Container:
    NumberOfModules = 3
    Module = ListContainer:
        Container:
            NumberOfCells = 15
            CellVoltages = ListContainer:
                3.306
                3.307
                3.305
                3.305
                3.306
                3.305
                3.304
                3.305
                3.306
                3.306
                3.307
                3.307
                3.308
                3.307
                3.306
            NumberOfTemperatures = 5
            AverageBMSTemperature = 29.81
            GroupedCellsTemperatures = ListContainer:
                29.61
                29.61
                29.61
                29.61
            Current = -3.5
            Voltage = 49.59
            Power = -173.565
            RemainingCapacity = 39.5
            TotalCapacity = 50.0
            CycleNumber = 5
    -->8-- SNIP -->8--
    TotalPower = -525.8022
    StateOfCharge = 0.79

>>> print(p.get_system_parameters())
Container: 
    CellHighVoltageLimit = 3.7
    CellLowVoltageLimit = 3.05
    CellUnderVoltageLimit = 2.9
    ChargeHighTemperatureLimit = 33.41
    ChargeLowTemperatureLimit = 26.21
    ChargeCurrentLimit = 10.2
    ModuleHighVoltageLimit = 54.0
    ModuleLowVoltageLimit = 46.0
    ModuleUnderVoltageLimit = 44.5
    DischargeHighTemperatureLimit = 33.41
    DischargeLowTemperatureLimit = 26.21
    DischargeCurrentLimit = -10.0

Dependencies

python-pylontech needs python 3.5 or greater (but please, use at least 3.7 or more if possible to be future-proof).

This lib depends on pyserial and the awesome construct lib.

Hardware wiring

The pylontech modules talk using the RS485 line protocol.

Pylontech side

The first DIP switch on the pylontech indicates the line speed. It must be off (0, down position) so that the speed is set to 115200 Bd.

The RS485 port is exposed on the pins 7 & 8 on the RJ45 connector names RS485.

Client side

Any RS485 to USB (TCP/IP not yet supported) converter should would. You just have to wire the two pins above to the A and B ports (swap them around if it doesn't work). of your converter.

I personally use cheap chinese "RS485 to USB" converters worth a couple of bucks each.

Known bugs

Mixing between US2000 and US3000

If you are using US2000 and US3000 batteries, then the main battery must be a US2000. Please see bug https://github.com/Frankkkkk/python-pylontech/issues/2#issuecomment-915966564 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

python-pylontech-0.0.7.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

python_pylontech-0.0.7-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file python-pylontech-0.0.7.tar.gz.

File metadata

  • Download URL: python-pylontech-0.0.7.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

File hashes

Hashes for python-pylontech-0.0.7.tar.gz
Algorithm Hash digest
SHA256 546a7d05fd1aa47e0bb01412a81421a27c441df7a9ec46af0ce784e0f376b05d
MD5 e1a7f6b819e7fbc01b295897f6855fca
BLAKE2b-256 cfb32d9431e89eef7f6cef7ba7128e8266d55cd4b89f41e9e371f25ce7b73250

See more details on using hashes here.

File details

Details for the file python_pylontech-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: python_pylontech-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

File hashes

Hashes for python_pylontech-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 1d66affcd3593c2c40de386e965919956134519940ad95d92db5dbffe22a2d6f
MD5 9c63cc130df64519a248e5bad4de881c
BLAKE2b-256 6b581e8d3e492f57c5802d9063e88a8e42a8a6fcdc8d2358298236254dbf86ab

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