How to connect multiple i2c-interface devices into a single pin A4 (SDA) and A5 (SCL) on Arduino?

  • I want to add a real time clock module into my little project. I want to display both time and date on my existing i2c 2x16 LCD module.

    Both i2c-interface real time clock module and 2x16 LCD module use the same pin A4 (SDA) and A5 (SCL) on Arduino Uno. After hours of searching on the net the i2c bus can actually take many serial devices. This is possible because each device has its own unique address.

    My question is how to physically wire the two i2c-interface devices into a single A4 and A5? Thanks.

    Short answer: Wire them in parallel. Tie the SDAs together and connect to A4, and the SCLs to A5. Then of course there is the pull-up issue that sometimes helps.

  • Some folks are having a hard time visualizing things connected together, so here's a picture:

    (Serving suggestion)


    simulate this circuit – Schematic created using CircuitLab I2C is a bus, so like-named signals are connected together. The addressing scheme allows the microcontroller to select which device it's talking to. On the Arduino the 10k pull-up resistors goto "VDD", which is the 5V or 3.3V pins.

    Hi, this may be very basic but I am new to electronics and landed this page from google search , what uC refers to ?

    I believe the reference is to any uC, as the connection scheme should be the same, unless noted otherwise.

    uC can be an Arduino. SDA is pin A4 and SCL is pin A5.

    @Ciastopiekarz, μC is short for "microcontroller." The greek letter μ is the abbreviation for micro. Because μ looks like u, lots of people just write "uC".

  • For I2C, if all the slave devices have different device addresses, all of the SDA pins should be connected together, and all of the SCL pins should be connected together. It's as simple as that.

    Naturally, you should also include pull-up resistors on both lines, as required for I2C. How to choose the resistor values has been discussed here before.

    I've found that as long as one of the devices is the DS3231 RTC then no external pullups are required.

    @SDsolar, that probably means the DS3231 has internal pull-ups, so by using that device, you are providing pull-ups for the bus. That's not necessarily a good thing, because it limits your freedom to adjust the pull up resistance depending on the number of devices on the bus.

    My thoughts exactly. Adding external pullups would be in parallel with whatever is in the DS3231, and so might end up not being enough for I2C to be happy.

    @SDsolar, What does this have to do with OP's question or my answer? This is not a general discussion site. If you want to just talk about stuff, you can join our chat room.

  • Connect two pins A4-sda to A5-scl(on both board uno-uno) and connect resistor from 5v from each corresponding sda-scl lines.

    enter image description here

    voted down because the answer doesn't answer the original question, namely "physically wire the two i2c-interface devices into a single A4 and A5".

    I could not delete, so I edit to a (maybe) more satisfactory answer

    Sharing the voltage is not required right?

  • I2C is a data transfer protocol developed by Philips. Also known as two-wire interface since it uses two wires for communication. SCL-Serial Clock Line. SDL-Serial Data Line. So you need to connect corresponding pins of the i2c devices be it an eeprom or lcd to SCL and SDL pins of micro controller you are using with a pullup resistor to VDD. Since it is an addresses protocol having 7-bit address for each device connected you can address upto 2^7 different devices. But normally I2C address of a slave device is predefined with some bits to be hardwired by the developer. This helps in connecting same type of devices with different hardwired address part on the same bus.

    All true, but it sucks if you want more than one, like the BH1750 light-intensity unit. I want 4 of them and don't want to deal with I2C dual-bus switching.. Also, some devices like the DS3231 have internal pullups so any external pullups are in parallel with them.

  • Also you should check the pull up resistors. If you use already made boards, not only the chip, that boards usually have pull up resistors on board between buss and vcc. So when you connect every thing in parallel, the resistors are also in parallel, so total resistor value drop and your communication may fail.

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM