LikesAChallenge
Posts: 32
Joined: Fri Dec 05, 2014 3:39 pm

Fixed I2C address - best solution for third sensor

Wed Dec 10, 2014 9:15 pm

Guys,

I've got three AM2315 sensors and I'm using both I2C channels on my B+ RPi but that leaves me one short!

I'd like to know how I should go about adding a third that is the easiest and probably most important - reliable.

I've googled for address translators with not much success. So I thought I could use a solid state relay via one of the GPIOs to switch from sensor to sensor electrically switching the SDA and/or the SCL wire.

Is there a better way of achieving this?

User avatar
Douglas6
Posts: 4904
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Fixed I2C address - best solution for third sensor

Wed Dec 10, 2014 11:41 pm

You could try an I2C bus hub like the NXP PCA9516A. Never used one myself, perhaps someone here has. Looks like it only comes in surface mount packages.

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Fixed I2C address - best solution for third sensor

Thu Dec 11, 2014 2:16 am

I have used these PCA9544A boards to expand an I2C bus. Very easy to use.

http://www.dsscircuits.com/sale/product/dssc0107
$6.50 ea
Image
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

danjperron
Posts: 3511
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Fixed I2C address - best solution for third sensor

Thu Dec 11, 2014 2:34 am

It is possible to connect up to four I2C devices ,with the same I2C address, using a 74hc4052.

A 74HC4052 is a CMOS switch multiplexer. You just need to select the correct sensor by adding GPIO into the A&B selection pins. Each of the sensors will need pull up resistor because they will disconnect when not select.

In theory you could have up to 8 sensors with two I2C ports.

Daniel

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Fixed I2C address - best solution for third sensor

Thu Dec 11, 2014 2:35 pm

Why would you want to go to all that grief with a logic chip? I am not saying that it won't work, but why move the control functions of the I2C bus off of the I2C bus? It is like driving a stick shift car where the passenger does all the shifting of gears.

I think what you fail to also see is the possibility of having 8 PCA9544 chips per bus. Now you can have 32 single address devices on a bus. It also does level conversion and more. The pass gates of the multiplexer are constructed such that the VDD pin can be used to limit the maximum high voltage which will be passed by the PCA9544A. This allows the use of different bus voltages on each SCx/SDx pair, so that 1.8 V, 2.5 V or 3.3 V parts can communicate with 5 V parts without any additional protection.

Do what you want but if it were me, I would use the PCA9544a.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

danjperron
Posts: 3511
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Fixed I2C address - best solution for third sensor

Thu Dec 11, 2014 9:44 pm

Of course if I have a PCA9544 board already in my collection this is the I.C. I will used. But right now I don't.

So what do I do.

Order the parts , wait 2 weeks for cheap delivery or find another method.

So my point is to give another possible method.

An I.C. (74hc...) could be delivered the next day or easilly found at an electronic store .

A shield with PCA9544 won't be! Unless you pay for next day delivery .$$$

It's always good to figure out other way.

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Fixed I2C address - best solution for third sensor

Fri Dec 12, 2014 2:08 am

I believe in most cases you get exactly what you pay for. This may be one of them.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

LikesAChallenge
Posts: 32
Joined: Fri Dec 05, 2014 3:39 pm

Re: Fixed I2C address - best solution for third sensor

Sat Dec 13, 2014 10:18 am

I've ordered two of the http://www.dsscircuits.com/sale/product/dssc0107 and the 74HC4052 to mess about with both.

Cheers.

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Fixed I2C address - best solution for third sensor

Sun Dec 14, 2014 6:45 am

Let us know how each works out.

With the two boards from DSS, you should be able to address 8 devices.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

LikesAChallenge
Posts: 32
Joined: Fri Dec 05, 2014 3:39 pm

Re: Fixed I2C address - best solution for third sensor

Thu Dec 25, 2014 12:37 pm

I've just received the PCA9544A but I'm unsure the best way to wire all this up is, would the following be suitable?

Image

I've made all the multiplexer and sensors run off the 5V line, only pulling the 5V to 3.3V when entering the RPI.


This is the multiplexers datasheet: http://dsscircuits.com/images/datasheets/PCA9544A.pdf

Not too sure what I need to do with the interrupts, not sure if the AM2315 is open-drain or totem or if it even matters.

Thoughts?

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Fixed I2C address - best solution for third sensor

Thu Dec 25, 2014 1:49 pm

Since you never indicated that you wanted to do interrupt processing, the interrupt lines can be ignored so leave them open, do not tie them high. The int line (active low) is an output of the chip, not an input. If you want to do interrupt processing, then configure each chip for open drain and then then connect to a GPIO input pin. You will have to add some lever conversion so that the Rpi GPIO pin never sees anything higher than 3 volts. I think interrupt processing is pointless as the temp/humidity devices does not have that feature.



Why do you have 10k rtesistors is series with the SDA and SCL lines? Remove those. Add 10k pull ups from the scl and sda lines from the raspberry to +3 volts.

You are missing some 4.7k - 10k pullups at each of the devices.

Other than that it looks good to me.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Fixed I2C address - best solution for third sensor

Thu Dec 25, 2014 2:25 pm

here is a corrected schematic
Attachments
multiplex.JPG
multiplex.JPG (51.45 KiB) Viewed 3911 times
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

User avatar
ilguargua
Posts: 73
Joined: Thu Jun 19, 2014 8:14 pm
Location: Livorno - Italy

Re: Fixed I2C address - best solution for third sensor

Thu Dec 25, 2014 6:49 pm

Raspy already has two 1.8 K pullup resistors on SDA/SCL lines, so the two 10 K resistor could be omitted .

Merry Christmas, Ale.

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Fixed I2C address - best solution for third sensor

Thu Dec 25, 2014 8:41 pm

ilguargua wrote:Raspy already has two 1.8 K pullup resistors on SDA/SCL lines, so the two 10 K resistor could be omitted .

Merry Christmas, Ale.
I always add 10 k pullups at the i2c devices. Adafruit does the same thing and other engineers do as well.

You do what you want.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

User avatar
jeanleflambeur
Posts: 157
Joined: Mon Jun 16, 2014 6:07 am
Contact: Website

Re: Fixed I2C address - best solution for third sensor

Thu Dec 25, 2014 8:56 pm

Another solution would be bit banging i2c on any other pair of GPIOs. There is a module already for this but you'd need to recompile the kernel to enable it. Check here: http://www.raspberrypi.org/forums/viewt ... 44&t=27227

You could also try this - http://www.raspberrypi.org/forums/viewt ... 44&t=94775

LikesAChallenge
Posts: 32
Joined: Fri Dec 05, 2014 3:39 pm

Re: Fixed I2C address - best solution for third sensor

Thu Dec 25, 2014 9:20 pm

Richard-TX wrote:
ilguargua wrote:Raspy already has two 1.8 K pullup resistors on SDA/SCL lines, so the two 10 K resistor could be omitted .

Merry Christmas, Ale.
I always add 10 k pullups at the i2c devices. Adafruit does the same thing and other engineers do as well.

You do what you want.
They currently have 10K Ohm and it works, but will my above circuit work, or perhaps, not break anything!?

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Fixed I2C address - best solution for third sensor

Fri Dec 26, 2014 9:21 am

LikesAChallenge wrote:
Richard-TX wrote:
ilguargua wrote:Raspy already has two 1.8 K pullup resistors on SDA/SCL lines, so the two 10 K resistor could be omitted .

Merry Christmas, Ale.
I always add 10 k pullups at the i2c devices. Adafruit does the same thing and other engineers do as well.

You do what you want.
They currently have 10K Ohm and it works, but will my above circuit work, or perhaps, not break anything!?
I posted a corrected diagram. If you follow it, you will be in good shape. If you use your original circuit, you are on your own. It likely won't work and you could wind up damaging some hardware.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

LikesAChallenge
Posts: 32
Joined: Fri Dec 05, 2014 3:39 pm

Re: Fixed I2C address - best solution for third sensor

Fri Dec 26, 2014 11:04 pm

Richard-TX wrote:
I posted a corrected diagram. If you follow it, you will be in good shape. If you use your original circuit, you are on your own. It likely won't work and you could wind up damaging some hardware.
Hi,

Thanks. For some reason when I first viewed your reply the diagram wasn't shown.

I'll get the soldering iron out tomorrow and give it a go :)

One curiosity though, why apply 10k ohm from 3.3 to SDA/SCL when on the sensor side we are applying 10k to 5v? Could we just not use 5v supply for it all?

E.g. Image

Also second Q, in the spec it says "The interrupt inputs should not be left floating.", given that I don't want to use that, I assume it doesn't matter?

User avatar
Burngate
Posts: 6334
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Fixed I2C address - best solution for third sensor

Sat Dec 27, 2014 12:30 pm

LikesAChallenge wrote:One curiosity though, why apply 10k ohm from 3.3 to SDA/SCL when on the sensor side we are applying 10k to 5v? Could we just not use 5v supply for it all?
The Pi bus is separate from the sensor busses and needs to be treated separately. The sensors can handle 5v; The Pi can't.
multiplex.png
multiplex.png (25.34 KiB) Viewed 3681 times
wiring_diagram_V2.png
wiring_diagram_V2.png (19.38 KiB) Viewed 3681 times
In your diagram, 5v will be applied to the GPIOs, which they're not designed to take. You may get away with it, since 10k is a lot higher than the 1k8 on the board, but it's not a good idea.

My personal opinion is that those 10k pull-ups are only necessary for long lines at high speed, but Richard may have a different view.
LikesAChallenge wrote:Also second Q, in the spec it says "The interrupt inputs should not be left floating.", given that I don't want to use that, I assume it doesn't matter?
If it says "should not" I wouldn't do it.
It could be that only the interrupt circuit inside the chip will destroy itself, but can you guarantee the destruction won't spread?
As you've already purchased some 10k resistors, some more to pull those inputs high is no great cost.
I notice Richard has marked those as outputs. This might be one of the very few occasions where he's in error.

darryletter
Posts: 76
Joined: Thu Jan 01, 2015 8:52 pm
Location: KC,MO

Re: Fixed I2C address - best solution for third sensor

Thu Jan 01, 2015 11:37 pm

Richard-TX wrote:I have used these PCA9544A boards to expand an I2C bus. Very easy to use.

http://www.dsscircuits.com/sale/product/dssc0107
$6.50 ea
Image
i would like to try this one out but the company is out of stock with no comtact info or expected date
Life After 60 sucks

LikesAChallenge
Posts: 32
Joined: Fri Dec 05, 2014 3:39 pm

Re: Fixed I2C address - best solution for third sensor

Fri Jan 02, 2015 5:47 pm

Well I've got it working perfectly now with that PCA9544A board.

I didn't need to tie the interrupts to anything and it seems to be working A-OK for the last 72 hours...

Now I just need to figure out the best way of getting a PWM 10V from the Pi. Probably going to be a transistor/capacitor combo.

darryletter
Posts: 76
Joined: Thu Jan 01, 2015 8:52 pm
Location: KC,MO

Re: Fixed I2C address - best solution for third sensor

Sun Jan 04, 2015 12:34 am

LikesAChallenge wrote:Well I've got it working perfectly now with that PCA9544A board.

I didn't need to tie the interrupts to anything and it seems to be working A-OK for the last 72 hours...

Now I just need to figure out the best way of getting a PWM 10V from the Pi. Probably going to be a transistor/capacitor combo.
could you please post the final wire up i am tring to do the same thing
Life After 60 sucks

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Fixed I2C address - best solution for third sensor

Mon Jan 05, 2015 3:27 pm

darryletter wrote:
Richard-TX wrote:I have used these PCA9544A boards to expand an I2C bus. Very easy to use.

http://www.dsscircuits.com/sale/product/dssc0107
$6.50 ea
Image
i would like to try this one out but the company is out of stock with no comtact info or expected date
I just checked and it appears that he now has a few in stock.

Enjoy.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

darryletter
Posts: 76
Joined: Thu Jan 01, 2015 8:52 pm
Location: KC,MO

Re: Fixed I2C address - best solution for third sensor

Mon Jan 05, 2015 5:01 pm

Richard-TX wrote:
darryletter wrote:
Richard-TX wrote:I have used these PCA9544A boards to expand an I2C bus. Very easy to use.

http://www.dsscircuits.com/sale/product/dssc0107
$6.50 ea
Image
i would like to try this one out but the company is out of stock with no comtact info or expected date
I just checked and it appears that he now has a few in stock.

Enjoy.
got 2 on the way would sure like to see that final wire wire up though so i don't end up burning one or my rpi up do you happen to know how he did it to get it to work right
Life After 60 sucks

darryletter
Posts: 76
Joined: Thu Jan 01, 2015 8:52 pm
Location: KC,MO

Re: Fixed I2C address - best solution for third sensor

Thu Jan 08, 2015 12:20 am

got both of them today not sure of best way to hook them up. should i use wire or header blocks
Life After 60 sucks

Return to “Interfacing (DSI, CSI, I2C, etc.)”