I am trying to use an EEPROM DS2431 with my arduino nano 33 BLE.
I have put it on the D3 pin, with a 4.7k pull up resistor.
I am using the DS2431 Library for arduino and the OneWire library.
I have read that the OneWire Library has no support for nano 33 BLE, I think this is why with the example code I have a No DS2431 found on the 1-Wire bus.
message.
Here is the example code :
#include <DS2431.h>
#include <OneWire.h>
const int ONE_WIRE_PIN = 3; // One Wire pin, change according to your needs. A 4.7k pull up resistor is needed.
OneWire oneWire(ONE_WIRE_PIN);
DS2431 eeprom(oneWire);
void setup()
{
Serial.begin(9600);
while (!Serial); // wait for Serial to come up on USB boards
// Search the 1-Wire bus for a connected device.
byte serialNb[8];
oneWire.target_search(DS2431::ONE_WIRE_FAMILY_CODE);
if (!oneWire.search(serialNb))
{
Serial.println("No DS2431 found on the 1-Wire bus.");
return;
}
// Check serial number CRC
if (oneWire.crc8(serialNb, 7) != serialNb[7])
{
Serial.println("A DS2431 was found but the serial number CRC is invalid.");
return;
}
Serial.print("DS2431 found with serial number : ");
printBuffer(serialNb, 8);
Serial.println("");
// Initialize DS2431 object
eeprom.begin(serialNb);
// Read all memory content
byte data[128];
eeprom.read(0, data, sizeof(data));
Serial.println("Memory contents : ");
printLargeBuffer(data, sizeof(data));
Serial.println("");
// Write a 8-byte row
byte newData[] = {1,2,3,4,5,6,7,8};
word address = 0;
if (eeprom.write(address, newData, sizeof(newData)))
{
Serial.print("Successfully wrote new data @ address ");
Serial.println(address);
}
else
{
Serial.print("Failed to write data @ address ");
Serial.println(address);
}
Serial.println("");
// Read again memory content
eeprom.read(0, data, sizeof(data));
Serial.println("Memory contents : ");
printLargeBuffer(data, sizeof(data));
Serial.println("");
// Read single byte
Serial.print("Data @ address ");
Serial.print(address);
Serial.print(" : ");
Serial.println(eeprom.read(address));
}
void loop()
{
// Nothing to do
}
void printBuffer(const uint8_t *buf, uint8_t len)
{
for (int i = 0; i < len-1; i++)
{
Serial.print(buf[i], HEX);
Serial.print(",");
}
Serial.println(buf[len-1], HEX);
}
void printLargeBuffer(const uint8_t *buf, uint16_t len)
{
uint8_t bytesPerLine = 8;
for (int i = 0; i < len / bytesPerLine; i++)
{
Serial.print(i * bytesPerLine);
Serial.print("\t\t:");
printBuffer(buf + i * bytesPerLine, bytesPerLine);
}
}
I have read that issue : https://github.com/PaulStoffregen/OneWire/pull/33
I have try using the pull request version of the OneWire but I have the same problem.
Do Someone has a similar problem ? And if yes how can I resolve it ?
Thank you for reading me.
Best regards.