forked from syssi/esphome-seplos-bms
-
Notifications
You must be signed in to change notification settings - Fork 1
/
esp32-s3-ruixu-example.yaml
349 lines (300 loc) · 15 KB
/
esp32-s3-ruixu-example.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
substitutions:
name: bms
friendly_name: bms # this will be appended before the entitiy names as per newer ESPhome standard - leave "bms" to work with my dashboards by default
batt_0: "batt 0"
device_description: "Monitor and control a Ruixu BMS via RS485 (Modbus) with M5Stack Atomic ESP32 S3 lite"
tx_pin: GPIO2 # M5stack Atom S3 + Atomic RS485 base = GPIO6 | Isolated RS485 Grove module = GPIO2
rx_pin: GPIO1 # M5stack Atom S3 + Atomic RS485 base = GPIO5 | Isolated RS485 Grove module = GPIO1
external_components_source: github://easybotics/esphome-ruixu-bms@main
esphome:
name: ${name}
comment: ${device_description}
min_version: 2024.6.0
project:
name: "syssi.esphome-ruixu-bms"
version: 1.2.0
external_components:
- source: ${external_components_source}
refresh: 0s
preferences:
flash_write_interval: 24h # prevent the flash from wearing out
esp32:
board: esp32-s3-devkitc-1 # m5stack-atoms3 #hardware is M5stack Atom S3 Lite with Atomic RS485 base - but the closest define with this version of platformio is the esp32-s3-devkitc-1
variant: esp32s3
framework:
type: arduino
# Enable logging
logger:
#level: VERBOSE
baud_rate: 921600 # faster logging
# Enable Home Assistant API
api:
encryption:
key: ""
ota:
- platform: esphome
password: ""
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
#ap:
# ssid: "Battery Fallback Hotspot"
# password: ""
#captive_portal:
uart:
- id: uart_0
baud_rate: 9600
tx_pin: ${tx_pin}
rx_pin: ${rx_pin}
# debug:
# direction: BOTH
# dummy_receiver: false
# after:
# delimiter: "0x16"
# sequence:
# - lambda: |-
# UARTDebug::log_string(direction, bytes);
# UARTDebug::log_hex(direction, bytes, ' ');
seplos_modbus:
id: modbus0
uart_id: uart_0
rx_timeout: 150ms
# RS485 transceiver should only be connected to the master BMS OUT port - the same one going to the inverter - it will not work correctly on any other battery or port!!
# the master battery CAN lines (middle pair) go to the inverter - the last pair (brown) go to the RS485 transceiver
# it will NOT work correclty on the extra port on the last slave battery.
# the Ruixu BMS seems sensitive to when the data is sent - if the logs show only 1 battery data being received try adjusting the interval or just restarting the ESP32
seplos_bms:
- id: bms0
address: 0x00 # master BMS
protocol_version: 0x21 # Known protocol versions: 0x20 (Seplos), 0x26 (Boqiang), 0x21 (Ruixu)
seplos_modbus_id: modbus0
update_interval: 5s # it seems that offsetting these intervals helps with making sure all battery requests dont interfere with eachother if using multiple.
binary_sensor:
- platform: status # exposes the node state in HA
name: "Node Status"
id: system_status
text_sensor:
- platform: wifi_info # exposes the node IP in HA
ip_address:
name: ESP IP Address
id: ip_address
sensor:
# these sensors calcualte kWh (energy) and are very useful - the separate IN / OUT sensors are necessary for the HA default power monitoring and the https://github.com/slipx06/sunsynk-power-flow-card which is highly recommended
- { power_id: batt_0_power_net, platform: total_daily_energy, method: left, accuracy_decimals: 2, unit_of_measurement: 'kWh', id: batt_0_energy_net, name: "${batt_0} daily energy net"}
- { power_id: batt_0_power_in, platform: total_daily_energy, method: left, accuracy_decimals: 2, unit_of_measurement: 'kWh', id: batt_0_energy_in, name: "${batt_0} daily energy in"}
- { power_id: batt_0_power_out, platform: total_daily_energy, method: left, accuracy_decimals: 2, unit_of_measurement: 'kWh', id: batt_0_energy_out, name: "${batt_0} daily energy out"}
- platform: seplos_bms #################################### batt_0 ###################################
seplos_bms_id: bms0
min_cell_voltage:
name: "${batt_0} voltage cell min"
id: batt_0_voltage_cell_min
max_cell_voltage:
name: "${batt_0} voltage cell max"
id: batt_0_voltage_cell_max
min_voltage_cell:
name: "${batt_0} voltage cell min number"
id: batt_0_voltage_cell_min_number
max_voltage_cell:
name: "${batt_0} voltage cell max number"
id: batt_0_voltage_cell_max_number
delta_cell_voltage:
name: "${batt_0} voltage cell delta"
id: batt_0_voltage_cell_delta
average_cell_voltage:
name: "${batt_0} voltage cell average"
id: batt_0_voltage_cell_average
cell_voltage_1:
name: "${batt_0} voltage cell 1"
cell_voltage_2:
name: "${batt_0} voltage cell 2"
cell_voltage_3:
name: "${batt_0} voltage cell 3"
cell_voltage_4:
name: "${batt_0} voltage cell 4"
cell_voltage_5:
name: "${batt_0} voltage cell 5"
cell_voltage_6:
name: "${batt_0} voltage cell 6"
cell_voltage_7:
name: "${batt_0} voltage cell 7"
cell_voltage_8:
name: "${batt_0} voltage cell 8"
cell_voltage_9:
name: "${batt_0} voltage cell 9"
cell_voltage_10:
name: "${batt_0} voltage cell 10"
cell_voltage_11:
name: "${batt_0} voltage cell 11"
cell_voltage_12:
name: "${batt_0} voltage cell 12"
cell_voltage_13:
name: "${batt_0} voltage cell 13"
cell_voltage_14:
name: "${batt_0} voltage cell 14"
cell_voltage_15:
name: "${batt_0} voltage cell 15"
cell_voltage_16:
name: "${batt_0} voltage cell 16"
temperature_1:
name: "${batt_0} temperature 1"
temperature_2:
name: "${batt_0} temperature 2"
temperature_3:
name: "${batt_0} temperature 3"
temperature_4:
name: "${batt_0} temperature 4"
temperature_5:
name: "${batt_0} temperature environment"
temperature_6:
name: "${batt_0} temperature mosfet"
total_voltage:
name: "${batt_0} voltage total"
id: batt_0_voltage_total
current:
name: "${batt_0} current"
id: batt_0_current
power:
name: "${batt_0} power net"
id: batt_0_power_net
filters:
- multiply: 0.001 # Multiplication factor from W to kW is 0.001
unit_of_measurement: 'kW'
accuracy_decimals: 3
charging_power:
name: "${batt_0} power in"
id: batt_0_power_in
filters:
- multiply: 0.001 # Multiplication factor from W to kW is 0.001
unit_of_measurement: 'kW'
accuracy_decimals: 3
discharging_power:
name: "${batt_0} power out"
id: batt_0_power_out
filters:
- multiply: 0.001 # Multiplication factor from W to kW is 0.001
unit_of_measurement: 'kW'
accuracy_decimals: 3
residual_capacity:
name: "${batt_0} remaining capacity"
battery_capacity:
name: "${batt_0} battery capacity"
state_of_charge:
name: "${batt_0} state of charge"
charging_cycles:
name: "${batt_0} charging cycles"
state_of_health:
name: "${batt_0} state of health"
# Ruixu Battery Testing
# First request in Strings: \xEF\x00\xFB\x00\xFF\x05\x16\
# 2 \xEF\x00\x83\x04\x00e\x00\x01\xFF\x13\x16 e = 0x65
# 3 \xEF\x00\x83\x04\x00\xB5\x00\x01\xFE\xC3\x16
# 4 ~21004642E00200FD36\r
# 5 ~21004644E00200FD34\r
# 6 \xEF\x00\xBD\x04\x01\x12\x00 \xFF\f\x16
# 7 \xEF\x00\xBD\x04\x00\xFA\x00\x14\xFE1\x16
# 8 \xEF\x00\xBD\x04\x01\xD4\x00\x14\xFEV\x16
# 9 ~21004651E00200FD36\r
# 10 ~2100464D0000FD9B\r
# hex 1 EF 00 FB 00 FF 05 16
# hex 1 response EF 00 FB 0B 00 43 4E 31 30 2E 30 32 00 00 00 FD 78 16
# hex 2 EF 00 83 04 00 65 00 01 FF 13 16
# hex 2 response EF 00 83 04 00 02 7A A8 FE 55 16
# hex 3 EF 00 83 04 00 B5 00 01 FE C3 16
# hex 3 response EF 00 83 04 00 02 00 FF FE 78 16
# hex 4 7E 32 31 30 30 34 36 34 32 45 30 30 32 30 30 46 44 33 36 0D
# hex 4 response 7e 32 31 30 30 34 36 30 30 38 30 38 30 30 30 31 30 30 43 45 32 30 43 45 31 30 43 44 46 30 43 45 32 30 43 45 30 30 43 45 33 30 43 44 46 30 43 45 31 30 43 44 46 30 43 45 31 30 43 45 31 30 43 45 30 30 43 45 30 30 43 45 31 30 43 45 30 30 43 45 30 30 37 30 42 43 43 30 42 44 31 30 42 43 45 30 42 43 46 30 42 44 42 30 42 43 43 30 42 44 37 30 30 30 30 31 34 39 35 34 38 41 37 30 34 37 41 41 38 30 30 30 31 33 42 36 34 30 30 30 30 45 30 44 33 5c 72
# this is the cell voltage I belive 30 43 45 32 = 3.298v 30 43 44 46 = 3.295v 30 43 45 30 = 3.296v = last voltage
# hex 5 7E 32 31 30 30 34 36 34 34 45 30 30 32 30 30 46 44 33 34 0D
# hex 5 response 7e 32 31 30 30 34 36 30 30 32 30 34 41 30 30 31 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 37 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 38 30 30 30 36 30 30 30 30 30 30 30 30 30 30 30 30 45 46 41 36 5c 72
# hex 6 EF 00 BD 04 01 12 00 20 FF 0A 16
# hex 7 EF 00 BD 04 00 FA 00 14 FE 31 16
# hex 8 EF 00 BD 04 01 D4 00 14 FE 56 16
# hex 9 7E 32 31 30 30 34 36 35 31 45 30 30 32 30 30 46 44 33 36 0D
# hex 10 7E 32 31 30 30 34 36 34 44 30 30 30 30 46 44 39 42 0D
# 7E 32 31 30 30 34 36 30 30 32 30 30 45 30 37 45 38 30 39 30 44 30 37 30 31 30 30 46 41 42 33 0D
# example of the requests and responses from Ruixu tools windows software
# request 1
# >>> "\xEF\x00\xFB\x00\xFF\x05\x16"
# >>> EF 00 FB 00 FF 05 16
# <<< "\xEF\x00\xFB\v\x00CN10.02\x00\x00\x00\xFDx\x16"
# <<< EF 00 FB 0B 00 43 4E 31 30 2E 30 32 00 00 00 FD 78 16
# request 2
# >>> "\xEF\x00\x83\x04\x00e\x00\x01\xFF\x13\x16"
# >>> EF 00 83 04 00 65 00 01 FF 13 16
# <<< "\xEF\x00\x83\x04\x00\x02z\xA8\xFEU\x16"
# <<< EF 00 83 04 00 02 7A A8 FE 55 16
# 02 = maybe binary?? 00000010
# 7A = 01111010
# request 3
# >>> "\xEF\x00\x83\x04\x00\xB5\x00\x01\xFE\xC3\x16"
# >>> EF 00 83 04 00 B5 00 01 FE C3 16
# <<< "\xEF\x00\x83\x04\x00\x02\x00\xFF\xFEx\x16"
# <<< EF 00 83 04 00 02 00 FF FE 78 16
# 02 = maybe binary?? 00000010
# 00 = 0
# request 4 - cell volts 0x42 = get analog value for old pylon protocol
# >>> "~21004642E00200FD36\r"
# >>> 7E 32 31 30 30 34 36 34 32 45 30 30 32 30 30 46 44 33 36 0D
# <<< ~21004600808000 10 0CE00CDF0CDD0CE00CDE0CE10CDD0CDF0CDD0CDF0CDF0CDE0CDE0CDE0CDE0CDE 070BAE0BB20BAF0BB00BC60BB80BC00000149148A7047AA800013B640000E056
# <<< 7E 32 31 30 30 34 36 30 30 38 30 38 30 30 30 31 30 30 43 45 30 30 43 44 46 30 43 44 44 30 43 45 30 30 43 44 45 30 43 45 31 30 43 44 44 30 43 44 46 30 43 44 44 30 43 44 46 30 43 44 46 30 43 44 45 30 43 44 45 30 43 44 45 30 43 44 45 30 43 44 45 30 37 30 42 41 45 30 42 42 32 30 42 41 46 30 42 42 30 30 42 43 36 30 42 42 38 30 42 43 30 30 30 30 30 31 34 39 31 34 38 41 37 30 34 37 41 41 38 30 30 30 31 33 42 36 34 30 30 30 30 45 30 35 36 0D
# ~21004600808000 starting data
# 10 = 16 cell count
# 0CE0 = 3.296v cell 1 voltage
# 0CDF = 3.295v cell 2 voltage
# 0CDD0CE00CDE0CE10CDD0CDF0CDD0CDF0CDF0CDE0CDE0CDE0CDE0CDE - remaining cell voltages
# 07 = 7 -temperature count = number of sensors
# 0BAE = 29.90 -Temp Cell 1
# 0BB2 = 29.94
# 0BAF = 29.91
# 0BB0 = 29.92
# 0BC6 = 30.14
# 0BB8 = 30.00
# 0BC0 = 30.08
# 0000 = 0 -Pack A?? Signed integer charge is positive
# 1491 = 52.65v -Pack V
# 48A7 = 18599mAh -remaining Ah
# 04 = 04 -Manual says "custom quantity"
# 7AA8 = 314.00Ah -full capacity Ah
# 0001 = 1 -cycles
# 3B = 59 -SOC% :)
# 64 = 100 -SOH
# 0000
# E056\r - ending
# request 5 - error flags / code? 0x44 = get alarm data for old pylon protocol
# >>> "~21004644E00200FD34\r"
# >>> 7E 32 31 30 30 34 36 34 34 45 30 30 32 30 30 46 44 33 34 0D
# <<< "~21004600204A00 10 0000000000000000000000000000000007000000000000000000080006000000000000EFA6\r"
# ~21004600204A00 10 0000000000000000000000000000000007000000000000000000
# 08 = Dischard current
# 00
# 06 = Status #2 flag bits DFET and CFET on
# 000000000000EFA6\r
# <<< 7E 32 31 30 30 34 36 30 30 32 30 34 41 30 30 31 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 37 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 38 30 30 30 36 30 30 30 30 30 30 30 30 30 30 30 30 45 46 41 36 0D
# request 6 - error flags / code? 901227970007 = Battery code
# >>> "\xEF\x00\xBD\x04\x01\x12\x00 \xFF\f\x16"
# >>> EF 00 BD 04 01 12 00 20 FF 0C 16
# <<< "\xEF\x00\xBD\"\x00 9012 27970007\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFC\x95\x16"
# <<< EF 00 BD 22 00 20 39 30 31 32 32 37 39 37 30 30 30 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FC 95 16
# request 7 - BMS SN1 serial number 1 = 90116322 2405150023
# >>> "\xEF\x00\xBD\x04\x00\xFA\x00\x14\xFE1\x16"
# >>> EF 00 BD 04 00 FA 00 14 FE 31 16
# <<< "\xEF\x00\xBD\x16\x00\x1490116322 2405150023\x00\xFBk\x16"
# <<< EF 00 BD 16 00 14 39 30 31 31 36 33 32 32 20 32 34 30 35 31 35 30 30 32 33 00 FB 6B 16
# request 8 - BMS Serial number 2 = BMS4503004810000SZTB
# >>> "\xEF\x00\xBD\x04\x01\xD4\x00\x14\xFEV\x16"
# >>> EF 00 BD 04 01 D4 00 14 FE 56 16
# <<< "\xEF\x00\xBD\x16\x00\x14BMS4503004810000SZTB\xFAk\x16"
# <<< EF 00 BD 16 00 14 42 4D 53 34 35 30 33 30 30 34 38 31 30 30 30 30 53 5A 54 42 FA 6B 16
# request 9 - Hardware Version and BMS SN2 App shows RX01 for SW version. HW Version = RS_GA02V01_51200
# >>> "~21004651E00200FD36\r" = 0x51 = get manufacturer information
# >>> 7E 32 31 30 30 34 36 35 31 45 30 30 32 30 30 46 44 33 36 0D
# <<< "~21004600C040RS_GA02V01_51200 RX01BMS4503004810000SZTB F0E7\r"
# <<< 7E 32 31 30 30 34 36 30 30 43 30 34 30 52 53 5F 47 41 30 32 56 30 31 5F 35 31 32 30 30 20 20 20 20 52 58 30 31 42 4D 53 34 35 30 33 30 30 34 38 31 30 30 30 30 53 5A 54 42 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 46 30 45 37 0D
# request 10 - looks like time / date maybe 07E8 = 2024
# >>> "~2100464D0000FD9B\r"
# >>> 7E 32 31 30 30 34 36 34 44 30 30 30 30 46 44 39 42 0D
# <<< "~21004600200E07E8090D070100FAB3\r"
# <<< 7E 32 31 30 30 34 36 30 30 32 30 30 45 30 37 45 38 30 39 30 44 30 37 30 31 30 30 46 41 42 33 0D
# error example: EF 00 83 04 00 B5 00 01 FF 13 16 -the 13 is a miss type - so the response is some error I believe
# error response: EF 00 83 01 02 FF 7A 16