I have an accelerometer which communicates with the arduino through I2C.
I put together some jumper wires in a total of 1.40m, and I had no problem at all in the I2C communication with the arduino.
However, if I use one single cable (with 4 wires), with approximately 1m, to connect the accelelometer to the arduino, there is no communication.
I have tried everything, replace the single cable, replace the headers, solder the cable directly to the accelelometer, check if the solder is done properly, etc.
Valen:
[EDIT] Maybe the cable has more capacitance causing the bit flanks to become too slow
This was my first thought as well (assuming the connections were proven good and some pull-ups were present). The OP could try slowing down the bus transfer rate and if that works, then the aforementioned is highly likely to be the problem.
Amagro, please consider that your use of long cables (meter length) is not how the I2C protocol is supposed to be used. It is intended as a bus between ICs on the same PCB, or in the same device with short bridging wires or connectors between PCBs. Long wires start to act like capacitors (especially with shielding), which the pull-up resistors need to charge when changing bitlevels from low to high. This can take a small amount of time that your master device is not expecting. It may have worked with that first cable, but that may just have been because you were lucky.
If you have access to an oscilloscope then try to look at the signals of SDA and SCL with it. See if it is like any of the 'scope screens in the link I placed earlier. If this is it then reducing the SCL clock rate, as Mee_n_Mac suggested, should get at least some communication going, but maybe not to the desired bandwidth. At least then you’ll know where the problem is.
The problem has been solved separating the cables, due to problems related with capacitance, although it isn’t a practical solution, but for now it will do.
In the future, I will have to learn more about I2C, in order to be able to use a single cable.
The problem has been solved separating the cables, due to problems related with capacitance, although it isn’t a practical solution, but for now it will do.
In the future, I will have to learn more about I2C, in order to be able to use a single cable.