I want to link a PIC16F1825 and a TCN75 temperature sensor via I2C. The temperature sensor is about 1m from the MCU. Can somebody enlighten me on whether and what kind of difficulties I am going to face by running I2C over wire? I read that I2C can be quite noise sensitive especially at higher rates and longer distances.
How much of an issue is this really going to be in practice in my case? Does anybody have any experience under similar conditions? I am quite happy so stick with slow transfer rates.
- Link will operate at 5V.
- What can I do to make this link as simple in design as well as operation as possible?
- With standard non-TP signal cables I will not know their capacitance. How do I calculate the pull-up resistors?
- Will I need any pull-up resistors or is the PIC16 pull-up current sufficient?
Alternatively, can somebody point me towards an AN that will help me with I2C over wire?
Best Answer
You definitely need external pull-up resistors. The internal pull-ups of a microcontroller are too weak. Note that with a high capacitance bus it's usually not a problem to have fast falling edges, because the FETs which pull the line low have low impedance, and then the wire's capacitance can be discharged quickly.
But for the rising edge we only have the relative high resistance of the pull-ups, and the RC time of that combined with the wire's capacitance determines the rise time. A smaller resistance value is better, but there's a limit to this too: an I2C device doesn't have to draw more than 3 mA, so at 5 V bus voltage the resistance shouldn't be lower than 1.7 kΩ.
The graph shows the maximum pull-up resistance for a given wire capacitance. At 1 m that capacitance won't be high, if you use signal wire probably less than 50 pF, and even for 100 pF you could go up to 12 kΩ. I'd stay near the lower limit though, not only will you have faster edges, but a lower impedance also makes the wire less sensitive to noise. 2.2 kΩ resistors will probably do.
Further reading
I2C Specification
I2C termination versus capacitance