Connecting ArduIMU to APM via I2C

I have a project where I need to connect an external ArduIMU V3 to an ArduPilot Mega 2.5 board via I2C, where the APM will contain modified ArduPlane code.  Both will be on a vehicle, and I want to be able to measure the motion of the ArduIMU with respect to the APM.  There are insufficient unused analog channels on the APM to send raw analog signals.

Wire.h has been used on modified ArduIMU (1.9.8) software to set the device as a slave and send an array of bytes.  The ArduIMU begins Wire with the desired address, and then sets a function for when the master requests data.  This works fine when connecting to an Arduino UNO board also using the Wire library.   

As the ArduPlane software uses I2CDriver, I attempted to use this library to communicate with the ArduIMU.  On the APM side, I used the following:

uint8_t dataI2C[128];
uint8_t nbstruct = sizeof(IMUDataStructure);
int stat = hal.i2c->read((uint8_t)0x05,nbstruct,dataI2C);

(where IMUDataStructure is a structure containing int variables for each of the three acceleration, gyro and magnetometer values) however stat keeps returning as 1, and the ArduIMU is never getting a request for data - IMU is meant to print to terminal when data is requested, but never prints that particular string:

void requestEvent()
{
     Wire.write((uint8_t*)data,nbstruct);
     Serial.println("Responded to request");
}

Again, this all works with no issues when connected to the Arduino UNO using the Wire library.  Any assistance on getting the ArduIMU and APM communicating would be greatly appreciated.  

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Hi, did you remember to init the i2c driver with begin()? Nothing else does it for you.

    Regards

    Soren

This reply was deleted.

Activity