syssi / esphome-seplos-bms

ESPHome component to monitor a Seplos Battery Management System (Seplos-BMS) via UART or RS485
Apache License 2.0
63 stars 29 forks source link

Temperature readings are wrong #26

Closed NosIreland closed 2 years ago

NosIreland commented 2 years ago

The temperature for 6 sensors are note decoded correctly and is alwasy showing 30 degrees. If I take output from UARTdebug 2000460010960001100CFF0CFE0D030D0C0CFD0D000D0A0D010CFD0D090D000CFD0CFD0D0A0CFD0D02060BCB0BC40BBF0BC00BEB0BDAFF8214CF31C50A426802ED4650006603E814D3000 The temperature sensor data is 060BCB0BC40BBF0BC00BEB0BDA Decoding it gives me:

06 = 6 Sensors
0BCB 
(3019-2731)/10 = 28.8
0BC4 
(3012-2731)/10 = 28.1
0BBF 
(3007-2731)/10 = 27.6
0BC0 
(3008-2731)/10 = 27.7
0BEB 
(3051-2731)/10 = 32
0BDA
(3034-2731)/10 = 30.3

The values that I get are correct and this is what BMS is showing me. This means the decoding is not correct in the code. Looking at the code it seems that you are missing substracting the initial value by 2731

  //   41     0x06           Number of temperatures           6                             V
  uint8_t temperature_sensors = data[offset];
  ESP_LOGV(TAG, "Number of temperature sensors: %d", temperature_sensors);

  //   42     0x0B 0xA6      Temperature sensor 1             2982 * 0.01f = 29.82          °C
  //   44     0x0B 0xA0      Temperature sensor 2             2976 * 0.01f = 29.76          °C
  //   46     0x0B 0x97      Temperature sensor 3             2967 * 0.01f = 29.67          °C
  //   48     0x0B 0xA6      Temperature sensor 4             2982 * 0.01f = 29.82          °C
  //   50     0x0B 0xA5      Environment temperature          2981 * 0.01f = 29.81          °C
  //   52     0x0B 0xA2      Mosfet temperature               2978 * 0.01f = 29.78          °C
  for (uint8_t i = 0; i < std::min((uint8_t) 6, temperature_sensors); i++) {
    this->publish_state_(this->temperatures_[i].temperature_sensor_,
                         (float) seplos_get_16bit(offset + 1 + (i * 2)) * 0.01f);
  }
  offset = offset + 1 + (temperature_sensors * 2);
syssi commented 2 years ago

Did you find out the 2731 be try and error? Can we be sure the 2731 applies to most of the Seplos BMS models?

NosIreland commented 2 years ago

Did you find out the 2731 be try and error? Can we be sure the 2731 applies to most of the Seplos BMS models?

It is in Seplos manual https://raw.githubusercontent.com/syssi/esphome-seplos-bms/main/docs/SEPLOS%20BMS%20Communication%20Protocol_V2.0.pdf page 9 image

syssi commented 2 years ago

Perfect! I will prepare a fix!

syssi commented 2 years ago

I've prepared a new feature branch. Could you give it a try?

substitutions:
  name: seplos-bms
  external_components_source: github://syssi/esphome-seplos-bms@fix-temperature-sensors
NosIreland commented 2 years ago

It does work but I will need to leave it for 24 hours to see how it works and if it produces expected pattern.

syssi commented 2 years ago

If it doesn't crash your setup (because of a under-temperature protection -> shutdown on high load): I would be happy if you could cool down a tempature probe to minus degrees to get an idea minus values are implemented correctly.

syssi commented 2 years ago

Thanks for your support and feedback to improve this custom component. Please create additional issues if you miss something or the component doesn't work as expected.