• Per I2C standard, I2C devices can (well, should) only pull the I2C lines LOW themselves - this makes the parts cheaper to produce, and also makes interfacing between devices running on different voltages a bit easier. But, it also means that neither device is responsible for bringing the SDA/SCL lines high - and something's gotta do that.

    That's the role of pullup resistors.

    You need 2, one between VCC and SCL, the other between VCC and SDA. All these do is ensure that between bits, and between transfers in general, these two wires are kept around VCC, making them a logical HIGH value. (They "pull" the voltage "up", hence pull-up). The value needs to be low enough that they're effective at pulling the voltage up, but not so low that the devices have trouble overcoming them to send data. 10k and 4.7k are very commonly used, and in most cases, any value around there will work. When you need a pullup or pulldown resistor for other purposes, these are also typically good default choices.

    There are formulas that can be used to calculate the necessary value, but their use is rarely necessary for normal low-speed I2C (it becomes more relevant at higher speeds).

    Here's what I think the official ones are from the I2C spec:
    Rmin = (Vcc-0.4v)/3ma (ie, the pullup can't have such a low resistance that you have to sink more than 3ma to keep it below 0.4v, ie, logical LOW). This minimum is ~1k at 3.3v, ~1.5k at 5v.

    Rmax = 1000ns/Cbus for 100khz, 300ns/Cbus for higher speeds, where Cbus is the capacitance of the bus - counting both the inputs to devices on it, and the wires themselves (it needs to be able to overcome the capacitance of the bus and get the voltage back to a logical HIGH between bits fast enough to be ready for the next bit).

    Note also that when you buy modules with the sensor and some supporting components on it, they very often include the pullups.

About

Avatar for DrAzzy @DrAzzy started