Jump to content

I2C replication

adithyay328

Hi there! So, I'm using the Arduino UNO and a couple sensors which use I2C, but the UNO only has 1 set of I2C port for use. Now, I was wondering if I could use code to have 2 digital I/O pins replicate an I2C port. Is that possible? Thanks!

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, rhyseyness said:

Why do you need 2 I2C busses?

Addressing means you only need one surely?

I'm assuming that the UNO is your master device?

1 minute ago, rhyseyness said:

Why do you need 2 I2C busses?

Addressing means you only need one surely?

I'm assuming that the UNO is your master device?

 
 

Yes, what I meant is that I need 2 I2C sets of ports(data and clock), and I don't have those, so what should I do?

 
Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, rhyseyness said:

So if I understand correctly, you need 2 I2C busses (4 lines total)?

My question is why do you need this?

What's your application?

 
 

Ok, so I have 1 UNO, and multiple sensors to connect, and a 3 use I2C. Now, the UNO only support I2C on 2  of the ports(clock and data), so how can I connect all of my sensors?

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, adithyay328 said:

Ok, so I have 1 UNO, and multiple sensors to connect, and a 3 use I2C. Now, the UNO only support I2C on 2  of the ports(clock and data), so how can I connect both of my sensors?

Don't you address your sensors individually, all connected to the same ports?

I.e. clock and data come from your UNO, go to all your sensors, from the same 2 lines, and then you use addressing to decide which sensor you want to read from

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, rhyseyness said:

Don't you address your sensors individually, all connected to the same ports?

I.e. clock and data come from your UNO, go to all your sensors, from the same 2 lines, and then you use addressing to decide which sensor you want to read from

 

Wait, what? I have never heard this before. Does it? I think that you have to use different ports for each 1, but, um...

Link to comment
Share on other sites

Link to post
Share on other sites

8 hours ago, adithyay328 said:

Wait, what? I have never heard this before. Does it? I think that you have to use different ports for each 1, but, um...

I2c allows daisychaining

so yes you only need two ports for up to 63 ( I think it's pretty big, 63 is a guess ) different things

Recommend what is best, not what you preffer.

"Like" comments to show your support of them or the idea they express.

Link to comment
Share on other sites

Link to post
Share on other sites

Usually there are spare pinns on the sensor to set an adress, so you can connect all sensors to the same I2C bus.

Howeven I run into the situatio that I had to use 12 battery controntrollers and they had a static adress so I needed 12 isolated busses. I just used to one bus provided by the CPU and added a analoge switch matrix (costs about 3$). It worked, but I didn't really liked the solution. But there wasn't a better one.

Also you can use normal IO pinns if they feature try state and use software. But the protocol is very complicated and takes days to get it rigth.

Mineral oil and 40 kg aluminium heat sinks are a perfect combination: 73 cores and a Titan X, Twenty Thousand Leagues Under the Oil

Link to comment
Share on other sites

Link to post
Share on other sites

I2C works by setting one device as the master (in this case it should be the UNO) and then multiple Slave devices. The arduino allows up to 127 different addresses to be set with the Wire Library. So you should be able to attach all of the devices to the two I2C pins and then assign them different addresses. 

There shouldn't be any needed to run them from GPIO pins but you could probably read the data from the sensors (depending on which type they are). I've managed to run a RTC, wireless module and 7 servos from the I2C pins on an Uno so I dont think there should be an issue with it. 

Link to comment
Share on other sites

Link to post
Share on other sites

On 4/29/2016 at 1:06 PM, Mihemine said:

I2c allows daisychaining

so yes you only need two ports for up to 63 ( I think it's pretty big, 63 is a guess ) different things

I believe it is around 100.

May Our Framerates Be High And Our Temperatures Be Low.

PSUs: EVGA B2/G2/GQ/GS, Corsair RMx/i, Grey-Label CXM, Everything Seasonic/Delta/Super Flower, XFX except XT

Use pcpartpicker.com

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×