30
\$\begingroup\$

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.

\$\endgroup\$
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ – SDsolar Mar 23 '17 at 6:20
31
\$\begingroup\$

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

(Serving suggestion)

schematic

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.

\$\endgroup\$
  • \$\begingroup\$ Hi, this may be very basic but I am new to electronics and landed this page from google search , what uC refers to ? \$\endgroup\$ – Ciasto piekarz Nov 30 '16 at 7:06
  • \$\begingroup\$ I believe the reference is to any uC, as the connection scheme should be the same, unless noted otherwise. \$\endgroup\$ – KingsInnerSoul Jan 5 '17 at 1:29
  • \$\begingroup\$ uC can be an Arduino. SDA is pin A4 and SCL is pin A5. \$\endgroup\$ – SDsolar Mar 23 '17 at 6:21
  • 7
    \$\begingroup\$ @Ciastopiekarz, μC is short for "microcontroller." The greek letter μ is the abbreviation for micro. Because μ looks like u, lots of people just write "uC". \$\endgroup\$ – foobarbecue Jul 23 '17 at 1:17
8
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ I've found that as long as one of the devices is the DS3231 RTC then no external pullups are required. \$\endgroup\$ – SDsolar Mar 22 '17 at 21:15
  • 2
    \$\begingroup\$ @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. \$\endgroup\$ – The Photon Mar 22 '17 at 21:45
  • \$\begingroup\$ 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. \$\endgroup\$ – SDsolar Mar 23 '17 at 5:49
  • \$\begingroup\$ @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. \$\endgroup\$ – The Photon Mar 23 '17 at 15:43
2
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ 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". \$\endgroup\$ – Oleg Mazurov Aug 6 '15 at 18:06
  • \$\begingroup\$ I could not delete, so I edit to a (maybe) more satisfactory answer \$\endgroup\$ – daedalucian Aug 6 '15 at 18:25
  • \$\begingroup\$ Sharing the voltage is not required right? \$\endgroup\$ – clankill3r Jan 24 at 18:25
0
\$\begingroup\$

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – SDsolar Mar 23 '17 at 6:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.