Why use a 47k resistor between 3.3v and SDA and SCL port of ESP3266

Hello guys,

Reading many articles of using I2C devices I realized that in most of diagrams the circuits add a 47K resistor between 3.3v and SDA, SLC (both PINS).

It’s mandatory ? How is the real main function of these ?

I ask, because I have 2 I2C sensor on my ESP, working without problem without any resistor.

Thanks in advance

Pullup resistors are required on the I2C lines SDA and SCL. The typical resistor is 4.7K (4700 Ohms). Many modules come with the pullups installed on the module board. One or more of your boards probably has the pullups installed. Also, the Wire library enables the internal pullups on the SDA and SCL pins, although on some boards (ie, Uno) the internal pullups are pretty weak and may not be enough by themselves. You can have too much pullup if many modules have resistors installed, the parallel resistance can be too low.

From the Sparkfun I2C tutorial:

Unlike UART or SPI connections, the I2C bus drivers are “open drain”, meaning that they can pull the corresponding signal line low, but cannot drive it high. Thus, there can be no bus contention where one device is trying to drive the line high while another tries to pull it low, eliminating the potential for damage to the drivers or excessive power dissipation in the system. Each signal line has a pull-up resistor on it, to restore the signal to high when no device is asserting it low.

Just guessing but it’s possible most I2C breakout boards have 47k because as you add more and more devices on the bus , all those resistors become in parallel and that way
you can have quite a few devices before the value actually gets down to 4.7k (like 10
devices (47000/4700)

The exact value of the pullup depends mostly on the capacitance of the data line to ground. (Which is why twisted-pair cable is a bad solution) It’s best determined with an oscilloscope, but 4k7 is a good starting point.

I2C communicates by pulling the data line low. If the pullup resistor is too small, then the device can’t pull the data line to a logical low. If it’s too large, its open-collector value may not be a logical high, or easily brought to a low state by induced noise on the data line.

Thanks you so much to all guys. Now the idea is clear!