Reduce noise on Arduino 400 kHz I2C with external pull-up resistors
Yesterday I wrote about how sensitive the I2C bus was to noise induced by merely touching exposed leads with a finger.
A friend suggested that increasing the current flow on the bus might help drown out the noise. Indeed, a quick google search turned up this article on the effects of various pull-up resistor values on the I2C bus. Essentially, if the pull-up resistor on the I2C bus is too resistive, the I2C pins do not go high fast enough, so the effective I2C bus operation frequency is lower than what the code tries to do.
It makes sense that I would have this problem. Arduino’s I2C library comes configured for 100 kHz operation by default. Then it is likely that the Arduino hardware (and the Seeeduino hardware) was designed for 100 kHz operation as well, and the internal pull-up resistor of the ATmega was probably good enough for that speed. However, I modified the code to run I2C at 400 kHz and did not realize I had to make hardware modifications, as well.
Fortunately, adding a few (1.5 kOhm) resistors takes no work at all, and now I have a beautiful, square waveform:
That said, this is only an improvement in that if I breathe on the circuit long enough, I can still make the signal go haywire. Nevertheless, that takes long enough to guarantee that the electronics will not fail all the time in humid Oregon. Besides, I would not expect this to work with a screwdriver laid across the leads, would I? (Or water. I tried running the circuit with a drop of water on the gyro breakout board, but it didn’t work.)
Categorised as: Projects