Open airy77 opened 2 years ago
The fix on that site took care of it for me. Using Arduino Mega, no need to 3.3 to 5v TTL translators, since Mega is a 5v board and 5v UART.
This is what I followed:
I think there are some errors in the bms.cpp. First, there are 5 lines with
write(true, BMS_REG_NAME, data, length); with an NODEMCU i got an error, I change data with length to write(true, BMS_REG_NAME, length, data);
Second, line 357 write(true, BMS_REG_CTL_MOSFET, length, data); change to write(false, BMS_REG_CTL_MOSFET, data, length);
Last, lines 348 ff data[0] = 0b11; data[1] = 0; if (charge) { data[0] &= 0b10; } if (discharge) { data[0] &= 0b01; } change to
data[0] = 0; data[1] = 0b11; if (charge) { data[1] &= 0b10; } if (discharge) { data[1] &= 0b01; } now bms.set_mosfet_control(true (or false), true (or false)) works.
Looking at the bms.cpp file and specifically the function definition "OverkillSolarBms::set_mosfet_control(bool charge, bool discharge)", I see the following call:
write(true, BMS_REG_CTL_MOSFET, length, data);
The first parameter "true" is used to indicate that the BMS will be read, why isn't this set to "false" indicating a write to the BMS to control the FETs? I changed the line in the code as follows:
write(false, BMS_REG_CTL_MOSFET, data, length);
I changed the first parameter from true to false (should change the old read to a write), and I swapped the data and length fields as others have noted, but it still doesn't work. I've seen others swapping data bytes (https://www.reddit.com/r/OverkillSolarBMS/comments/mmosr0/overkillsolarbmsarduinolibrary_mosfets_onoff/) to try and fix the issue but I am hesitant to arbitrarily write different registers within the BMS without knowing. Are the BMS registers defined somewhere so I can determine the proper way to write and control the FETs?