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.
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.
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
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 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.
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!:
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!