Hello,
I am currently working on a BMS project where I am using the Arduino Mega 2560 as my microcontroller. The BMS IC that I am currently using has I2C communication capability, but when I tried to run the code and interface with the board its returning the garbage values. The below are the details of my code that I used to check the communication of my setup:
#include<Wire.h>
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Wire.begin();
Wire.beginTransmission(80); //
byte error = Wire.endTransmission();
if ( error == 0)
{
Serial.println("chip found");
}
else {
Serial.println("chip not found");
}
}
void stat_MODE()
{
Wire.beginTransmission(80); // Slave address of my BMS IC is 0X50H
Wire.write(0X00); // register address
Wire.endTransmission();
Wire.requestFrom(80,7);
Serial.println("Read register3");
byte k = Wire.read();
Serial.println(k);
}
void loop() {
// put your main code here, to run repeatedly:
stat_MODE();
delay(5000);
}
Could you please tell me is there any mistake is there in my code because its always returning the garbage values