OUR WORK · CASE STUDY
DIY Battery BMS: ESP32 firmware for solar inverters
DIY Battery BMS is firmware we wrote for ESP32 boards. It lets a self-built LiFePO4 battery bank work with an off-the-shelf solar inverter, and it is free for personal, non-commercial use, with the source on GitHub.
The problem
Many hybrid inverters expect the battery to report its state and charge limits over CAN, using the Pylontech protocol. A DIY bank monitored by a Victron SmartShunt has the data but no way to send it in that form.
What the firmware does
- Reads the SmartShunt over VE.Direct serial or Bluetooth, or takes readings from MQTT, with an optional fallback source.
- Sends battery data and the charge voltage and current the owner sets to the inverter over CAN, using the Pylontech protocol.
- Controls charging: voltage-limited charging, temperature protection, fan control and force charge for off-peak rates.
- Publishes to MQTT with Home Assistant discovery, and accepts commands such as enabling or disabling charge.
- Includes a web UI for setup, a CAN sniffer for diagnosis and syslog forwarding.
Hardware and build
It runs on ESP32 and ESP32-S3 boards, either with an MCP2515 CAN adapter or with the chip’s built-in CAN controller, including boards such as the LilyGo T-CAN485 and the Seeed XIAO ESP32-S3. The firmware is C++, built with PlatformIO on the Arduino core for ESP-IDF.
Getting it onto a board
Owners flash it from a web flasher in the browser, which reads the chip’s flash size and turns off options that would not work on it. After that they join it to Wi-Fi, set it up in its web UI and install updates over the air.
In use
It is tested with Solis inverters, and members of the DIY Solar Forum community report others working. It also connects to PowerPilot, our home energy manager, over WebSockets.
Where this applies to your project
If you need firmware for an ESP32 board that reads one device and talks to another over CAN, serial, Bluetooth or MQTT, this is the kind of work we do. See our edge and hardware integration service.