What to do if multiple boards require the same SCL and SDA pins

Hello, I have a Mega connected to a breakout board which uses both digital pins 20 (SDA) and 21 (SCL). Now I want to add another breakout board but it requires the same two pins. Can you please tell me what to do?

If these are I2C boards, they should have address jumpers or assigned addresses you can refer to in you sketch. .

Common I2C devices are a clock and an LCD. They are declared by their addresses, being typically

#define DS1307_ADDRESS 0x68                                         //addr 0x27
liquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);   //addr 0x68

All I2C devices share the same SCL and SDA lines, no need to reserve different pins for each device.

On that common bus the devices are selected by their individual addresses. Check the I2C addresses of your boards, they must be different for each device.

What are your boards? We can help you find the I2C addresses for those boards, and show you how to wire them. The exact board matters, so can you post a link to a website that shows the boards you are using please?

newto_arduino: ... Can you please tell me what to do?

Do a little research on the basics of I2C ;)

sterretje: Do a little research on the basics of I2C ;)

The 'basics' of I2C are pretty intimidating. I see timing diagrams and ... specifications! :fearful:

When I realized it was much simpler than that, I became enamored of I2C because it's a no brainer.

OP: learn how to use it, then copy, paste, and modify an I2C example for your own purposes.

ChrisTenone: The 'basics' of I2C are pretty intimidating. I see timing diagrams and ... specifications! :fearful:

You find the wrong stuff ;) Try i2c.info, can't get much simpler than the first picture in the text.

Don't forget to connect all the Gnds together.

sterretje:
You find the wrong stuff :wink: Try i2c.info, can’t get much simpler than the first picture in the text.

Ok. That is a really nice site. Thanks for posting it. I’d call that an overview tho, not ‘the basics’.