Arduino Nano i2c Troubleshooting

Hello all,

For the past few days i have been hitting my head against the wall because i cant get my nano to see the EEPROM I got (the 24LC512).

I have the SDA going to A4 and SCL going to A5. I am using 4.7k pull-up resistors as i have seen mentioned elsewhere.

I have Address pins A0, A1, and A2 all set to ground.

Beginning to think somethings up. I am using the usual i2c scanner found around the net, but with one arduino im getting error code 2’s (suggesting wire issues), or error code 4’s (suggesting who knows what the hell it could be).

#include <Wire.h>
 
void setup()
{
  Wire.begin();
 
  Serial.begin(9600);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}
 
 
void loop()
{
  byte error, address;
  int nDevices;
 
  Serial.println("Scanning...");
 
  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
 
    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");
 
      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");
 
  delay(5000);           // wait 5 seconds for next scan
}

Here is as pic of its current iteration. If anyone has run across this before, or notice some bone-headed thing i did wrong, i would greatly appreciate the assistance.

Stupid question, but we can’t see from the picture, are the right power buses of your breadboard connected to power?

1 Like

They are, and i have tested that the breadboard is not the one that breaks in the middle. I checked with voltmeter, that rail’s got power.

Have you run the I2c scan sketch to confirm its address on the bus?

Couple of random mutations that’ll probably not change anything, but may provide clues if they do:

  • Try different pullups (e.g. 2k2, 10k)
  • Try different slave addesses (move one or more address pins to Vcc)
1 Like

Yes, I find nothing. I appreciate the assistance y’all.

As I’m not familiar with the Wire library or i2c I can only ask whether the choice of 1 rather than 0 for the loop initialiser is deliberate. Is there a reason not to scan channel 0?

You know, I wondered that myself since that’s a valid address and my pinout would effectively be 0x00. I got this sketch from the net for troubleshooting, and my other nano absolutely didn’t respond to that address. Might try on this new board though. It is entirely possible my other board got fried and I didn’t check that address on this new one. Will check after work.

A change of strategy may be helpful. For instance try downloading this EEPROM library and see if using it brings more enlightenment. The author lists your EEPROM as one of the target devices.

Thanks, but the problem is being unable to connect with i2c, it’s got to be something hardware related. I’m not even using the protocol to do anything with the chip yet, and that part seems easy to me.

When you use the Wire.beginTransmission() method it returns an error code. On one of my nanos, I get a 2, and the other freshly opened one gives me a 4.

Won’t be able to check until I get home, but I’ll check address 0x00 and hope the first one I checked with was dead.

1 Like

Slave addresses 0-7 and 120-127 are reserved; from the spec:

image

(but iiuc the chip only looks at the bottom three bits, so if things are working it should appear at 8, 16, 24, etc) nope, see below.

1 Like

Fredrick, where are you seeing this? My documentation says the control byte should be the following for chip addressing:
control code: 1010
Chip select bits: xxx
R/w bit: x

Source: https://www.google.com/url?sa=t&source=web&rct=j&url=http://ww1.microchip.com/downloads/en/devicedoc/21754m.pdf&ved=2ahUKEwiDoaf49LrnAhXJl-AKHbTODFkQFjABegQIBhAI&usg=AOvVaw3oPAmCzhv4K-uOjh5vzn4T

Sorry for ugly, doing from phone. Regardless though, nothing is responding so it’s got to be something about my setup that is preventing communication. The error codes I received are likely timeouts attempting to ack.

Oh crap guys I thought of another possibility. I’m thinking there might be some issues with how I’m powering this. I’ve got it hooked up to my keyboard’s USB connector. I remember my phone wouldnt consistently charge on that thing just now. One more thing to check!

Oops, I stopped reading after “The A0, A1 and A2 inputs are used by the 24XX512 for multiple device operations. The logic levels on these inputs are compared with the corresponding bits in the slave address. The chip is selected if the compare is true.” in section 2 :stuck_out_tongue_winking_eye: but you’re right, they spell out all the bits in section 5.

So one more random thing to try would be to scan only 80-87, in case things get out of sync by the earlier traffic.

And yeah, try a different power supply or two.

1 Like

God I hope it’s just something stupid I did. At least that’s easier to fix.

WELP. Guess what, it WAS something stupid.

I moved everything to a different breadboard. It worked IMMEDIATELY. I think some contacts were messed up or something.

Off I go to program this thing. Thanks for the help @fredrik @Bitnik @Maxhirez @antoine.pasde2.

Moral of the story is to:

  1. Check hardware first. Connections as well as the board itself. Take nothing for granted. Trust nothing.
  2. Buy better breadboards. :frowning:

image

1 Like

Yeah, you can go through breadboards like toilet paper if you screw up as much as I do. Luckily they’re getting cheaper. My first one I’ve had for probably 3 ½ decades, but with different pin sizes you can warp the conduction channels pretty quickly after you break them in. And then there’s always this little gem!:


Yeah, I know. I’ll throw it away as soon as the next Tayda order comes in.

3 Likes

Did something get a little toasty???

Rob

I dont see what the big deal, sees the giant melty part HOLY CRAP.

Also, having bought the tayda breadboard, it’s the type to have those splits in the power / ground bus. They are poo poo quality, but i will say they arnt the ones that gave me the issue, it was the cheapo amazon ones. So i would say for a cheap breadboard, they both are nearly equally poo poo. the only advantage the amazon one had was better alignment with the numbers etc. I dont even use that though.

Truly, if one plans to proto on breadboard, i dont think you can go cheap as much as my frugal heart weeps at the concept.

You know I think I remember that from the Tayda ones-especially the 800+ hole versions. I couldn’t figure out why a simple circuit wasn’t working until I pinned out the rails and checked continuity. Hopefully the 200-400 point “disposables” check out, but I thanks for the reminder @Caustic!

1 Like