EEPROM I²C returning strange values

Hi all :slight_smile:

I’m trying to write data and getting them back in the EEPROM AT24C16 using I²C bus and an Arduino Uno.

I’m currently trying to write “Hello” and I should read “Hello” on the serial monitor but instead i get “72101108108111”. :frowning:

Maybe I’m not reading data from the good place in the EEPROM.

Enclosed is my code, adapted from code of the example.

Thanks for any help :slight_smile:

MonCodeEEPROM.ino (912 Bytes)

Or if you prefer, here is my code :slight_smile:

#include <Wire.h>

void setup() {
  // put your setup code here, to run once:
  Wire.begin();
  Serial.begin(9600);

  //step 1 : send something to the eeprom
  Wire.beginTransmission(0x50); //transmit to device #80 (0x50)
  Wire.write(0); //set register pointer to the command register (0x00)
  Wire.write("Hello"); //send 5 data bytes
  Wire.endTransmission();//stop transmitting

  //step2 : wait for readings to happen
  delay(70);

  
   Wire.beginTransmission(0x50); //transmit to device #80 (0x50)
   Wire.write(0);
   Wire.endTransmission();
  
  //request reading from sensor
  Wire.requestFrom(0x50, 5);    // request 5 bytes from slave device #80
  
  while(Wire.available())
  {
    byte c = Wire.read();
    Serial.print(c); // print the character
  }
  Serial.println();
  
}

void loop() {
  // put your main code here, to run repeatedly:

}
    byte c = Wire.read();
    Serial.print(c); // print the character

Change byte to char. Now it is printing the ASCII code of each character.

Thank you it works perfectly :smiley: