I2C connections on Mega board - usage

All, I have a Mega that has two each of the SCL and SDA connections. If I want to use an LCD module with a PCF8574 module with an address of 0x27 and an OLED with an address of 0x3c, connecting each one to a different SDA / SCL pin, as they are different types of module do I have to add any additional identifier to show which is which, or will the callouts below be sufficient?

LiquidCrystal_PCF8574 lcd(0x27);
if(!oled.display.begin(SSD1306_SWITCHCAPVCC, 0x3C))

Cheers

Les

The I2C addresses will distinguish the displays.

edited because I hadn't finishd writing!*

Thanks, I imagined that it would be the case, thanks for confirming

One of the reasons I ask is that I connected one devise to one set of the SCL / DSA pins, and the other to the remaining pair. It appears to be that only one set of pins is functioning because one or the other device does not work dependant on which pins you connected to. The ones that seem to work are pins 20 and 21, should all I2C devices be connected through these pins?

Cheers

Les

The SDA pin at 20 and the SDA by Aref are physically connected together as are the SCL at pin 21 and the SCL by Aref. Something else is going on.

Again, that's what I thought, the I2C connections are parallel from what I understood and the pins assigned by the I2C protocol

First step has to be to check my wiring, but not too much that can go wrong with two wires....

Thanks again for the assistance

Les

I wish that I had any suggestions aside from check your wiring but after wracking my brain have none.

I was thinking that I could make a rail from the two working pins and see if that works just for troubleshooting (after checking my wiring of course), it is possible I have a duff Mega pin

Cheers

Les

That is a great idea. You could also connect a LED (with resistor) to the "extra" I2C pins and run the blink example with the output pins set to 20 and 21.

I have it all working correctly and can only assume that I had a poor contact or something like that as I did all my troubleshooting of the wires and so forth, and I couldn't find anything wrong. Just to be sure I took it all down to components then reassembled it and it works fine.

Thanks for the assistance

Les

Glad that you got it working. And thanks for reporting the cause. So many do not bother. May help others. Karma to you.

Lesthegringo:
I have it all working correctly and can only assume that I had a poor contact or something like that

Well, I daresay we knew that! :grinning:

Using "Dupont" or these jumper wires?

You must test them all before you use them! :astonished: "Cheap" Chinese stuff.

Wire them all zig-zag across a breadboard so that they are all in series with a 5 V supply, resistor and LED. If it does not light, divide the chain in half repeatedly until you find the problem.

Definitely not those horrible jumper wire things! I do have some that I used for fast testing, but they have no place in any project beyond that.

The headers I use once I have sorted out how the wiring should be are (if possible) the JST-XH type which for what I have go up to five connections, but if not the standard 0.1" header pin and female connector crimp pins in those plastic multiple housings. I have a couple of expensive and good quality crimping tools so that I can make the terminations myself and generally have good success with them. I also bought off ebay some pre-made multi connector ribbon type cables with the 0.1" connections on them and use those, suitably modified to make my connections.

With Arduino nanos, they mainly come without the header pins installed, which gives me the option of a) which way I want to put the connection on and b) whether I use header pins or female header connections. As a result very often I can have a pre-wired cable with connectly spaced pins made for stuff like connecting OLEDS, PCF8574 boards, LCD modules, MAX7219 modules, stepper motor drivers etc.

I also try and make PCB's to mount the components on, like for example a board for X27-68 stepper motors with 0.1" female headers for an A4988 stepper driver, then use a couple of JST-XH connectors to make keyed connector cables for the Arduino connection and 12v supply, so that I can't physically mis-connect them once done.

In contrast the Mega comes with female 0.1" connectors, and while once I have established what is to connect to where I make a pcb shield with mating 0.1" headers so that I can then use good solid connectors on the other side that have easily identifiable connections. So for instance, all my stepper motor outputs have four pin JST-XH connectors, with the GND, 5v, DIR and STEP connections in a preset order so that I can easily connect it and make a 'standard' cable.

However while I am still developing the project I am stuck with having to use those nasty Dupont crimp connectors that have a pin to fit into the female headers on the Mega. I have the pins and make the terminations myself and they are definitely better than the jumper wires in the picture above, especially as you can set them in the multi pin plastic connector housings. But, as this has shown, even when you have a 'good' cable, if the contact of those pins to the Mega isn't great, you end up chasing problems. Also with time reuse breaks the wires internally or at the junction to the crimped part of the connector, especially with cables with a specific function like the Max7219 case a few days ago.

The fact remains that properly done the Dupont connectors can make good wiring, but as you can see they can also (especially the male pin crimp terminations) give problems that can lead you a dance.

I toyed with the idea of buying one of those pre-made Mega sensor shields but the pin layout is very poor for my purposes, plus getting stuff delivered here to Hungary is fraught - two weeks ago I received an item that I ordered on January 20th....

So guaranteed I'll have further issues, and will have to be thorough with the troubleshooting, but nonetheless asking stuff on this forum has given me information on the stuff I'm trying to get working, even if the fault at the time was due to physical wiring.

Which is why I'm always grateful for the help!

Cheers

Les