syssi / esphome-jk-bms

ESPHome component to monitor and control a Jikong Battery Management System (JK-BMS) via UART-TTL or BLE
Apache License 2.0
451 stars 151 forks source link

currently flashing an esp8266 module no longer works. #557

Closed duymelody9x closed 1 month ago

duymelody9x commented 1 month ago

1 month ago i flashed an esp8266 and it worked perfectly, but now flashing a new device it doesn't work anymore. Do you have any updates during this time? image

syssi commented 1 month ago

The implementation haven't changed. Please provide some logs. Do you use another ESP? Did you change the BMS? Please try to identify the changed parts of your setup.

duymelody9x commented 1 month ago

i sold the old battery pack i bought a new battery pack and a new 8266 module. But they are the same as the last time i used them. i bought another new 8266 module but it still doesn't work. i'm using batmon addons now i bought an esp32 that connects via bluetooth will they work stably?

syssi commented 1 month ago

To resolve the issue it's important to provide more details.

  1. Do you have a new BMS too?
  2. Are you sure the new BMS has a working GPS port?
  3. Is RS485 enabled and the correct protocol selected?
  4. Does Batman use a wired connection or BLE?
  5. Which GPIOs did you use for RXD and TXD? Please provide your YAML configuration
  6. Enable the debug output of the uart component and provide some logs
duymelody9x commented 1 month ago

20240805_131128 Screenshot_20240805-131259_BMS Screenshot_20240805-131321_BMS here is the code:

    substitutions:
        name: jk-bms
        device_description: "Monitor a JK-BMS via UART-TTL"
        external_components_source: github://syssi/esphome-jk-bms@main
        tx_pin: GPIO1
        rx_pin: GPIO3

      esphome:
        name: ${name}
        comment: ${device_description}
        min_version: 2024.6.0
        project:
          name: "syssi.esphome-jk-bms"
          version: 2.0.0

      esp8266:
        board: d1_mini

      external_components:
        - source: ${external_components_source}
          refresh: 0s

      logger:
        baud_rate: 0
        level: DEBUG

      # If you use Home Assistant please remove this `mqtt` section and uncomment the `api` component!
      # The native API has many advantages over MQTT: https://esphome.io/components/api.html#advantages-over-mqtt
      # Enable Home Assistant API
      api:
        encryption:
          key: "Nba2bhiXhstwszVFI164aVebEfEdS1MwSyU+nOnWXp4="

      ota:
        - platform: esphome
          password: "ab022b77f6f95c31ea47578e5bd96156"

      wifi:
        ssid: solar
        password: 04071997

        # Enable fallback hotspot (captive portal) in case wifi connection fails
        ap:
          ssid: "Jk-Bms Fallback Hotspot"
          password: "gPnuSXL3W1Oa"

      uart:
        - id: uart_0
          baud_rate: 115200
          rx_buffer_size: 384
          tx_pin: ${tx_pin}
          rx_pin: ${rx_pin}
          debug:
            direction: BOTH

      jk_modbus:
        - id: modbus0
          uart_id: uart_0
          rx_timeout: 50ms

      jk_bms:
        - id: bms0
          jk_modbus_id: modbus0
          update_interval: 5s

      binary_sensor:
        - platform: jk_bms
          balancing:
            name: "${name} balancing"
          balancing_switch:
            name: "${name} balancing switch"
          charging:
            name: "${name} charging"
          discharging:
            name: "${name} discharging"
          dedicated_charger_switch:
            name: "${name} dedicated charger switch"
          online_status:
            name: "${name} online status"

      sensor:
        - platform: jk_bms
          min_cell_voltage:
            name: "${name} min cell voltage"
          max_cell_voltage:
            name: "${name} max cell voltage"
          min_voltage_cell:
            name: "${name} min voltage cell"
          max_voltage_cell:
            name: "${name} max voltage cell"
          delta_cell_voltage:
            name: "${name} delta cell voltage"
          average_cell_voltage:
            name: "${name} average cell voltage"
          cell_voltage_1:
            name: "${name} cell voltage 1"
          cell_voltage_2:
            name: "${name} cell voltage 2"
          cell_voltage_3:
            name: "${name} cell voltage 3"
          cell_voltage_4:
            name: "${name} cell voltage 4"
          cell_voltage_5:
            name: "${name} cell voltage 5"
          cell_voltage_6:
            name: "${name} cell voltage 6"
          cell_voltage_7:
            name: "${name} cell voltage 7"
          cell_voltage_8:
            name: "${name} cell voltage 8"
          cell_voltage_9:
            name: "${name} cell voltage 9"
          cell_voltage_10:
            name: "${name} cell voltage 10"
          cell_voltage_11:
            name: "${name} cell voltage 11"
          cell_voltage_12:
            name: "${name} cell voltage 12"
          cell_voltage_13:
            name: "${name} cell voltage 13"
          cell_voltage_14:
            name: "${name} cell voltage 14"
          cell_voltage_15:
            name: "${name} cell voltage 15"
          cell_voltage_16:
            name: "${name} cell voltage 16"
          cell_voltage_17:
            name: "${name} cell voltage 17"
          cell_voltage_18:
            name: "${name} cell voltage 18"
          cell_voltage_19:
            name: "${name} cell voltage 19"
          cell_voltage_20:
            name: "${name} cell voltage 20"
          cell_voltage_21:
            name: "${name} cell voltage 21"
          cell_voltage_22:
            name: "${name} cell voltage 22"
          cell_voltage_23:
            name: "${name} cell voltage 23"
          cell_voltage_24:
            name: "${name} cell voltage 24"
          power_tube_temperature:
            name: "${name} power tube temperature"
          temperature_sensor_1:
            name: "${name} temperature sensor 1"
          temperature_sensor_2:
            name: "${name} temperature sensor 2"
          total_voltage:
            name: "${name} total voltage"
          current:
            name: "${name} current"
          power:
            name: "${name} power"
          charging_power:
            name: "${name} charging power"
          discharging_power:
            name: "${name} discharging power"
          capacity_remaining:
            name: "${name} capacity remaining"
          capacity_remaining_derived:
            name: "${name} capacity remaining derived"
          temperature_sensors:
            name: "${name} temperature sensors"
          charging_cycles:
            name: "${name} charging cycles"
          total_charging_cycle_capacity:
            name: "${name} total charging cycle capacity"
          battery_strings:
            name: "${name} battery strings"
          errors_bitmask:
            name: "${name} errors bitmask"
          operation_mode_bitmask:
            name: "${name} operation mode bitmask"
          total_voltage_overvoltage_protection:
            name: "${name} total voltage overvoltage protection"
          total_voltage_undervoltage_protection:
            name: "${name} total voltage undervoltage protection"
          cell_voltage_overvoltage_protection:
            name: "${name} cell voltage overvoltage protection"
          cell_voltage_overvoltage_recovery:
            name: "${name} cell voltage overvoltage recovery"
          cell_voltage_overvoltage_delay:
            name: "${name} cell voltage overvoltage delay"
          cell_voltage_undervoltage_protection:
            name: "${name} cell voltage undervoltage protection"
          cell_voltage_undervoltage_recovery:
            name: "${name} cell voltage undervoltage recovery"
          cell_voltage_undervoltage_delay:
            name: "${name} cell voltage undervoltage delay"
          cell_pressure_difference_protection:
            name: "${name} cell pressure difference protection"
          discharging_overcurrent_protection:
            name: "${name} discharging overcurrent protection"
          discharging_overcurrent_delay:
            name: "${name} discharging overcurrent delay"
          charging_overcurrent_protection:
            name: "${name} charging overcurrent protection"
          charging_overcurrent_delay:
            name: "${name} charging overcurrent delay"
          balance_starting_voltage:
            name: "${name} balance starting voltage"
          balance_opening_pressure_difference:
            name: "${name} balance opening pressure difference"
          power_tube_temperature_protection:
            name: "${name} power tube temperature protection"
          power_tube_temperature_recovery:
            name: "${name} power tube temperature recovery"
          temperature_sensor_temperature_protection:
            name: "${name} temperature sensor temperature protection"
          temperature_sensor_temperature_recovery:
            name: "${name} temperature sensor temperature recovery"
          temperature_sensor_temperature_difference_protection:
            name: "${name} temperature sensor temperature difference protection"
          charging_high_temperature_protection:
            name: "${name} charging high temperature protection"
          discharging_high_temperature_protection:
            name: "${name} discharging high temperature protection"
          charging_low_temperature_protection:
            name: "${name} charging low temperature protection"
          charging_low_temperature_recovery:
            name: "${name} charging low temperature recovery"
          discharging_low_temperature_protection:
            name: "${name} discharging low temperature protection"
          discharging_low_temperature_recovery:
            name: "${name} discharging low temperature recovery"
          total_battery_capacity_setting:
            name: "${name} total battery capacity setting"
          current_calibration:
            name: "${name} current calibration"
          device_address:
            name: "${name} device address"
          sleep_wait_time:
            name: "${name} sleep wait time"
          alarm_low_volume:
            name: "${name} alarm low volume"
          manufacturing_date:
            name: "${name} manufacturing date"
          total_runtime:
            name: "${name} total runtime"
      #    start_current_calibration:
      #      name: "${name} start current calibration"
          actual_battery_capacity:
            name: "${name} actual battery capacity"
      #    protocol_version:
      #      name: "${name} protocol version"

      switch:
        - platform: jk_bms
          charging:
            name: "${name} charging"
          discharging:
            name: "${name} discharging"

      text_sensor:
        - platform: jk_bms
          errors:
            name: "${name} errors"
          operation_mode:
            name: "${name} operation mode"
          battery_type:
            name: "${name} battery type"
          password:
            name: "${name} password"
          device_type:
            name: "${name} device type"
          software_version:
            name: "${name} software version"
          manufacturer:
            name: "${name} manufacturer"
          total_runtime_formatted:
            name: "${name} total runtime formatted"

i am using batmon via BLE connect. it still works but i have to bring the homeassistant server close to the battery block

syssi commented 1 month ago

Some ideas:

  1. There are D1 mini boards out there where GPIO1/GPIO3 cannot talk to the BMS because the UART-to-TTL chip attached to the same pins makes strange things. Please try GPIO4, GPIO5 instead.
  2. May be the underlying Arduino implementation has changed. I'm using ESP32 boards only without trouble. Please try an ESP32 just for testing.
  3. If the GPS port remains silent you have to use BLE unfortunately.
duymelody9x commented 1 month ago

Which ESP32 boards do you usually use?

syssi commented 1 month ago

They are called ESP32 D1 Mini and are looking very similar to the Wemos D1 Mini board. Be careful to not pick a ESP8266 based board. ;-)

duymelody9x commented 1 month ago

i bought esp32 d1 mini. it worked perfectly without BLE connection. seems like esp8266 it is not stable. anyway thank you very much!