I2C circuit - can't make 2 device work at the same bus (not the same address)

Thread Starter

david1234

Joined Nov 27, 2013
102
Hello,
I'm having BIG trouble with a simple circuit

I want to use I2C with Arduino while connecting
LCD(0x27)
Oled(0x61)
RTC1307 (0x68)
INA219 (0x41)
all of them work on 5V

the connection is with a 4K7 pullups
when I conenct Oled + LCD - I can see them in the scan code
Scanning...

I2C device found at address 0x27 (39)
I2C device found at address 0x3D (61)


when I connec the RTC1307 - it get stuck \ or running for 3 more times (with out the resualt from the clock) then get stuck.
I have also try to connect INA219 - get stuck

what could be the problem ?
I have double check the wiring 10 times -- all good there.

when I only connect one (INA219 \RTC) - I can see it's working
Scanning...

I2C device found at address 0x40 (64)


maybe when a device is "sending" data - like the DS1307\INA219I need to use another circuit?
can't use both on the same bus?

Thanks,
 

Papabravo

Joined Feb 24, 2006
13,690
What is the total length of the bus?
Where does the power come from, for each device?

You must be aware that I2C was DESIGNED so that all of the devices would be on the same board with a common power source. Is that correct?
 

andrewmm

Joined Feb 25, 2011
307
which arduino do you have ?
what of the I2C speeds are you running at ?

I2C is current mode open collector driven, so unless your arduino has the pull ups, you need to provide them.

Does the scan see all the I2C parts you have ?
 

dendad

Joined Feb 20, 2016
3,514
It may be each board has pullups included, so the resultant pullup is too low.
I am quite happily running an Arduino Nano to control a Codan radio having 7 devices on the I2C bus.
 

dendad

Joined Feb 20, 2016
3,514
Plug all the devices in, and with the power off, measure the resistance from DSA and SCL to +5V.
It may indicate too many resistors.
 

KeithWalker

Joined Jul 10, 2017
880
I2C is designed to use a pull up resistor on each line somewhere. Most devices lack the ability to pull up. Master and slaves only pull down.
The arduino I2C library uses analog pins 4 and 5 for data and clock inputs and configures them with internal pullups. If you are using a number of devices, you may have to add extra pullup resistors but I have never had to yet. You may have to experiment with values depending on the devices you are using.
Keith
 

Thread Starter

david1234

Joined Nov 27, 2013
102
I will answer for all the post in order:

1.
KeithWalker
I have try to use it without Pullups - when I didn't use them -sometime it's works ad sometime not.(after connectin them it was "stable")

2.
Papabravo
the total length of the bus is no more then 20 cm.
all the power is comming from the Ardino 3.3V , all of them connected to th same ground.

3.
andrewmm
the csan doesn't show all the devices - this is my problem.
.I have try to run it using Ardunio Uno , how can I know which speed each device is using? (I have never seem this option. everywhere I look to see how to connect to I2C - they just connected the devcies, not onw word about the speed).

4.
dendad
how did you do this? do you use any resistors? I know it should be very easy connection\setup.
this is why it so frustrating

5.
ronsimpson
this is the connection I have made , using 4K7 on SCL&SDA - didn't work.

6.
dendad
I will run this test , what should I see?
if I see 4K7 - is this OK?
if I see more\less - what does it mean\ and how can I change it ?

7.
KeithWalker
how can I know and calculate the value I need?
what is the formula to calculate pullups resistors with 5V ?
if I will change the 4K7 with 10K - will this give me a direction ?


Thanks,
 

Ian Rogers

Joined Dec 12, 2012
773
My two penneth….

First.. The I2C bus works quite well with 10k or 4k7 with one or two devices.. Using 4 devices I would use a 2k or a 1k.
Second.. There cannot be crosstalk.. ie.. You cant open one device whilst in communication with another.

From your comments, it looks like you have two communicating at the same time...

When you have all four devices on at the same time, can you scan all four addresses?? I would surmise that one of the addresses are conflicting.. Some devices have an external address switches..
 

Thread Starter

david1234

Joined Nov 27, 2013
102
nope ,
I have never seen all 4 at the same time.
I have check and every device has it's own address ( as I wrote at the first post) .

so what else can I do ?
 

Ian Rogers

Joined Dec 12, 2012
773
The only thing I can suggest.. You are running the bus too fast and some of the devices are not coping.. Try running at 400Mhz or lower...
 

Thread Starter

david1234

Joined Nov 27, 2013
102
can I change the bus speed?
I didn't know this
I saw there is a command
Wire.setClock()
in arduino
is there anywhy to know what is the speed now?
 

Ian Rogers

Joined Dec 12, 2012
773
Actually.. I just looked at the Arduino I2C and the setting is in the I2C header... I2C_LOW and I2C_HIGH.. Apparently. Its safer to use the original 100khz..

My bad... The last post should have said 400khz....
 

Thread Starter

david1234

Joined Nov 27, 2013
102
Great
I will try it and let you know if it's work for me.

to test it with the 4K7 pullups , or not?
 
Last edited:

KeithWalker

Joined Jul 10, 2017
880
I re-read the question and all the answers.
The scanning program was possibly never intended to be used with more than one device connected at a time. You may be trying to solve a non-existent problem!
If you can successfully get the addresses of all the devices you want to use, connect up one device and try programming it in your application. If it works OK, add the next device and program it, making sure you only open one device at a time, and close it before you open another. If you run into a problem, try lowering the value of the pullup resistor. The Arduino configures the bus with internal 10Kohm pullups. Do this until you have them all operational. If you run onto a problem, let us know what you have done and what the symptoms are.
Regards,
Keith
 
Top