FoxESS CAN bus battery monitor - MQTT Home Assistant device
Gauging interest post...

I've noticed that people here are still wanting to monitor BMS signals (temps, voltages, status), dynamically control their charge rates, cap SoC (min and max), and automate this via Home Assistant using MQTT. Just putting some feelers out for a concept which I've floated before. Some here will remember my other work developing FoxESS v2 compatible BMS controllers, and this work is an offshoot of that, specifically the Home Assistant control.

The main issue for most has been the issue until now is not having a plug and play option which uses standard RJ45 cabling such that fitting only requires the unplugging of the BMS data cable and insertion of the interception device. This device would be mounted in a small enclosure with two RJ45 sockets, and use standard ethernet patch cables to connect to the battery.

Monitoring and control of the BMS is performed using a Man-in-the-Middle CAN bus device which intercepts specific BMS CAN bus traffic, and reports all values to Home Assistant using MQTT sub/pub or TCP polling using a local API over Wi-Fi. Safe tuning of charge and discharge rate is performed through value reductions only.

Why do this?
  1. Fine control over the charging and discharging profile of your batteries
  2. Simple automation of summer/winter/off-peak max/min SoC, DoD control
  3. Discharge inhibit when EV charging and during free energy sessions (IOG)
  4. Monitoring individual cell voltages, module temps, charge and discharge rates and limits
  5. Safe updating of FoxESS firmware without breaking your HA BMS integration
  6. No hammering the FoxESS EEPROM every time a setting is changed or HA automation triggers
  7. Optional RS485 providing Modbus RTU over Wi-Fi - depending on level of interest
  8. Can be powered via inverter COM port or USB - FoxESS model dependent
  9. Arduino Wi-Fi Manager and OTA for simple flashing
My own implementation of BMS control provides the following sensors and control in HA

Image

And automation to suit Octopus and EVSE agnostic integration

Image

Example JSON payload

Code: Select all

{"uptime":5483289,"conn_uptime":47060,"soc":57.0,"volts":409.6,"cell_mv_high":3799,"cell_mv_low":3791,"cell_temp_high":26.0,"cell_temp_low":26.0,"dod":[15,80],"amps":0.0,"kwh":27.7,"charge":30.0,"discharge":30.0}
Typical HA MQTT sensors

Code: Select all

    - name: "kWh"
      state_topic: "bms/ESP48CA43/state"
      unique_id: "kwh_sensor"
      value_template: "{{ value_json.kwh | float | round(2) | default(0.00) }}"
      unit_of_measurement: "kWh"
      json_attributes_topic: "BMS"
      json_attributes_template: >
        {"kwh": "{{ value_json.kwh }}"}

    - name: "Min DoD"
      state_topic: "bms/ESP48CA43/state"
      unique_id: "min_dod_sensor"
      value_template: "{{ value_json.dod | min }}"
      unit_of_measurement: "%"
      json_attributes_topic: "BMS"
      json_attributes_template: >
        {"min_dod": "{{ value_json.dod }}"}

    - name: "Max DoD"
      state_topic: "bms/ESP48CA43/state"
      unique_id: "max_dod_sensor"
      value_template: "{{ value_json.dod | max }}"
      unit_of_measurement: "%"
      json_attributes_topic: "BMS"
      json_attributes_template: >
        {"max_dod": "{{ value_json.dod }}"}

Happy to open-source the Arduino firmware so that the community can get involved. My design is mostly stateless which leaves all complexity and flexibility in Home Assistant. Hardware is a dual CAN bus ESP32-C6.

Interested Dave?
Re: FoxESS CAN bus battery monitor - MQTT Home Assistant device
Hi, as you can imagine I do much of this already, but I really like the simplicity of intercepting the CAN bus to the batteries (and not hitting the inverter registers as often).
It's a shame there isn't similar traffic available for the other inverter sensors, that really would be a score so it's back to RS485 for those, although you can cloud connect via OpenApi for that data so it's only a resolution issue.

I don't have so much spare time available right now but always happy to get involved as you never know where it will end up :)

There's a lot more traffic and potentially interest on the Facebook group, but you may get a bit swamped over there ;)
Post Reply