Arduino DUE - I2C connection lost after a while - SOLVED

I have an Arduino DUE and a GPS module, equipped with an HMC5883l.
I run an example program on the DUE but after a while, the program stops working. I assume it could be some I2C problem.
Here are the tests I made:
-Arduino DUE + HMC5883l, connected on SCL/SDA: dies after 15-40 min.
-Arduino DUE + HMC5883l, connected on SCL1/SDA1: dies instantly
-Arduino DUE + HMC5883l, connected on SCL1/SDA1(with 4700ohm pull-ups): dies after 4 min
-Arduino UNO + HMC5883l: stable (tested for 24h)
Why does it run with the DUE so poorly and with the UNO so stable? Is it something with the pull-ups? Or with the voltage?

Sounds like a voltage issue; the Due is 3.3 volts and the Uno is 5. Just a thought...

Yes, I know it, but the I2c bus is open-drain. I am not sure, but the voltage shouldn't be a problem.

I tried using a Due some time ago, and if I recall, I had to use a level-shifter for the compass chip, and the LCD. I liked the Due for it's cpu power, but for me, the 3.3 volts and miniscule (3 milli-ohm, if I recall correctly) source limit on the GPIO pins was a giant PITA. If they made a 5 volt Due with the Mega's 16 analog pins, I'd marry it. LOL

I bet for an EMI issue with your I2C bus. The DUE I2C bus is sensitive to EMI, but there are several workarounds.

A good practice with I2C would be to implement a timeout each time the I2C master reads an I2C slave. In case the timeout is reached, try first to reset the I2C bus: Reconfigure the SCL line in GPIO output and generate nine clock pulses via software to unlock the I2C device. Once done, the SCL line can be reconfigured as a peripheral line.

You can also have a reset line to the I2C slave in case of a non recoverable hang out.

See these threads for more details:

https://forum.arduino.cc/index.php?topic=560415.0
reply #1

https://forum.arduino.cc/index.php?topic=488910.msg3691618#msg3691618
reply #8

FYI, if you decide to use SDA1/SCL1, 2K2 Ohms pull ups seem a good option.

Thank you for your answers!

Okay, I will give the level-shifter a try. Unfortunately, I don't have any level-shifters on hand, so I need to order a couple, which will take time.
I agree with you, a 5v DUE would be awesome, but the Teensy 3.5 is also considerable.

EMI issue? That's interesting because I keep my SCL and SDA lines away from any high current power lines. On the other hand, reimplementing and I2C communication would be quite a hard task for me (as a beginner).

Okay, thanks for your help, I have solved my problem, following those threads, that ard_newbie mentioned.
The solution isn't complicated, I simply put one pair of 120ohm resistors to the SCL, SDA line, between the Due and the HMC5883l. It became very stable, there aren't any random freezes any more.