I am using 24lc512 and 24lc16 eeprom. Is there is any way to find the memory capacity of EEPROM by sending command on i2c?. Actually, I use these is according to requirement. so I want microcontroller automatically find which is connected on i2c. Presently I am thinking to write a byte on 2500 location of eeprom. If it is 64kb memory then the byte is written correctly otherwise if respond with 0XFF and then try to write using the function for 24lc16 (it require page and address, this is a separate function). If the value is written then I use the function for 16kb read/write. I try this on every power up.
edit: Moved because it was not a tutorial and fixed the title for a clearer meaning. Moderator.