I2C 24LC246 + Arduino Wire.read() returns -1 ??

Hello all,

I am trying to write and read to a 24LC256 eeprom with my Arudino Uno.

I don't know if I'm not properly writing to the 24LC256, or if I am not properly reading the information.

I found this write up on youtube: - YouTube

It seems to be working, except it is returning -1 for the value read from the chip.

I have tried researching it and couldn't find what the -1 is meaning.

Below is the code, along with a screen shot of the Serial output.

Any help would be greatly appreciated.

Thank you
n8er``

#include <Wire.h>
int data = 0;
byte high = 0x00, low=0x00;

void setup(void){
 Wire.begin();
 Serial.begin(9600);
 Serial.println("Serial Connection Made.");
}

void loop(){
 Wire.beginTransmission(0x50);
 Wire.write(high);
 Wire.write(low);
 Wire.write('H');
 Wire.endTransmission();
 delay(5);

 Wire.beginTransmission(0x50);
 Wire.write(high);
 Wire.write(low);
 Wire.endTransmission();
 Wire.requestFrom(0x50,1);
 delay(5);
   
 Serial.print(Wire.read());
 Serial.print(" Address    ");
 Serial.print(high);
 Serial.print("     ");
 Serial.println(low);
 
 data++;
 
 if(data > 255) data=0;
 
 if(low == 255) high++;
 
 low++;
 
 
 }

I have tried researching it and couldn't find what the -1 is meaning.

links to

where read() links to

which says:

Returns

the first byte of incoming data available (or -1 if no data is available)

Show us the wiring you used. The chip has a configurable address, if not wired properly you might not get any useful data out of it.

Thank you for your replies plyon and PaulS.

I rewired it with color coordinated wires for a better pictures and I said, why not try it quick, maybe it was a loose connection. Sure enough, after swapping out all of the wiring it works. :slight_smile:

The breadboard I have is junk.

Thank you very much and have a great day.