Hello, please, I have a problem regarding writing to a DS2431 EEPROM using the OneWire protocol and Arduino libraries. I think it’s a synchronization issue, because the write function sometimes works well, but most of the time, I can't write to the memory slot. I've tried adjusting the delay, but it doesn't work. I also use a 4.7k pull-up resistor. My circuit is correct, but I still have a writing problem. Please, can you help me?
#include <DS2431.h>
#include <OneWire.h>
#define Max_DEVICES 1
const int ONE_WIRE_PIN_1 = 9;
OneWire oneWire1(ONE_WIRE_PIN_1);
DS2431 eeprom1(oneWire1);
word address3 = 0;
void setup() {
Serial.begin(9600);
while (!Serial); // Attendre que la console série soit prête
byte CycleCharge[] = {25,2};
eeprom1.write(address3, CycleCharge, sizeof(CycleCharge));
delay(7000);
byte NbCycleChargeR[2];
eeprom1.read(address3, NbCycleChargeR, sizeof(NbCycleChargeR));
//Serial.println("Charge Cycle avant : ");
printBuffer(NbCycleChargeR, sizeof(NbCycleChargeR));
// Vérifier si l'écriture a réussi
if (NbCycleChargeR[0] != CycleCharge[0]) {
Serial.println("Erreur d'écriture !");
}
}
void loop() {}
void printBuffer(const uint8_t *buf, uint8_t len)
{
for (int i = 0; i < len-1; i++)
{
//Serial.print(buf[i], HEX);
Serial.print(buf[i]);
// Serial.print(",");
}
Serial.println(buf[len-1]);
}```