user52219: This question is asked a lot and I've found many usable details on different forums regarding adding pull-up resistors on SDA/SCL lines. I know that only one resistor should be added on these lines regardless of how many devices are attached.
One thing that is not clear for me is that what if I2C devices are powered on from different sources, at different timing?
In following schematic, I have used pull up resistors for both I2C devices. Considering devices might be turned on and off at different timing, or even one device might be absent, is it fine to remove the second pull up resistors (second I2C device) and connect them directly to SDA/SCL pins on uC? In this case (removing pull-up resistors from second device), what happens if device 1 is not available and only second device is connected?
---edit:

Schematic was updated to include only one pair of pull up resistors connected to master side.
I will not how swap or hot plug I2C devices.
I2C devices are sensors (BME280 here, and Chirp capacitive soil moisture, here), not on breakout boards with preset pull up resistors.
Is it possible to just connect resistors on master side and not slave side? In this case, would it be fine for both sensors?


simulate this circuit – Schematic created using CircuitLab

user47766: I wanted to add this as a comment but I ran out of characters, so this isn't an answer, just more comment. 
@Majenko "I would never suggest using I2C over anything other than short PCB traces. i2C + wires = no thank you sir."

And that made me write the following.
We had one product that needed an external radio module. I put a connector in to extend the I2C bus. Total length of the additional cable was about 4 feet. Enough to route it outside the box and mount the radio close by. 
Much later I am asked to look at why the communications is failing. The engineering manager had the cable extended to 20 feet. It worked for him on the bench when he tested it. No scope check on waveforms. No calculations. (he was a firmware programmer with just enough hardware knowledge to do his job)
I looked at the waveforms with a scope and I was shocked that it worked at all. The I2C lines were cpu to cpu. The radio had a microcontroller that acted as a slave I2C device. 
I put a couple of buffers on either end and all was back in spec and it worked reliably after that, in the field and not just on the bench.
We have a bigger control box that uses I2C to communicate to modules in the back of the box. I have a buffer at the CPU end. The cpu is 3.3v, the modules are 5 volts. The buffer does a level conversion and stronger drive than the cpu could handle. The back of the boxes are shown below. Space for 14 modules. The bigger box is about 2 feet wide and 3 feet tall. The I2C lines run vertically down the center of each of the columns on the back of the board.  

There also can be a secondary slave box for an additional 14 modules. The same back board. I used a second I2C port with and isolated I2C buffer for driving the lines. The slave boax was to be mounted beside the main box. Again I specified a short cable, this time six feet in length. 
So one day I am asked if the cable can be extended. The contractor installing the panels wanted to put the slave boax on the other side of the hall by another electrical panel. I ask how long do they need. I'm told it is ten feet away. Yeah, ten feet line of sight. Once the cable was touted up into the ceiling, across the hall, and then down to the other box, the 10 feet turned into 30 feet. 
I did a check with a scope. The rise times were still in spec, it seemed to work, so we made up a cable and told them that it may or may not work. Use at their own risk. I told them this was an exception and it is not to be a part of the product offering. But I'm sure there will be more exceptions. 
And while it can work over those kind of distances the following shows how I2C can fail over short distances. 
Same equipment. The smaller box in the picture was expanded with an additional larger box. The smaller box was mounted eight inches above the bigger box. (display and main cpu in the front panel of the product) Only temperature input into the modules in the smaller box. The bigger box was loaded with modules with control relays. Four 17 amp relays per module.  Same electronics as in the exception described above. But they were having lots of sporadic behaviour. Pictures of the wiring, the installation, looked clean and well done. I had no idea why it was failing.
After this had been going on for a couple of months I asked our customer service person to ask what they have connected to our relays. Normally it would be motor up to 1 hp. They were controlling bigger motors and they had our relays turning on power contactors in a different panel. Lots of power contactors. All generating voltage spikes when they were turned off. I had them put snubbers across the contactor coils and the problems went away. 
So I2C can work over longer distances, and it can fail over shorter distances. The whole picture needs to be taken into account. The problem is the whole picture often is hard to see.   

user4143: You should consider adding some bus isolation between each slave and the master. The reason being is that the ESD diodes in the SCL/SDA pins of a slave that is powered down could be interfering with the I2C bus as they leech power from the bus to feed through the internals of the slave.  Given the low current imposed by the pullup resistors being the only power source this shouldn't cause any damage to the slave, but it may well cause the I2C bus to be seen as LOW when it shouldn't, causing communication to fail.
You should add a buffer with an "enable" pin of its own between each slave and the bus.  My device of choice is the PCA9306 from Texas Instruments.  It also means that the slave has its own separate pullup resistors powered by its own 3.3V rail, keeping all the power separate.
You would then have sequences such as:

Power up slave
Give short powerup delay (if needed)
Enable PCA9306
Do I2C transactions
Disable PCA9306
Power off slave

The PCA9306 can also be used to connect 3.3V slaves to a 5V MCU if needed.

simulate this circuit – Schematic created using CircuitLab

52219: <p>This question is asked a lot and I've found many usable details on different forums regarding adding pull-up resistors on SDA/SCL lines. I know that only one resistor should be added on these lines regardless of how many devices are attached.</p>

<p>One thing that is not clear for me is that what if I2C devices are powered on from different sources, at different timing?
In following schematic, I have used pull up resistors for both I2C devices. Considering devices might be turned on and off at different timing, or even one device might be absent, is it fine to remove the second pull up resistors (second I2C device) and connect them directly to SDA/SCL pins on uC? In this case (removing pull-up resistors from second device), what happens if device 1 is not available and only second device is connected?</p>

<p>---edit:</p>

<ul>
<li><p>Schematic was updated to include only one pair of pull up resistors connected to master side.</p></li>
<li><p>I will not how swap or hot plug I2C devices.</p></li>
<li><p>I2C devices are sensors (BME280 <a href="https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME280-DS002.pdf" rel="nofollow noreferrer">here</a>, and Chirp capacitive soil moisture, <a href="https://www.tindie.com/products/miceuz/i2c-soil-moisture-sensor/" rel="nofollow noreferrer">here</a>), not on breakout boards with preset pull up resistors.</p></li>
<li><p>Is it possible to just connect resistors on master side and not slave side? In this case, would it be fine for both sensors?</p></li>
</ul>



<p><img src="https://i.stack.imgur.com/oetuB.png" alt="schematic"></p>



<p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2foetuB.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p>
 47766: <p>I wanted to add this as a comment but I ran out of characters, so this isn't an answer, just more comment. </p>

<pre><code>@Majenko "I would never suggest using I2C over anything other than short PCB traces. i2C + wires = no thank you sir."
</code></pre>

<p>And that made me write the following.</p>

<p>We had one product that needed an external radio module. I put a connector in to extend the I2C bus. Total length of the additional cable was about 4 feet. Enough to route it outside the box and mount the radio close by. </p>

<p>Much later I am asked to look at why the communications is failing. The engineering manager had the cable extended to 20 feet. It worked for him <em>on the bench</em> when he tested it. No scope check on waveforms. No calculations. (he was a firmware programmer with just enough hardware knowledge to do his job)</p>

<p>I looked at the waveforms with a scope and I was shocked that it worked at all. The I2C lines were cpu to cpu. The radio had a microcontroller that acted as a slave I2C device. </p>

<p>I put a couple of buffers on either end and all was back in spec and it worked reliably after that, in the field and not just on the bench.</p>

<p>We have a bigger control box that uses I2C to communicate to modules in the back of the box. I have a buffer at the CPU end. The cpu is 3.3v, the modules are 5 volts. The buffer does a level conversion and stronger drive than the cpu could handle. The back of the boxes are shown below. Space for 14 modules. The bigger box is about 2 feet wide and 3 feet tall. The I2C lines run vertically down the center of each of the columns on the back of the board.  </p>

<p><a href="https://i.stack.imgur.com/nFQyt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nFQyt.jpg" alt="enter image description here"></a></p>

<p>There also can be a secondary slave box for an additional 14 modules. The same back board. I used a second I2C port with and isolated I2C buffer for driving the lines. The slave boax was to be mounted beside the main box. Again I specified a short cable, this time six feet in length. </p>

<p>So one day I am asked if the cable can be extended. The contractor installing the panels wanted to put the slave boax on the other side of the hall by another electrical panel. I ask how long do they need. I'm told it is ten feet away. Yeah, ten feet line of sight. Once the cable was touted up into the ceiling, across the hall, and then down to the other box, the 10 feet turned into 30 feet. </p>

<p>I did a check with a scope. The rise times were still in spec, it seemed to work, so we made up a cable and told them that it may or may not work. Use at their own risk. I told them this was an exception and it is not to be a part of the product offering. But I'm sure there will be more exceptions. </p>

<p>And while it can work over those kind of distances the following shows how I2C can fail over short distances. </p>

<p>Same equipment. The smaller box in the picture was expanded with an additional larger box. The smaller box was mounted eight inches above the bigger box. (display and main cpu in the front panel of the product) Only temperature input into the modules in the smaller box. The bigger box was loaded with modules with control relays. Four 17 amp relays per module.  Same electronics as in the exception described above. But they were having lots of sporadic behaviour. Pictures of the wiring, the installation, looked clean and well done. I had no idea why it was failing.</p>

<p>After this had been going on for a couple of months I asked our customer service person to ask what they have connected to our relays. Normally it would be motor up to 1 hp. They were controlling bigger motors and they had our relays turning on power contactors in a different panel. Lots of power contactors. All generating voltage spikes when they were turned off. I had them put snubbers across the contactor coils and the problems went away. </p>

<p>So I2C can work over longer distances, and it can fail over shorter distances. The whole picture needs to be taken into account. The problem is the whole picture often is hard to see.   </p>
 4143: <p>You should consider adding some bus isolation between each slave and the master. The reason being is that the ESD diodes in the SCL/SDA pins of a slave that is powered down could be interfering with the I2C bus as they leech power from the bus to feed through the internals of the slave.  Given the low current imposed by the pullup resistors being the only power source this shouldn't cause any damage to the slave, but it may well cause the I2C bus to be seen as LOW when it shouldn't, causing communication to fail.</p>

<p>You should add a buffer with an "enable" pin of its own between each slave and the bus.  My device of choice is the <a href="http://www.ti.com/product/PCA9306" rel="nofollow noreferrer">PCA9306</a> from Texas Instruments.  It also means that the slave has its own separate pullup resistors powered by its own 3.3V rail, keeping all the power separate.</p>

<p>You would then have sequences such as:</p>

<ol>
<li>Power up slave</li>
<li>Give short powerup delay (if needed)</li>
<li>Enable PCA9306</li>
<li>Do I2C transactions</li>
<li>Disable PCA9306</li>
<li>Power off slave</li>
</ol>

<p>The PCA9306 can also be used to connect 3.3V slaves to a 5V MCU if needed.</p>



<p><img src="https://i.stack.imgur.com/hkDtE.png" alt="schematic"></p>



<p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fhkDtE.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p>
