Giter Club home page Giter Club logo

i2c_eeprom's Introduction

Arduino CI Arduino-lint JSON check GitHub issues

License: MIT GitHub release PlatformIO Registry

I2C_EEPROM

Arduino Library for external I2C EEPROM - 24LC512, 24LC256, 24LC64/32/16/08/04/02/01.

Description

This library is to access external I2C EEPROM up to 64KB (= 512 Kbit) in size. MicroChip 24LC512, 24LC256, 24LC64, 24LC32, 24LC16, 24LC08, 24LC04, 24LC02, 24LC01 and equivalents.

Also confirmed working M24512-W, M24512-R, M24512-DF (See #68). Not supported is the identification page functions.

The I2C_eeprom_cyclic_store interface is documented here

RP2040

There are at least two boards modules for the RP2040 that use a different Wire libraries. One from "Earle F. Philhower" and an "MBED" one. See issues #53 and #55 for details.

In 1.7.3 defines are checked to select between these two and as far as tested this seems to solve the issue #53 while being backwards compatible. If a better solution is found, it will be implemented.

Breaking change

Version 1.8.0 introduced a breaking change. You cannot set the pins in begin() any more. This reduces the dependency of processor dependent Wire implementations. The user has to call Wire.begin() and can optionally set the Wire pins before calling I2C_eeprom.begin().

Links

Schematic

        +---U---+
    A0  | 1   8 |  VCC = 1.7V to 5.5V
    A1  | 2   7 |   WP = write protect pin
    A2  | 3   6 |  SCL = I2C clock
   GND  | 4   5 |  SDA = I2C data
        +-------+

Default address = 0x50 .. 0x57 depending on three address lines (A0, A1, A2).

Interface

#include "I2C_eeprom.h"

The interface is kept quite identical to the I2C_24LC1025 library. https://github.com/RobTillaart/I2C_24LC1025

Most important difference is 32 bit memory addresses.

Constructor

  • I2C_eeprom(uint8_t deviceAddress, TwoWire *wire = &Wire) constructor, optional Wire interface.
  • I2C_eeprom(uint8_t deviceAddress, uint32_t deviceSize, TwoWire *wire = &Wire) constructor, with optional Wire interface.
  • bool begin(uint8_t writeProtectPin = -1) initializes the I2C bus with the default pins. Furthermore it checks if the deviceAddress is available on the I2C bus. Returns true if deviceAddress is found on the bus, false otherwise. Optionally one can set the WP writeProtect pin. (see section below). If the WP pin is defined the default will be to not allow writing.
  • bool isConnected() test to see if deviceAddress is found on the bus.
  • uint8_t getAddress() returns device address set in the constructor.

Write functions

  • int writeByte(uint16_t memoryAddress, uint8_t value) write a single byte to the specified memory address. Returns I2C status, 0 = OK.
  • int writeBlock(uint16_t memoryAddress, uint8_t * buffer, uint16_t length) write a buffer starting at the specified memory address. Returns I2C status, 0 = OK.
  • int setBlock(uint16_t memoryAddress, uint8_t value, uint16_t length) writes the same byte to length places starting at the specified memory address. Returns I2C status, 0 = OK.

Update functions

  • int updateByte(uint16_t memoryAddress, uint8_t value) write a single byte, but only if changed. Returns 0 if value was same or write succeeded.
  • uint16_t updateBlock(uint16_t memoryAddress, uint8_t * buffer, uint16_t length) write a buffer starting at the specified memory address, but only if changed. Returns bytes written.

Read functions

  • uint8_t readByte(uint16_t memoryAddress) read a single byte from a given address.
  • uint16_t readBlock(uint16_t memoryAddress, uint8_t * buffer, uint16_t length) read length bytes into buffer starting at specified memory address. Returns the number of bytes read, which should be length.

Verify functions

Since 1.6.0. - experimental, needs extensive testing.

Same as write and update functions above. Returns true if successful, false indicates an error.

  • bool writeByteVerify(uint16_t memoryAddress, uint8_t value)
  • bool writeBlockVerify(uint16_t memoryAddress, uint8_t * buffer, uint16_t length)
  • bool setBlockVerify(uint16_t memoryAddress, uint8_t value, uint16_t length)
  • bool updateByteVerify(uint16_t memoryAddress, uint8_t value)
  • bool updateBlockVerify(uint16_t memoryAddress, uint8_t * buffer, uint16_t length)
  • bool verifyBlock(uint16_t memoryAddress, uint8_t * buffer, uint16_t length) Returns true is buffer equals memoryAddres for length bytes.

Other

  • uint32_t getDeviceSize() idem
  • uint8_t getPageSize() idem
  • uint8_t getPageSize(uint32_t deviceSize) idem
  • uint32_t getLastWrite() idem
  • uint32_t determineSizeNoWrite() function that determines the size of the EEPROM by detecting when a selected memory address is not readable. (new in 1.8.1).
  • uint32_t determineSize(bool debug = false) function that determines the size of the EEPROM by detecting when a memory address is folded upon memory address 0. It is based upon the observation that memory wraps around. The debug flag prints some output to Serial.

Warning: this function has changed (again) in 1.4.0

Test results determineSize()

Type returns Memory Page Size Notes
- 0 connect error, check device address / wiring
24LC512 65536 64 KB 128
24LC256 32768 32 KB 64
24LC128 16384 16 KB 64
24LC64 8192 8 KB 32
24LC32 4096 4 KB 32 not tested with hardware
24LC16 2048 2 KB 16
24LC08 1024 1 KB 16
24LC04 512 512 b 16
24LC02 256 256 b 8
24LC01 128 128 b 8

The function cannot detect smaller than 128 bit EEPROMS.

Experimental since 1.7.1 can be used for debugging and overruling constructor.

  • uint32_t setDeviceSize(uint32_t deviceSize) overrules constructor setting. returns set size == 128, 256, ... 32768, 65536
  • uint8_t setPageSize(uint8_t pageSize) overrules constructor setting. returns set size == 8, 16, 32, 64, 128.

UpdateBlock()

(new since 1.4.2)

The function updateBlock() reads the block of data and compares it with the new values to see if it needs rewriting.

As the function reads/writes the data in blocks with a maximum length of I2C_TWIBUFFERSIZE (== 30 AVR limitation; 128 for ESP32) It does this comparison in chunks if the length exceeds this number. The result is that an updateBlock() call can result e.g. in 4 reads and only 2 writes under the hood.

If data is changed often between writes, updateBlock() is slower than writeBlock(). So you should verify if your sketch can make use of the advantages of updateBlock()

ExtraWriteCycleTime (experimental)

To improve support older I2C EEPROMs e.g. IS24C16 two functions were added to increase the waiting time before a read and/or write as some older devices have a larger timeout than 5 milliseconds which is the minimum.

  • void setExtraWriteCycleTime(uint8_t ms) idem
  • uint8_t getExtraWriteCycleTime() idem

It is also possible to adjust the I2C_WRITEDELAY in the .h file or overrule the define on the command line.

WriteProtectPin WP (experimental)

(since 1.7.4)

The library can control the WP = WriteProtect pin of the EEPROM. To do this one should connect a GPIO pin of the MCU to the WP pin of the EEPROM. Furthermore the WP should be defined as a parameter in begin(). If the WP pin is defined the default will be to not allow writing. The user has to enable writing either by manual or automatic control.

In the automatic mode the library only allows writing to the EEPROM when it actually writes to the EEPROM. So it keeps the EEPROM in a read only mode as much as possible. This prevents accidental writes due to (noisy) signals on the I2C bus. (#57)

Status

  • bool hasWriteProtectPin() returns true if WP has been set.

Automatic control

  • void setAutoWriteProtect(bool b) if set to true, the library enables writing only when the EEPROM is actually written. This setting overrules the manual control. If setAutoWriteProtect() is set to false (== default) the manual control is leading.
  • bool getAutoWriteProtect() get current setting.

Manual control

  • void allowWrite() allows writing by setting WP to LOW.
  • void preventWrite() disables writing by setting WP to HIGH.

Limitation

The library does not offer multiple EEPROMS as one continuous storage device.

Operation

See examples

Future

Must

  • improve documentation

Should

  • investigate multi-EEPROM storage
    • wrapper class?
  • improve error handling,
    • write functions should return bytes written or so.
  • make deviceSize explicit in examples?

Could

  • investigate smarter strategy for updateBlock() => find first and last changed position could possibly result in less writes.
  • can setBlock() use strategies from updateBlock()
  • pageBlock(): incrBuffer is an implementation name, not a functional name.

Wont

  • investigate the print interface?
    • circular buffer? (see FRAM library)
    • dump function?

Support

If you appreciate my libraries, you can support the development and maintenance. Improve the quality of the libraries by providing issues and Pull Requests, or donate through PayPal or GitHub sponsors.

Thank you,

i2c_eeprom's People

Contributors

emmett81 avatar ivankravets avatar robtillaart avatar roelandkluit avatar thijstriemstra avatar titantompa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

i2c_eeprom's Issues

Support for WP-Pins

Could you please add support for Write-Protect-Pins? I always connect them to a GPIO of my microcontroller which allows for better control of the EEPROM, but sadly as far as I can see, your library does not support this feature.

It would be awesome to see that addition =)

Version [1.8.4] - 2024-04-20 Get Failure

Board ESP32-S3 N8
\Arduino\libraries\Wire\src/Wire.h:125:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)'
uint8_t requestFrom(int address, int size);

// Previous definition using 'int' (not optimal for this application):
// const int EEPROM_ADDRESS = 0x50; // EEPROM address

// Updated definition using 'uint8_t' (optimal for 8-bit addresses):
const uint8_t EEPROM_ADDRESS = 0x50; // EEPROM address

// Create an EEPROM object for a 24LC512 chip using the corrected address type
I2C_eeprom EEPROM_24LC512(EEPROM_ADDRESS, I2C_DEVICESIZE_24LC512);

read errors

only this variable gives �������D

I2C_eeprom ee(0x51, I2C_DEVICESIZE_24LC512);

if (request->argName(i) == "setname")
{
if (strcmp(cihaz_adi, request->arg(i).c_str()) != 0)
{
strcpy(cihaz_adi, request->arg(i).c_str());
pass_len1 = strlen(cihaz_adi);
ee.writeBlock(670, (uint8_t *)&cihaz_adi, sizeof(pass_len1));
ee.writeByte(350, pass_len1);
}
}

should the library control the Write Protect pin?

It would add five (simple) functions to the class

  • void setWriteProtectPin(uint8_t pin) set pinMode(_wpPin, OUTPUT) + defaults enable write ?
  • uint8_t getWriteProtectPin() returns _wpPin
  • uint8_t enableWrite() digitalWrite(_wpPin, LOW);
  • uint8_t disableWrite() digitalWrite(_wpPin, HIGH);
  • uint8_t isEnabledWrite() return (digitalRead(_wpPin) == LOW);

These 5 functions can be kept disjunct from the existing class. so if not used no code increment.
If merged into e.g. writeBlock() - checking isEnabledWrite() - it would always add to the footprint.

integration could also be in begin(), default pin -1?
(constructor would interfere with default Wire parameter)

low prio


As many devices have a WriteProtect or enable pin this could be a minimal class.
Other classes could inherit this WriteProtect class.
As naming + function and polarity etc differ it looks like overkill to "classify" this idea.

Using the library in RP2040

Hi !

I used your library with the RP2040 (Raspberry Pi Pico) . I used the earlephilhower board for my project.

For used your library in my project I make this changes in the I2c_eeprom.h and I2C_eeprom.cpp file

.h

#if defined (ESP8266) || defined(ESP32) ||defined(PICO_RP2040)
  //  set the I2C pins explicitly (overrule)
  bool     begin(uint8_t sda, uint8_t scl);
#endif
#ifdef PICO_RP2040
bool I2C_eeprom::begin(uint8_t sda, uint8_t scl)
{
   //  if (_wire == 0) Serial.println("zero");  //  test #48
  if ((sda < 255) && (scl < 255))
  {
    _wire->setSCL( scl );
    _wire->setSDA( sda);
    _wire->begin();
  }
  _lastWrite = 0;
  return isConnected();
}
#endif 

I want to add this change in the actual branch. Can it ??

Thanks for your work !!

See you later

writeByte / readByte

Hello! I have an issue (or two, I can't tell, really) with this library: readByte function returns only 0x000 on the serial monitor. I don't know if isn't writing, reading or none. I let you the sample code.

Note: Since I didn't know if my code was bad or not, I tride your other library (I2C_24LC1025) and these functions works on that one.

#include <Wire.h>
#include <I2C_eeprom.h>

uint32_t eepromSize;
uint8_t b, c, d;

#define SERIAL_OUT Serial

I2C_eeprom ee(0x50);

void setup(){
  SERIAL_OUT.begin(9600);
  ee.begin();
  if(!ee.isConnected()){
    SERIAL_OUT.println("No memory detected. Freezing.");
    while(1);
  }
  SERIAL_OUT.println("Memory detected!");
  delay(10);
  SERIAL_OUT.print("Memory size in bytes: ");
  eepromSize = ee.determineSize();
  SERIAL_OUT.print(eepromSize);
  SERIAL_OUT.print('\n');
  ee.writeByte(0x0000,0xA1);
  ee.writeByte(0x0001,0xB2);
  ee.writeByte(0x0002,0xC3);
  SERIAL_OUT.print("Your written data is: 0h");
  SERIAL_OUT.print(ee.readByte(0x0000),HEX);
  SERIAL_OUT.print(ee.readByte(0x0001),HEX);
  SERIAL_OUT.print(ee.readByte(0x0002),HEX);
  SERIAL_OUT.print('\n');
}

void loop(){
  
}

String structure bug

Hello Rob,
Thank you for this superb library but I encounter a bug when I try to save a string type structure, I try to save a telephone number in international format for example "+32495030405" the first character is always replaced by a bad one, if i decrease the size like "+324950304" does it work??
Thanks for your help

Pascal

here is the code from an example of the package.

Example 1 return

size: 20
write: 13105
read: 2947
temp: +324950304
hum: 53.10
pres: 1000.90
done...

Example 2 return

size: 20
write: 13105
read: 2947
temp: #32495030405
hum: 53.10
pres: 1000.90
done...

Test_1_I2C_eeprom_struct.zip
Test_2_I2C_eeprom_struct.zip

Suspected crash when calling begin()

Had a strange issue with code suddenly not running giving an USB device error in Windows and uploads no longer possible via USB. I have replicated (mostly) with the code below using the EEPROM library. Windows does not give an USB device error with this code (maybe due to delay() in my test code which delays the point at which the device fails). However uploads still are no longer possible when running this code so I guess the CPU is still crashing.

What should happen is after stat or upload the builtin LED is off for 3 seconds then comes on. What happens is the LED does not come on and USB uploads do not work. Pressing reset twice in quick succession allows new code to be uploaded.

It is begin() that fails and from what I could tell _wire is nullptr in the begin() code for some reason - does not look possile though.

It works (may just hide the issue) when I use the I2C_eeprom ee(0x50, I2C_DEVICESIZE_24LC256, &Wire) line instead. My first thought is undefined behaviour somewhere, but I have eliminated my code so that can't be the cause. I do not have a spare Arduino with me at the moment to test. The Arduino is only connected to a EEPROM chip but the same issue occurs when completely disconnected (i.e. the Arduino is removed from the breadboard).

Board in question is the Nano 33 IoT and the IDE is 2.0.2
The RaspberryPi PICO does the same thing. It flashes a code with its built in LED as well - Cannot find what my specific pattern means but essentially means it has crashed also which probably eliminates my hardware as a cause.

Thanks.

#include "Wire.h"
#include "I2C_eeprom.h"

I2C_eeprom ee(0x50, &Wire); //Does not work
//I2C_eeprom ee(0x50, I2C_DEVICESIZE_24LC256, &Wire); //Works

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);
  delay(3000);
  ee.begin();
  digitalWrite(LED_BUILTIN, HIGH);
}

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

}

Probleme 24C16 et I2C_EEPROM

Bonjour, je n'arrive pas à utiliser votre bibliothèque avec une Eeprom 24C16 ! Pourtant elle fonctionne avec Wire sur Arduino Nano et un delay de 5ms après Wire.endTransmission();
Si vous pouviez m'aider ?
Merci

writeBlock across page boundaries intermittently failing

Hi

I have a 12 byte struct of meter values that I store in a "circular buffer" on the eeprom which for testing is 60 records.
I am observing that intermittently when I write this struct across a page boundary only the values that fit on the first page are written.
Values being written within a page are 100% correct.
I have put a debug Serial.print in _WriteBlock and I can see it getting called twice for the writes over the boundaries as expected.

could this be some kind of chip not ready for the second write issue?

eeprom: 24LC256

struct
{
  unsigned long ts;
  unsigned long meter;
  unsigned long ticks;
} logRecord;

Regards
Ged

Add readme_cyclic_store.md

@Titantompa
Please add a short separate document to describe the usage of the cyclic store

  • short description (added value)
  • interface - which calls, what do they do
  • limitations?
  • other notes

Fix examples

  • fix small eeprom test
  • replace it
  • add performance for small eeprom. (won't)

Questions regarding begin() for ESP and speed tests

Hi Rob, first of all, great work with this library. I'm impressed. I've tried it out with AT24C32 and it seems to work fine. Just two questions.

  1. What is the significance of the test in begin for ESP? There are 42 pins on the ESP32, which would be an upper limit, but what would be the significance of 0xFF?
  2. I can't quite understand the output of the performance test at the end of the example. First, the code still works with a fixed delay() of 2 ms (datasheet claims it should be 10 ms). Below are the figures for I2C_WRITEDELAY of 5000 on ESP8266:
20:04:27.692 -> TEST: timing writeByte()	TIME: 523
20:04:27.692 -> TEST: timing writeBlock(50)	TIME: 9606
20:04:27.726 -> TEST: timing readByte()		TIME: 2090
20:04:27.726 -> TEST: timing readBlock(50)	TIME: 7141
20:04:27.726 -> TOTALS: 19360
20:04:27.726 -> 
20:04:27.726 -> TEST: timing writeByte()	TIME: 526
20:04:27.726 -> TEST: timing writeBlock(50)	TIME: 8205
20:04:27.762 -> TEST: timing readByte()		TIME: 672
20:04:27.762 -> TEST: timing readBlock(50)	TIME: 6956
20:04:27.762 -> TOTALS: 16359

Why would the tests be faster with a 5 ms delay once before the test, in particular readByte()? Even an I2C_WRITEDELAY of 10000 doesn't change much. Could that be caused by endTransmission in waitEEReady running into a timeout, so that it actually takes longer than a fixed delay()?

Add autodetection of size and i2c address

First off, thank you for the library.

What I am trying to do is abstract the EEPROM size and i2c address from the end user by scanning the i2c bus and reading the EEPROM size in code prior to calling the library since both of those values are required to instantiate an object.

More Detail:
There are 4 AT24cXX Chips on the market. Two of them are common:

  • AT24LC32 - on DS3231 and other RTC modules - 32byte pages
  • AT24C256 - on Discreet module - 64 byte pages

They use different page sizes

  • The AT24LC32/64 use 32 byte pages
  • The AT24C128/256 use 64 byte pages

These modules can be located on 1 of 8 addresses -

  • 0x50 to 0x57

In code I can scan for the i2c address but I need the I2c address and Memory size to instantiate your library.

you currently have a getsize() function, but that seems redundant if we need to define or assume size ahead of time (chicken/egg problem).

Is there a way we can "automagically" detect size and location within your library and return those values?

Thanks!

Investigate Write with Verify functionality

Two different approaches possible

extra functions

  int      writeByteVerify(const uint16_t memoryAddress, const uint8_t value);
  int      writeBlockVerify(const uint16_t memoryAddress, const uint8_t* buffer, const uint16_t length);
  int      setBlockVerify(const uint16_t memoryAddress, const uint8_t value, const uint16_t length);
  int      updateByteVerify(const uint16_t memoryAddress, const uint8_t value);
  int      updateBlockVerify(const uint16_t memoryAddress, const uint8_t* buffer, const uint16_t length);

This is clear for the user. The functions can be implemented as wrappers around the existing write / update / read functions.

verify flag functions

 void    enableVerify();
 void    disableVerify();
 bool   verifyEnabled();

The write and update functions would verify depending on the flag.
This would imply a footprint increase even if you never would use verify.

Optimization thoughts

Optimizations could be created on the lowest level e.g. by verifying (partial) blocks on page level.
That could decrease the runtime memory needed, typical a buffer of I2C_BUFFERSIZE only to be allocated if verify == true

Triggered by #39

Help with I2C_eeprom_cyclic_store

I'd like to use the I2C_eeprom_cyclic_store example as a template for a project I need to port:

// default values at startup, if nothing is stored in the eeprom
int DryTemperature = 35;    // Destination Dry Temperature in degree celsius
int DryTime_Hours = 1;
int DryTime_Minutes = 30;
int curDryTime_Hours = 1;
int curDryTime_Minutes = 30;

// port to external eeprom
// I2C_eeprom ee(0x50, I2C_DEVICESIZE_24LC64);

/***
 * Saves the current settings for temperature, drying hours and minutes
 */
void SaveSettings() {
  EEPROM.write(0, (uint8_t) 17);
  EEPROM.write(1, (uint8_t) DryTemperature);
  EEPROM.write(2, (uint8_t) DryTime_Hours);
  EEPROM.write(3, (uint8_t) DryTime_Minutes);
}


/***
 * Reads the last saved settings for temperature, drying hours and minutes
 */
void ReadSettings() {
  uint8_t isInit = EEPROM.read(0);

  if (isInit == 17) {
    DryTemperature = EEPROM.read(1);
    DryTime_Hours = EEPROM.read(2);
    DryTime_Minutes = EEPROM.read(3);
  }
}

but it's hard to figure out how to use that I2C_eeprom_cyclic_store example in a way that matches the old EEPROM library.

These lines for example:

#define MEMORY_SIZE 0x2000 // Total capacity of the EEPROM
#define PAGE_SIZE 64 // Size of write page of device, use datasheet to find!

I have no idea what to use here for my AT24C64D device on 0x50.

It feels a lot of the examples are more unit test type of examples and I'm missing simple hello world kind of stuff.

AT24C128C can i use this one?

can i use this one AT24C128C with your lib?

all seems to go well but if i use your example:
I2C_eeprom_struct.ino

when read value i get:

size: 	12
write: 	1626
read: 	1708
temp:	0.00
hum:	37.01
pres:	0.01

done...

using:

  // make measurement here
  measurement.temperature = 22.5;
  measurement.humidity    = 53.1;
  measurement.pressure    = 1000.9;

Device Address not working

You can define the hardware address of an EEPROM, but then it uses the default 0x50. When using one address byte EEPROMS from ST or others (Example M24C08) that allow other addresses then 0x50 it does not work.

Fix to:
L:298 in I2C_eeprom.cpp
uint8_t addr = _deviceAddress | ((memoryAddress >> 8) & 0x07);

updateByte

Would it be possible to add a function like in the internal Arduino lib for updating a byte? So read a byte and only write if it differs to safe some writing cycles of the eeprom?

Compiler warnings

Using platformio:

[env:pico]
platform = raspberrypi
board = pico
framework = arduino

lib_deps =
  robtillaart/I2C_EEPROM@^1.8.2

seeing some warnings while compiling my project:

.pio\libdeps\pico\I2C_EEPROM\I2C_eeprom.cpp: In member function 'bool I2C_eeprom::writeBlockVerify(uint16_t, const uint8_t*, uint16_t)':
.pio\libdeps\pico\I2C_EEPROM\I2C_eeprom.cpp:206:11: warning: variable length array 'data' is used [-Wvla]
  206 |   uint8_t data[length];
      |           ^~~~
.pio\libdeps\pico\I2C_EEPROM\I2C_eeprom.cpp: In member function 'bool I2C_eeprom::setBlockVerify(uint16_t, uint8_t, uint16_t)':
.pio\libdeps\pico\I2C_EEPROM\I2C_eeprom.cpp:216:11: warning: variable length array 'data' is used [-Wvla]
  216 |   uint8_t data[length];
      |           ^~~~
.pio\libdeps\pico\I2C_EEPROM\I2C_eeprom.cpp: In member function 'bool I2C_eeprom::updateBlockVerify(uint16_t, const uint8_t*, uint16_t)':
.pio\libdeps\pico\I2C_EEPROM\I2C_eeprom.cpp:239:11: warning: variable length array 'data' is used [-Wvla]
  239 |   uint8_t data[length];
      |           ^~~~

update documentation and examples

See I2C_24LC1025 lib -> readme + .h + .cpp

  • add returned data per function
  • check returned types per function as 1025 had a bug in update()
  • examples for the new verify functions.

Possible bug in EEPROM format example

I have only just come across this library so I may have misunderstood.

However in one of the examples; I2C_EEPROM/examples/I2C_eeprom_format/I2C_eeprom_format.ino
it looks like there may be a bug. I assume this is suppose to write a fixed value to every address on the EEPROM. The following loop looks suspicious,

for (uint32_t i = 0; i < size; i += 128)
{
if (i % 1024 == 0) Serial.print('.');
ee.setBlock(0, 0xFF, 128);
}

Assuming I am understanding it correctly this writes the value 0xFF to 128 places always starting at address 0.

I would assume the line should be:

ee.setBlock(i, 0xFF, 128);

Apologies if I have misunderstood something, I have not had a chance to look at this library in detail yet.

No Issue, but remarks/questions about Constructor parameter, and determineSize()

  1. Constructor uses (default) I2C_EEPROM_PAGESIZE as "devicesize", which gives obviously not a right pagesize. Was this intentional?
  2. In determineSize() when i equals 7 we have addr 65536, and 1 is added which overflows addr as a uint16_t and gives 1.
    Both "remarks" do not "influence" my 24c32. So determineSize() gives 4K correctly. But I try to understand the cpp, so could you please react?

Compile error for Arduino rp2040 linked to _wire->setSCL(scl) and _wire->setSDA(sda)

Hi !

After updating to v1.7.2 I am getting the following error when compiling my project for arduino rp20240:

Compiling .pio\build\nanorp2040connect\lib376\I2C_EEPROM\I2C_eeprom.cpp.o
.pio\libdeps\nanorp2040connect\I2C_EEPROM\I2C_eeprom.cpp: In member function 'bool I2C_eeprom::begin(uint8_t, uint8_t)':
.pio\libdeps\nanorp2040connect\I2C_EEPROM\I2C_eeprom.cpp:79:12: error: 'TwoWire' {aka 'class arduino::MbedI2C'} has no member named 'setSCL'
79 | _wire->setSCL(scl);
| ^~~~~~
.pio\libdeps\nanorp2040connect\I2C_EEPROM\I2C_eeprom.cpp:80:12: error: 'TwoWire' {aka 'class arduino::MbedI2C'} has no member named 'setSDA'
80 | _wire->setSDA(sda);

This was not the case with v1.7.1

Thanks !

Issue Fix #21 (Addressing 24LC04/08/16) incomplete

The addressing bug fix in #21 is incomplete.

It corrects the addressing in function _beginTransmission(). When using the 24LC04/08/16, the same address calculation must also be applied in function _ReadBlock(), Line 349 when calling
uint8_t readBytes = _wire->requestFrom(_deviceAddress, length);
With the current implementation, _ReadBlock() always accesses the first 256bytes of the EEPROM.

24LC32A

Best regard. Please I want to ask you for help to be able to upload a matrix of pointers using an arduino uno with an eeprom 24LC32A or larger and then display it on LCD
Thanks in advance for your support.

#include <I2C_eeprom.h>
#include "Arduino.h"
#include <Wire.h>                                     // libreria de comunicacion por I2C
#include <LiquidCrystal_I2C.h>                        // libreria para LCD por I2C

I2C_eeprom ee(0x50, I2C_DEVICESIZE_24LC32);

uint32_t start, diff;

/***********************************************************
   Base de datos de palabras y frases
 ***********************************************************/
const char* palabras[] = {
  "Maquillarse",
  "Playa",
  "Erizo",
  "Macarena",
  "Cirujano",
  "Huracan",
  "Facebook",
  "Estreñimiento",
  "Accidente de coche",
  "Criminal",
  "El presidente",
  "Chivato",
  "Club de lucha",
  "Hipo",
  "Jefe",
  "Detective",
  "Ipad",
  "Hacer galletas",
  "Chiste",
  "Puta",
  "Peluca",
  "Oveja negra",
  "Avion",
  "Macho",
  "Bebe",
  "Rayo de sol",
  "Brindis",
  "Limbo",
  "Cuchara",
  "Sorpresa",
  "Claque",
  "Bañar a un gato",
  "Cambiar pañal",
  "Pasear al perro",
  "Levantar pesas",
  "Jugar a las cartas",
};


/***********************************************************
   Inicializacion y funcion principal
 ***********************************************************/

LiquidCrystal_I2C lcd(0x27, 16, 2);                   //Crear el objeto lcd  direccion  0x27 y 16 columnas X 2 filas

void setup() {
  lcd.init();
  lcd.backlight();
  lcd.clear();
  pinMode(3, INPUT_PULLUP);
  ee.begin();
  if (! ee.isConnected())
  {
    lcd.setCursor(0,0); lcd.print(F("ERROR:No hay acceso con la memeoria..."));
    while (1);
  }

  ee.writeBlock(0, (uint8_t *) &palabras, 50);
  //ee.writeBlock(60, (uint8_t *) &data3, sizeof(data3));
 // dumpEEPROM(0, 128);

}

void loop() {
  
}

24LC1025-I support

Please add 24LC1025-I support if possible.
And thanks for your I2C_EEPROM lib.

512kbit eeprom problem

I am using 512 kbt eeprom but it sees 4 kb how can I fix it

I2C_eeprom ee(0x50, I2C_DEVICESIZE_24LC512);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.