How can I use analog I2C on arduino MEGA2560

Hey guys.The test is normal on esp32, I’ll report an error if I move the code to arduino MEGA2560.

Examples on esp32:
MagneticSensorI2C sensor = MagneticSensorI2C(AS5600_I2C);
MagneticSensorI2C sensor1 = MagneticSensorI2C(AS5600_I2C);
TwoWire I2Cone = TwoWire(0);
TwoWire I2Ctwo = TwoWire(1);

void setup() {
I2Cone.begin(18, 5, 400000);
I2Ctwo.begin(19, 23, 400000);
}

I want to use two-way analog I2C on MEGA2560,what can i do.Thankyou.

Does the MEGA2560 have 2 I2C buses? If so, you are on the right track…

Pass the I2C object to the sensor’s init method:

sensor.init(&I2Cone);
sensor1.init(&I2Ctwo);

one i2c, I want set other IO ports for I2C by using simulated I2C.

I am not sure how well this will work. Running 2 x I2C sensor is already kind of slow with hardware I2C at 400kHz. Your main loop has to call loopFOC() very often, maybe not less than 1000x per second.
You can give it a try, but your results will be much better if you can use an SPI-based sensor.