The circuit on the left works OK. There are two I2C temperature sensors ((TMP102) on breakout boards. The software arranges for the fan to come on if the sensor on the left is above 18 degrees C. I arrange for this to happen by putting my finger on top of the IC. (I have a piece of tape over my finger to prevent the approximately 20k resistance of my skin causing a problem.)
The circuit below with longer wiring to the TMP102 does not work as expected. I’ve checked the wiring, re-
By altering the values in the condtional clause in the software it seems that in this fault mode, the Trinket is interpreting the signal from the TMP102 as signifying a temperature of about 0.5 degreesC.
In the circuit arrangement below, just the unconnected extension wires are enough to stop the system functioning as expected.
However, if the extension SDA wire is disconnected, the system works as it should, switching on the fan at the touch of my finger. All it takes to stop it working is to plug in a small piece of wire (connected to nothing as shown)! The system does not work with a piece of wire longer than about 70mm. The system works with 50mm of wire sticking out of the SDA connection but moving my hand within about 10mm of the wire causes it to fail.
At first I thought it might be some sort of capacitative loading but then I wondered about 50hz hum pickup corrupting the clock signal.
Apparently the maximum bus capacitance for I2C is 400pF. I don’t think a few inches of wire can exceed that. However, I don’t have the test equipment or technical knowledge to analyse exactly what is going on.
However, I have used the same TMP102 sensors over a 10M connection with an Arduino, seemingly without problems. One difference is that a logic level shifter was required to match the 3.3v TMP102 with the 5v Arduino. Perhaps this acted as a low impedance buffer?
I2C problems
I’ve also tried a 5v Trinket and 5 to 3.3v level shifters. I didn’t seem to be getting noise pickup but bafflingly, I couldn’t seem to get two TMP102s to work, it would only work with one! (Yes, I had set the TMP102s to two different addresses! I stared and stared at the circuit and the software but I just couldn't see what I was doing wrong!
Eventually, I gave up and went back to an Arduino Uno which seemed to work perfectly (as it had on my heating system controller).
With the Arduino, I2C works over quite a long cable!