Collecting Data From ESC/Motor With I2C

I'm using an Arduino and Castle Serial Link chip to run a BLDC motor through an Castle Phoenix Edge 75 ESC. I'm using an I2C communication protocol to have Arduino extract the data (such as RPM) from the ESC/Serial Link. The problem is I keep getting a read value of 0 every time.

I know for sure the address of the slave (ESC) is correct. I quadruple checked it. There is definitely communication between the Arduino and Serial Link Chip/ESC by the nature of my code. I've attached the code that controls the motor and collects data here. Anyone have any idea why this is happening?

Here is the link to the Castle Serial Link and where it tells me the value of the register read:
http://www.castlecreations.com/support/documents/castle_serial_link_v1.3.pdf

//set up library
#include <Servo.h>
#include <Wire.h>

int motorSpeed = 0; // set inital speed to zero

Servo ESC;

void setup() {

  ESC.attach(9);    // attached to pin 9
  Serial.begin(9600);    // start serial at 9600 baud
  Wire.begin();

}

void loop() {

  ESC.writeMicroseconds(motorSpeed);

  //I2C communication protocal
  Wire.beginTransmission(0x08);
  Wire.write(0x05);
  Wire.requestFrom(0x08, 2);
  while (Wire.available() == 0);
  byte data1 = Wire.read();
  byte data2 = Wire.read();
  Wire.endTransmission();
  byte val = ((data1 << 8) + data2);
  //covert the data into RPM
  float rpm = val / (2042 * 20416.66);
  Serial.print("rpm: ");
  Serial.println(rpm);
  delay(100);

  //ask user to input new speed for motor
  //Enter value that range from 1050 to 1300
  //values over 1300 will make the motor spin INCREDIBLY FAST. WATCH OUT!!!!
  if (Serial.available())
    motorSpeed = Serial.parseInt();    // Parse an Integer from Serial
  Serial.print("motorSpeed: ");
  Serial.println(motorSpeed);
}

Without looking into the manual, I found a problem here. You had Wire.endTransmission in the wrong place. It should be like this:

  //I2C communication protocal
  Wire.beginTransmission(0x08);
  Wire.write(0x05);
  Wire.endTransmission();

  Wire.requestFrom(0x08, 2);
  while (Wire.available() == 0);
  byte data1 = Wire.read();
  byte data2 = Wire.read();

I actually had the code like this before and it didn't work as well. :frowning:

kuan3:
I actually had the code like this before and it didn't work as well. :frowning:

Don't waste your time.

OP has another post with same topic Trouble Obtaining Data From ESC/Motor - Motors, Mechanics, Power and CNC - Arduino Forum

ieee488:
Don't waste your time.

OP has another post with same topic Trouble Obtaining Data From ESC/Motor - Motors, Mechanics, Power and CNC - Arduino Forum

Thanks

Did anyone get this working?

I have tried the code above and many other examples of reading I2C but I always get zeroes back.

I have tried 10K 4.4K and 2.2K pull up resistors and no luck.