Hey there,
im having Problems with communicating with a BMS over I²C. I boiled down the problem to the size of the Buffer of the wire.h library. In the documentation it is stated, that the buffer should be 32 bytes long. So the following lines of code should not be a problem:
However on the scope i can see that only the first three bytes get transmitted. Apart from a missing ACK the endTransmission() command does not report any problems. This looks like the buffer is only three bytes long without the endTransmission command reporting this as a problem.
Has anybody had a similar problem? And maybe a solution to send more than 3 bytes?
I think I found a problem. I didn't now that a I²C Master aborts the communication as soon as a Slave reports a NACK. I thougt the NACK could be ignored. Since the Slave didn't understand the 01 02 03 04 commands on the bus it NACKed and Arduino aborted the bus after three bytes.
The original Problem occured with a more complex command that i was testing after several "easy" commands were successfully implemented. So there must be a problem with the order of individual bytes in the complex command.
I thought that the Arduino itself aborted any comms longer than x bytes but it was the Slave that was confused with the commands, NACKed and thus stopped the Arduino communicating.
I didn't know NACKs where a serious problem, because i get them frequently when reading data from the slave. (The Arduino doesn't ACK when reading the bytes.)
Shorter, successfully implemented commands didn't result in the BMS NACKing so there wasn't a problem. I got NACKs when reading data from the BMS so i thought some NACKs wouldn't be a problem.
Both MEGA and Micro a 5V Controllers. But since the Pullups to 5V are quite weak (10K on MEGA, None/only internal on Micro) the BMS is perfectly fine. It too has 10K pullups to its own 3,3V supply. I used the Mega for some weeks now. The final MCU will be 3,3V though.
The BMS is supplied by the cells itself. With 4 cells that's up to 16,8V. It has internal LDOs to supply itself with 3,3V. The PullUps on the MEGA from SDA/SCL to 5V have so far not been a problem. According to the Datasheet the BMS can tolerate up 5,5V on SDA/SCL without any problems.
The I²C Adress is stated on page 53 of the datasheet.
The Recommended operating Voltage Min/Max of SDA/SCL is stated on page 9 of the datasheet.
Usually, the data sheets mention the 7-bit slave/device address. This data sheets have given the 8-bit I2C Bus address which you have shifted 1-bit right to get the 7-bit slave/device address.