Jump to content

Pylontech-Battery-Monitoring-for-InfluxDB 0.4

3 Screenshots

About This File

Disclaimer:  Use at your own risk - the console port of a Pylontech battery is not something you should touch if you don't know what you're doing and are not happy to bear the risks.  This code is offered for educational purposes only, so you can see what worked for me.  If you brick your battery or burn your house down, it's on you.


This is based on Ireneusz Zielinski's beautiful code, with some (frankly barbaric) additions to feed the data gained from Pylontech battery 'console' port into influxdb for display in grafana, using a wemos D1 mini (or other ESP8266 module) and a MAX3232 line driver (see code link above for details, including cable spec).

It's set up for 7 batteries, so for any other number, you'll need to add/remove variables, conditional 'if (xi ==...)s' and influx write points as required (because I'm too lazy to learn how to use arrays).  The variable 'influxInterval' sets the data sample rate (how often it queries the battery - every 15secs seems about right).  It only logs variables that have changed since the last reading.

8 metrics per battery: Batt Volts, Batt Current, SOC, Temp, Highest cell temp, Lowest cell temp, Highest cell voltage & Lowest cell voltage.

It should be possible to log the individual cell voltages/temps, but I haven't here, as the above values from each battery are sufficient for my needs.

Chunks of the original MQTT code are commented out (for no good reason that I can remember), so if you want to enable MQTT, you're probably better off with the original code.

Build/upload with 'platformio', all libraries should be included in the .zip.  Enter your influx/wifi credentials and don't forget to edit the 'platformio.ini' if you want to do over-the-air (OTA) updates after your initial USB flash.

There's provision for an LED (across pins D1 & D2) that flashes slowly when it's getting data and happy, but really slowly when it's not.

You can still access the console as with Zielinski's original code, through a browser via the IP address of the device - handy if you need individual cell data.

Suggestions for improvements most welcome.


  • Create New...