GolamMostafa:
If you have followed this connection diagram (Fig-1), then the I2C addresses of:
MPU6050 is: 0x69
HMC8883L is: 0x68
You need to edit the MPU6050.h Library to set the address of the device at 0x69.
Fig-1:
This is the Library I use for MPU6050.
Isn't the address of the HMC8883L 0x1E or 30 ?
Also, note that passing the i2c data through the MPU6050 isn't necessary. Use it if you want the MPU6050 to gather it for you. But It does nothing with the data besides getting it. and there is no advantage for you if you use the i2c bus anyway to get the data. The embedded DMP firmware we inject into the MPU6050 has no available registers or way to use the magnetometer data! I have investigated this in-depth.
You could just as easily have the MPU6050 and the HMC8883L tied on the same i2c bus without any drawbacks. I would recommend moving the XCL wire to the SCL and the XDA wire to the SDA. the 2 4.7k resistors tied to the 3.3 supplies on the mpu6050 and the HMC8883L fall within the max current limits of the i2c connections. Also, this would eliminate you from having to change registers in the MPU6050 to pass the i2c communications through it.
If you wish to use this schematic
4.14 Register 55 – INT Pin / Bypass Enable Configuration INT_PIN_CFG
I2C_BYPASS_EN When this bit is equal to 1 and I2C_MST_EN (Register 106 bit[5]) is equal to 0, the host application processor will be able to directly access the auxiliary I 2C bus of the MPU-60X0. When this bit is equal to 0, the host application processor will not be able to directly access the auxiliary I2C bus of th
or you could ask the MPU6050 to get the data for you and store it.
4.8 Registers 37 to 39 – I 2C Slave 0 Control I2C_SLV0_ADDR, I2C_SLV0_REG, and I2C_SLV0_CTRL
I2C_SLV0,1,2,3 and I2C_SLV4 are used to send and receive data from the Secondary i2c bus. and store it in the
4.20 Registers 73 to 96 – External Sensor Data EXT_SENS_DATA_00 through EXT_SENS_DATA_23
Description: These registers store data read from external sensors by the Slave 0, 1, 2, and 3 on the auxiliary I2C interface. Data read by Slave 4 is stored in I2C_SLV4_DI (Register 53). External sensor data is written to these registers at the Sample Rate as defined in Register 25. This access rate can be reduced by using the Slave Delay Enable registers (Register 103). External sensor data registers, along with the gyroscope measurement registers, accelerometer measurement registers, and temperature measurement registers, are composed of two sets of registers: an internal register set and a user-facing read register set. The data within the external sensors’ internal register set is always updated at the Sample Rate (or the reduced access rate) whenever the serial interface is idle. This guarantees that a burst read of sensor registers will read measurements from the same sampling instant. Note that if burst reads are not used, the user is responsible for ensuring a set of single byte reads correspond to a single sampling instant by checking the Data Ready interrupt. Data is placed in these external sensor data registers according to I2C_SLV0_CTRL, I2C_SLV1_CTRL, I2C_SLV2_CTRL, and I2C_SLV3_CTRL (Registers 39, 42, 45, and 48). When more than zero bytes are read (I2C_SLVx_LEN > 0) from an enabled slave (I2C_SLVx_EN = 1), the slave is read at the Sample Rate (as defined in Register 25) or delayed rate (if specified in Register 52 and 103). During each Sample cycle, slave reads are performed in order of Slave number. If all slaves are enabled with more than zero bytes to be read, the order will be Slave 0, followed by Slave 1, Slave 2, and Slave 3.
Z