Yes, if it's the ZS-042 module shown in jim-p's picture, it has the AT24C32 4K EEPROM chip on it, at address 0x57. The AT24Cxx.h library would be the one to use. See the examples in that library.
Hmmm, is this code correct to write then read 16 bytes to and from the EEPROM?
/*
* EEPROM Write test
*/
#include <AT24Cxx.h>
#define i2c_address 0x57
/** the current address in the EEPROM (i.e. which byte we're going to write to next) **/
AT24Cxx eep(i2c_address, 32);
void setup() {
Serial.begin(9600); // initialize serial and wait for port to open:
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
}
void loop() {
for (int i = 0 ; i < 16 ; ++i) {
eep.write(i, i*2);
}
for (int i = 0 ; i < 16 ; ++i) {
int iVal = eep.read(i);
Serial.print("at ");
Serial.print(i);
Serial.print(" read ");
Serial.println(iVal);
}
delay(5000);
}
Because the results are not encouraging...
at 0 read 30
at 1 read 30
at 2 read 30
at 3 read 30
at 4 read 30
at 5 read 30
at 6 read 30
at 7 read 30
at 8 read 30
at 9 read 30
at 10 read 30
at 11 read 30
at 12 read 30
at 13 read 30
at 14 read 30
at 15 read 30
Is there an error in my code. The manual from AZ_Delivery says 0x57 as well.
With any new device library, start by carefully reading the library documentation and verifying that the library examples work as expected.
It has been a long time since I've used one of those EEProms, but there are timing restrictions on the write operation. If those are not built into the library, they have to be built into your code.
So, I would not expect this to work, without first checking:
for (int i = 0 ; i < 16 ; ++i) {
eep.write(i, i*2);
}