I need connect the magnetometer HMC5843 on my arduino 2009. If I use a short cable(20cm) all it works. If I use a longer cable(2m) arduino always read 0 from sensor. I need use a cable not less than 1.2 m. I used normal cable and shield cable but the problem still remains. Anyone know how to fix it, please?
I2C is not designed for those sorts of lengths, it's really just an on-PCB protocol.
You could try running it at the 100kbps speed (I don't know how to do that but it must be possible) or get a buffer chip like the PCA9600.
Do you have a pull up resistor on the data and click lines. A 4K7 pull up from the signal line to +5V at the far end will help.
Thanks to everybody. I have put 2 pull up resistors of 1.5K from SDA-VCC and SCL-VCC and now it works with a 3 meters cable. That's good :)