I2c Not working unless PC's connected?

Hey everyone!

So I have a weird issue... I basically have built a launchpad with an Arduino Nano and a controller with the same that connects to it via I2c and it works great however, for some reason it will only work if both Nanos are connected to a computer through USB?

Without the controller running USB even though it's battery-powered will not work at all? It still registers the signal etc as I have feedback of that from an LED.

Any help will be appreciated thanks!

Can you tell more about the wiring ?

The I2C bus has three wires: SDA, SCL, GND. Did you connect the GNDs ?
Are there long wires between the Arduino and the controller. The I2C is not meant to go into a cable.

If the I2C bus is not the problem, then perhaps how everything is powered or the grounding is a problem.

Can you make a drawing that shows the wires, the battery, the distances and so on ?

Can you show your sketch, perhaps you should check with every Wire.endTransmission() and every Wire.requestFrom() if you are actually communicating with the controller.

What is the controller ? Do you have a schematic ?

Hey there cheers for replying!

So I didn't realise this, do I literally just have to run a ground between them? I didn't know if it had to connect them both together with it or just have to have the obvious ground connection anyway, I didn't think it was a problem just because it worked if you get me.

Also, they are short cables about 25cm and don't seem to be a problem when it is connected to the PCs.

Sorry, I don't have a diagram yet I will try and get one tomorrow!

And the controller is just another Arduino Nano, sorry I didn't state that properly above! It's basically just sending a number if it switches number it changes state so really simple in that aspect.

Hope this info helps for now thanks for replying so fast!

The I2C bus is not that kind of bus. They are two different logic level signals that only exist when there is a GND.

Can you show the sketch of the Master and the Slave ?

If the cable is flat ribbon cable (or an other cable) and SDA is next to SCL, then 25cm is already too long. The I2C bus can not handle crosstalk between SDA and SCL.

I forgot to ask if you have pullup resistors ?

1 Like

Okay, I understand but if it's working when they are plugged into a PC surely they are talking correctly right?

And I will do a diagram today for you I am just in the process of it now. and no I haven't got pull up resistors. I knew I should add them but space is a big problem on the boards as they are packed. I tried it without them and it worked so I am here now with that other issue I presume this is the cause but its the fact they work when connected that baffles me!

Thanks!

The internal pullup resistors are 30k or 50k or so. Even if they are in each Arduino board, then it is still a high value. Can you add 4k7 pullup resistors at the Master ?

When SDA or SCL are low, then a Arduino board pulls that signal strong to GND.
When SDA or SCL are high, then the resistor keeps the signal high. That means the high level is vulnerable for noise.

You can draw something on a piece of paper and make a photo of it.

Sorry I am terrible at drawing haha.

Hope this makes sense! please let me know what else you need!

Yes I think there is room am I just attaching them both to a Gnd rail on my board?

Here are the links to the photos: https://drive.google.com/drive/folders/1EtzoyoXJVMZ8Kd7lsISMsTeBwJHw6scW?usp=sharing

It wouldn't let me upload them direct because I am a new user.

A few pixels, only 206 pixel height ?
What are the green and yellow wire ? I hope those are not SDA and SCL. The SDA and SCL have no meaning without GND.

Not sure why they are that size but yes they are SDA and SCL, and if it has no meaning why is it working when they are connected through USB?

That is the wrong question. Actually, I don't care :yawning_face:
The I2C bus must have a GND.

@nathanielevans I don't know the details, but it's probably the case that when both Nanos are connected to the PC, their grounds are connected together via their USB leads and the PC.

When you unplug one or both from the PC, their grounds are no longer connected together. Just try connecting the two grounds together with a piece of wire, and then we'll know.

1 Like

Yeah, I thought this could be the case, Thanks for actually giving me some info I could use unlike that other guy haha.

I will try this today and get back to you! Thanks

It works! Thanks for the tip. What shall I do from here, I reckon I try to add those pull up resistors and see how long I can run these cables?

Hi, I made this picture a few days ago: Arduino hangs whit I2C-LCD when NOT printing Serial messages - #21 by Koepel

The I2C bus can not handle crosstalk between SDA and SCL. Keep those away from each other. The SDA and SCL can be close (or even paired with) a GND wire. That will give extra capacitance, but that is less of a problem. The pullup resistors can be lowered and the bus speed can be lowered when the capacitance gets too large.

There is a official I2C document UM10204 shows on page 60 to keep SDA away from SCL.

And then there is my wiki, where I collect the I2C things.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.