Logging Data to *large* EEPROM with Arduino

Hi, I am working on a telemetry package for a rocket to be shot to the boundary of space this spring break with the University of Washington. I am trying to log the sensor data in a stable and simple manner. I have been looking into I2C EEPROM as the solution, but it seems like there isn't anything with small enough pages to be worthwhile. From what I know, you must write an EEPROM page all at once.

Does anybody know either: 1) How to write to an EEPROM such as the 256K 24LC256 with the limited memory of the Arduino? 2) Of any I2C or other simple serial interfaced EEPROM with a small enough page size so that it could be utilized by an Arduino?

Thanks a ton!

From what I know, you must write an EEPROM page all at once.

No you have to erase them all at once you can write them one byte (sometimes 4) at a time.

How big a device do you need?

Is there no chance you could use something different like an SD Card for storing telemetry? That would give you just another bonus of having the stuff 'at hand' if you want to use it.

If it’s stored on board, it isn’t telemetry. :slight_smile:

The Microchip sensors you mention (24LC256) have byte-writable modes as well as page write. Unfortunately the predefined buffers in the Arduino I2C library aren’t big enough to support its page-write operations. FYI, the 24LC1025 is 4 times as large (but must be addressed in such a way that it looks like 2 different devices on the I2C bus). You can use several of these chips; I recently flew 2 on a balloon experiment, and the addressing is such that you can easily connect 8 of the 512kbit-or-less variety or 4 of the 1024kbit devices to the same bus.

My concern for I2C devices is that the speed is slow - you may miss data.

I’m currently looking at the Atmel AT45DB161D “dataflash” chip. It has an SPI interface, which is a few orders of magnitude faster than I2C. It also has two onboard RAM buffers, so that you can fill one buffer, issue a write command, and start filling the other buffer while waiting on the write to complete. There is code for this family of devices on the playground.

An SD card has an SPI mode, so you can use it as a big SPI flash device. I’m not sure about write speeds, etc, but the size and availability are right. If you do write directly to an SD card, there is no FAT filesystem, so you can’t just pop it into a computer and double click on a file. You can read raw data off (e.g. using dd on a unix box).


An SD card has an SPI mode, so you can use it as a big SPI flash device. I'm not sure about write speeds, etc, but the size and availability are right.

For what it's worth, the SD card I use with my camera is good for 20 megabytes/second. When they give a speed like "60x", the base number they're multiplying by is 150kB/s, the speed of the original single-speed cdrom drives, so 60x = 9MB/s.

Thanks for the fast reply!

@kg4wsv: Yeah, we're transmitting radio too, the memory is for redundancy and a higher sample rate. How slow are you talking? If I were transmitting at 2000 baud and wanted to store more than that would I2C not be the way to go?

@Grumpy_Mike: I didn't realize this, so does this mean that an Arudino could write to something like the 24LC256 or 24LC1025 and utilize all the storage? Using the code on http://www.arduino.cc/playground/Code/I2CEEPROM , would I just use the i2c_eeprom_write_byte function with an incremented address? Would this erase the other written data on the page?

I have been looking at the DataFLASH type chips also, (AT45DB161D) and I thought that looked like a great chip, but since I'm using a prototyping board, surface mount is mostly not an option if a through hole alternative is possible, which looking through DigiKey didn't yield any results for any of that type of chip. :(

Yeah, SMT+protoboards are a problem. You can get adapter boards that are DIP format boards with SMT footprints, like this one from SparkFun. That Atmel dataflash chip is wide; that’s it pictured as an example on the adapter board, and it hangs over the pads a bit (but it works).

Also note that LadyAda has a prototyping shield that has an SMT pad that looks like it would fit the dataflash IC.

That Atmel device requires 3.3V supply, but the pins are 5V tolerant, so it’s a good fit for an Arduino with a 3.3V supply.

A big problem a lot of us face in prototyping/one-off/hobby type applications is that lots of the interesting devices are SMT only. Places like Sparkfun have tools to help - things like the adapter boards and breakout boards with SMT devices pre-mounted.

As for the I2C rate to the 24LC256, I am pretty sure it will beat 2k bps. I needed samples every 15 or 20 seconds (3 hour balloon flight to 95k’) so I don’t have a precise data rate, but a limiting factor is a 3ms + delay required after writing each byte. This can be mitigated a bit by alternating devices with the writes (e.g. write byte 1 to IC 1, byte 2 to IC 2, etc). Also, IIRC the Arduino library runs I2C at 100kHz. Both the ATmega and the 24LCxxx are capable of 400kHz operation, so there’s a bit of room for improvement there.


Oh yeah, the folks at Wulfden (I believe that's forum member BBR) have provided working Arduino code for the 24LCxxx family. You can get it here.


Sounds good. I am thinking I am going to use the AT25DF321 with the "SOIC to DIP Adapter 8-Pin" from SparkFun. This has a small enough page size that fast writing can be accomplished directly. It has more space than most EEPROM's too.

Off hand, does anybody know of any libraries written for Arduino that work w/ SPI like Wire does, or do you just have to get nitty gritty and do the hardware instructions for that? I suspect that I'm just going to have to do the byte level work for that, but it seems to be a well documented standard so that's OK.

There is no SPI library for Arduino, but the hardware part of SPI seems much simpler to me than I2C.

There is code on the playground for one of the dataflash devices - this should be a good starting point.


I agree SD card would be more usefull for larger storage capacity.

How to write to an EEPROM such as the 256K 24LC256

thats 256kbit, before anyone gets excited, 32kbyte x8, just thought i'd mention it