{"id":19476512,"url":"https://github.com/frankkkkk/python-pylontech","last_synced_at":"2025-09-08T05:33:26.686Z","repository":{"id":41481401,"uuid":"398906141","full_name":"Frankkkkk/python-pylontech","owner":"Frankkkkk","description":"Python lib to talk to pylontech lithium batteries 🔋 (US2000, US3000, ...) using RS485","archived":false,"fork":false,"pushed_at":"2023-08-14T19:31:15.000Z","size":810,"stargazers_count":70,"open_issues_count":22,"forks_count":33,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-01-02T23:49:10.183Z","etag":null,"topics":["battery","lithium","pylon","pylontech","python","rs485","us2000","us2000c","us3000"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Frankkkkk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-08-22T21:36:47.000Z","updated_at":"2024-12-23T09:46:22.000Z","dependencies_parsed_at":"2022-08-29T23:51:21.200Z","dependency_job_id":"e89d90e5-ab27-4f05-90a6-c98074932822","html_url":"https://github.com/Frankkkkk/python-pylontech","commit_stats":{"total_commits":45,"total_committers":8,"mean_commits":5.625,"dds":0.4666666666666667,"last_synced_commit":"5d91f6d7fe3a42853eacbf9d79fd03a70055ccc4"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Frankkkkk%2Fpython-pylontech","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Frankkkkk%2Fpython-pylontech/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Frankkkkk%2Fpython-pylontech/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Frankkkkk%2Fpython-pylontech/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Frankkkkk","download_url":"https://codeload.github.com/Frankkkkk/python-pylontech/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232282918,"owners_count":18499331,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["battery","lithium","pylon","pylontech","python","rs485","us2000","us2000c","us3000"],"created_at":"2024-11-10T19:40:33.476Z","updated_at":"2025-01-03T03:09:37.566Z","avatar_url":"https://github.com/Frankkkkk.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# python-pylontech\nPython lib to talk to pylontech lithium batteries (US2000, US3000, ...) using RS485\n\n## What is this lib ?\nThis 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.\n\n## How to use this lib ?\nFirst of all, you need a USB to RS485 converter. They are many available online for some bucks.\n\nThen, you simply need to import the lib and start asking values:\n```python\n\n\u003e\u003e\u003e import pylontech\n\u003e\u003e\u003e p = pylontech.Pylontech()\n\u003e\u003e\u003e print(p.get_values())\nContainer:\n    NumberOfModules = 3\n    Module = ListContainer:\n        Container:\n            NumberOfCells = 15\n            CellVoltages = ListContainer:\n                3.306\n                3.307\n                3.305\n                3.305\n                3.306\n                3.305\n                3.304\n                3.305\n                3.306\n                3.306\n                3.307\n                3.307\n                3.308\n                3.307\n                3.306\n            NumberOfTemperatures = 5\n            AverageBMSTemperature = 29.81\n            GroupedCellsTemperatures = ListContainer:\n                29.61\n                29.61\n                29.61\n                29.61\n            Current = -3.5\n            Voltage = 49.59\n            Power = -173.565\n            RemainingCapacity = 39.5\n            TotalCapacity = 50.0\n            CycleNumber = 5\n    --\u003e8-- SNIP --\u003e8--\n    TotalPower = -525.8022\n    StateOfCharge = 0.79\n\n\u003e\u003e\u003e print(p.get_system_parameters())\nContainer: \n    CellHighVoltageLimit = 3.7\n    CellLowVoltageLimit = 3.05\n    CellUnderVoltageLimit = 2.9\n    ChargeHighTemperatureLimit = 33.41\n    ChargeLowTemperatureLimit = 26.21\n    ChargeCurrentLimit = 10.2\n    ModuleHighVoltageLimit = 54.0\n    ModuleLowVoltageLimit = 46.0\n    ModuleUnderVoltageLimit = 44.5\n    DischargeHighTemperatureLimit = 33.41\n    DischargeLowTemperatureLimit = 26.21\n    DischargeCurrentLimit = -10.0\n```\n\n## Dependencies\n`python-pylontech` needs python 3.5 or greater (but please, use at least 3.7 or more if possible to be future-proof).\n\nThis lib depends on `pyserial` and the awesome `construct` lib.\n\n# Hardware wiring\nThe pylontech modules talk using the RS485 line protocol.\n## Pylontech side\nThe 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.\n\nThe RS485 port is exposed on the pins 7 \u0026 8 on the RJ45 connector names `RS485`.\n\n## Client side\n\n### USB to RS485\nAny RS485 to USB 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.\n\nI personally use cheap chinese \"RS485 to USB\" converters worth a couple of bucks each.\n\n### TCP/IP\nIf you are using a Ethernet to RS485 bridge, connect as for USB and run the following command (Linux only) for creating a virtual serial port. Then run the python script with adapted serial parameter in the constructor.\n\n`socat pty,link=$HOME/bat2,waitslave tcp:\u003cIP_ADDRESS\u003e:\u003cPORT\u003e`\n\nThis is tested with an USR-N540\n\n# Known bugs\n## Mixing between US2000 and US3000\nIf 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\n\n\n# FAQ\n\n## Using Pylontech LV Hub with multible battery banks\n\nIf the LV hub is used the address of the RS485 devices is depending on the battery bank. To read values the specific device address is needed. To scan for devices on a bank you can use the `scan_for_batteries` function. The max range is 0 to 255.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrankkkkk%2Fpython-pylontech","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrankkkkk%2Fpython-pylontech","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrankkkkk%2Fpython-pylontech/lists"}