Hi! I'm using your example but it hangs on Vector raw = compass.readRaw(); after 2-5 minutes if I'm using 1m UTP cable. If direct connection - everything ok. What can you recommend?
UPD: the reason for that is infinite loop in readRegister16 depending on !Wire.available()
So some fail safe could be added. I patched it like
if(!Wire.available()) {
while (!begin())
{
Serial.println("Could not find a valid HMC5883L sensor, check wiring!");
delay(100);
}
return 0;
}
But the wire lib doesn't provide fail safe in it's Wire.endTransmission(); so if the power is lost for a second it won't recover too. So maybe should use another I2C lib with timeout support.
Hi! I'm using your example but it hangs on
Vector raw = compass.readRaw();after 2-5 minutes if I'm using 1m UTP cable. If direct connection - everything ok. What can you recommend?UPD: the reason for that is infinite loop in readRegister16 depending on
!Wire.available()So some fail safe could be added. I patched it like
But the wire lib doesn't provide fail safe in it's
Wire.endTransmission();so if the power is lost for a second it won't recover too. So maybe should use another I2C lib with timeout support.