GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - joba-1/LiFePO_Island: Monitor for JbdBms Battery Management System and eSmart3 MPPT solar charger via ESP32 WLAN

BranchesTags
Open more actions menu

Latest commit

 

History

61 Commits
61 Commits

Folders and files

NameName
Last commit message
Last commit date
docs
docs
 
 
domoticz
domoticz
 
 
include
include
 
 
src
src
 
 
test
test
 
 
tools
tools
 
 
web
web
 
 
.gitignore
.gitignore
 
 
Readme.md
Readme.md
 
 
embed_web.py
embed_web.py
 
 
git_version.py
git_version.py
 
 
pio_secrets.py
pio_secrets.py
 
 
platformio.ini
platformio.ini
 
 
secrets.ini.template
secrets.ini.template
 
 
upload_script.py
upload_script.py
 
 

Repository files navigation

Monitor for JbdBms Battery Management System and eSmart3/4 MPPT solar charger

ESP32 Arduino firmware to monitor Jbd Battery Management Systems and eSmart3 or eSmart4 chargers. Sends status to an Influx db with the Joba_JbdBms and Joba_ESmart3 libraries. Status is also sent to an mqtt broker. Switching eSmart3/4 load and JbdBms mosfets on and off via web page is also possible. For now, hardcoded battery parameters for LiFePO are always set at startup by setup_LiFePO().

lifepo-island-test-rig-IMG-2929

Running the monitor on an ESP8266 might work but is not tested.

Installation

There are many options to compile and install an ESP32 Arduino firmware. I use this one on linux:

  • Install MS Code
  • Install PlatformIO as MS Code extension
  • Add this folder to the MS Code workspace
  • Edit platformio.ini in this folder so the usb device name for monitor and upload matches your environment
  • Select build and upload the firmware

Connection

See library readmes for wiring details.

Required hardware:

  • A MAX485 board (or similar) to convert RS485 signals to serial.
  • A level shifter from 5V to 3.3V (at least 3 channels) if the MAX485 board does not already have one
  • An ESP32 (with USB connection or an additional serial-to-USB adapter for flashing)
  • Cable with one RJ45 plug and just wires on the other end. 1-8: A-, B+, nc, nc, Gnd, Gnd, 5V, 5V
  • eSmart3 or eSmart4 MPPT charge controller
  • JBD BMS like SP04S010A
  • LiFePO battery, PV (or >16V power supply for testing)
 RJ45 plug
for eSmart3
     __
  __/__\__
  |front |
  ||||||||
  1 ...  8
  ABxx--++

InfluxDB

Relevant connection data (Influx host, database, ...) is configured in platformio.ini Create necessary database like this on the influx server: influx --execute 'create database LiFePO_Island'

  • checks eSmart3 Information every 10 minutes
  • checks eSmart3 ChgSts every half second
  • checks eSmart3 BatParam, LoadParam, ProParam every minute
  • checks eSmart Log(wStartCnt, wFaultCnt, dwTotalEng, dwLoadTotalEng, wBacklightTime, bSwitchEnable) every minute
  • checks JbdBms Hardware every 10 minutes
  • checks JbdBms Cells every 10 seconds
  • checks JbdBms Status every 10 seconds
  • updates database at startup and on changes
job4:~ > influx -precision rfc3339 --database LiFePO_Island --execute 'show measurements'
name: measurements
name
----
BatParam
Cells
ChgSts
Hardware
Information
LoadParam
Log
Parameters
ProParam
Status

job4:~ > influx -precision rfc3339 --database LiFePO_Island --execute 'select * from Cells limit 5'
name: Cells
time                 Host            Id                      Version voltage1 voltage2 voltage3 voltage4
----                 ----            --                      ------- -------- -------- -------- --------
2022-11-01T09:49:39Z lifepo_island-1 JBD-SP04S010A-L4S-35A-B 1.0     3360     3356     3356     3355
2022-11-01T09:49:45Z lifepo_island-1 JBD-SP04S010A-L4S-35A-B 1.0     3360     3357     3356     3356
2022-11-01T09:49:52Z lifepo_island-1 JBD-SP04S010A-L4S-35A-B 1.0     3360     3356     3356     3356
2022-11-01T09:49:58Z lifepo_island-1 JBD-SP04S010A-L4S-35A-B 1.0     3361     3357     3356     3356
2022-11-01T09:50:05Z lifepo_island-1 JBD-SP04S010A-L4S-35A-B 1.0     3361     3356     3356     3356

Networking

since WiFi is needed for Influx anyways, it is used for other stuff as well:

  • Webserver
    • display links for JSON of all eSmart3 item categories and JbdBms commands
    • enables OTA firmware update
    • later: display and change some values of BatParam, LoadParam, ProParam and Log
  • Syslog and mqtt publish of status on changes
    • mqtt topic LiFePO_Island/{instance}/json/# for publishing eSmart3/4 or JBD infos in json format
    • mqtt topic LiFePO_Island/{instance}/status/# for publishing esmart3/4 or jbd fault status
    • mqtt topic LiFePO_Island/{instance}/cmd for receiving commands:
      • "load on": switch eSmart3/4 load on
      • "load off": switch eSmart3/4 load off
  • NTP to set eSmart3/4 time at startup once
  • RSSI and BSSID monitoring to find a place with good WLAN signal reception for the ESP32

Web interface

LiFePO_Island

Grafana Panels using LiFePO_Island data

grafik

Live web page, batching, test bench (since 4.2)

  • The start page shows the key values live (SoC, V/A/W, PV, load, cells, temperatures, faults, link state) and their age; data comes from GET /api/live. Load and MOSFETs are switched with POST /api/load and POST /api/mosfets; the old form endpoints still work.
  • InfluxDB writes are batched (one POST every 5 s, retried with backoff, ms timestamps) instead of one POST per change.
  • pio test -e native runs the unit tests; envs mhetesp32minikit_bench and xiao_esp32c6_bench build a silent simulator firmware for the test bench (own instance, database and Wi-Fi), and test/system/check_device.py tests a running device.
  • The protection limits stored in the BMS (cell/pack under and over voltage, current and temperature limits, balancer) can be read on request from the page (Read from BMS, admin login) or POST /api/bmsparam; they are published as BmsParam (see docs/spec-webui.md).
  • JSON now carries "Version" as a string.
  • Home Assistant MQTT discovery: device LiFePO_Island <instance> with 26 entities; migration of the former hand-written YAML entities with tools/ha_migrate.py (docs/admin.md).

Documentation: docs/spec.md (architecture and decisions), docs/spec-webui.md, docs/spec-telemetry.md, docs/spec-homeassistant.md, docs/user.md, docs/admin.md, docs/test.md.

Comments welcome

Joachim Banzhaf

Server hosts at runtime and admin login (since 4.1)

The [syslog], [mqtt], [influx] and [ntp] servers in platformio.ini are only defaults, now the service aliases syslog, mqtt and influx. A change needs no rebuild: it is validated, stored in NVS (ESP32; separate from the EEPROM sector with the static IP config) and active after the reboot that follows 1 s later (reboot=0 suppresses it). ESP8266 builds keep the defaults.

curl -u admin:<pw> -X POST http://lifepo_island-1/api/netconfig -d mqttHost=mqtt -d influxHost=influx
curl -u admin:<pw> -X POST http://lifepo_island-1/api/netconfig -d defaults=1
curl http://lifepo_island-1/api/netconfig     # active values, source, defaults
curl http://lifepo_island-1/api/netstatus     # firmware, WiFi, syslog/MQTT/InfluxDB/NTP with last result

Fields: syslogHost, syslogPort, mqttHost, mqttPort, influxHost, influxPort, ntp. Host names only (letters, digits, -, .; empty = off), ports 1..65535; a bad value gives 400 {"error":"invalid value","field":...} and nothing is stored.

/update, /reset, /ip and POST /api/netconfig need the user admin and the password from secrets.ini (untracked, mode 600; see secrets.ini.template). pio_secrets.py compiles it in, and upload_script.py uses it for OTA. Load and mosfet switching stay open. Without secrets.ini there is no lock ("adminLock": false).

Note: the ESP8266 env d1_mini_ota does not build (it already did not before 4.1): ip_config() uses the ESP32-only EEPROM API (writeBytes, readULong, bool begin).

About

Monitor for JbdBms Battery Management System and eSmart3 MPPT solar charger via ESP32 WLAN

Resources

Readme
Activity

Stars

3 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.