Hot answers tagged

36 votes

How to read and write EEPROM in ESP8266

While EEPROM.read and EEPROM.write are valid methods, it's like mopping the floor with a toothbrush. Use EEPROM.put and EEPROM.get instead. For example: #include <EEPROM.h> void setup() { ...
codechimp's user avatar
  • 461
9 votes
Accepted

Can you access the EEPROM of an ATtiny with Arduino Code?

The Arduino EEPROM library is compatible with the ATTiny range of AVR microcontrollers as the library itself is built on the standard Atmel AVR avr/eeprom.h 'library' so it is compatible with all the ...
RSM's user avatar
  • 1,437
9 votes

EEPROM bytes preset to 255 while programming

In flash and eeprom memory an erased value is 255. It's all about how flash memory works. If you want something other than 255 in there you will have to write something other than 255 in there.
Majenko's user avatar
  • 105k
8 votes
Accepted

Arduino digitalWrite 1 or 0 instead of HIGH or LOW

Yes, that is fine. LOW is 0 and HIGH is 1. digitalWrite() sets the output to off if it receives a 0 and on if it receives anything of 1 or more. That means that these are all equivalent: ...
Majenko's user avatar
  • 105k
8 votes

Run code once after programming

This is a X->Y problem. Here is a solution for X: Bit 3 of high fuse of the ATmega328p controls if EEPROM memory is preserved through the chip erase. You can change the high fuse setting in boards....
Juraj's user avatar
  • 17.6k
7 votes

EEPROM endurance and page size

Testing a single byte write I ran some test code overnight to try to get to the bottom of this. Somewhat surprisingly perhaps, I got up to over 11 million writes before a read-back failed: Current ...
Nick Gammon's user avatar
  • 37.6k
7 votes

How do you write to a free location on an external EEPROM?

You can divide EEPROM space into entries and provide each entry with a single "used" bit. You could use a separate byte to store it, or reuse a bit from a byte which is not completely used ...
Dmitry Grigoryev's user avatar
7 votes

How to increase life of EEPROM?

The other answer mentioned some general ideas; here are a couple of more-specific notes. • You can direct your writes of single bytes through a routine that reads the EEPROM cell before writing to it,...
James Waldby - jwpat7's user avatar
7 votes
Accepted

EEPROM.get returns bad data

You are saving a String object in EEPROM, which is useless. A string object does not store the contents of your string. Instead, it just stores: the memory address where the actual contents (the ...
Edgar Bonet's user avatar
  • 41.4k
7 votes
Accepted

How can I read the data stored in EEPROM although is powered OFF based on the simple code I wrote?

increase is a global variable and will implicitly initialized with the value zero. Then you are reading the EEPROM data into the variable storagedata in setup(). And then in loop() you are increasing ...
chrisl's user avatar
  • 15.6k
6 votes
Accepted

How do you write to a free location on an external EEPROM?

The trick you are looking to implement here is the ability to look through the EEPROM and say "This is the last place I wrote to - I will write to the next place now." There's two ways of doing it, ...
Majenko's user avatar
  • 105k
6 votes
Accepted

How can configuration values be stored on an ESP8266?

Thanks to Jaromanda X and Juraj for the SPIFFS recommendation. I was able to use this block of SPIFFS code as an example and safely store settings in my project outside of the compiled source. To ...
travis's user avatar
  • 201
6 votes

How to save a float variable to the eeprom

Since your floating point value always uses only 1 digit after the comma, why not multiply it by 10 and put it in an integer? For a value up to 15.0 (resulting in 150 int), you can use a simple byte ...
Michel Keijzers's user avatar
6 votes

Which EEPROM has a long lifecycle?

You can cycle through all the addresses in the EEPROM like a ring buffer. You'll need to reserve a bit so you can binary search for the head of the buffer during startup. You can also reduce how ...
ratchet freak's user avatar
6 votes

Spiffs vs Eeprom on esp8266

On the ESP8266 there's very little to choose from between the two. It all really boils down to what you want to store and how you best want to access it. EEPROM emulation is ideal for small bits of ...
Majenko's user avatar
  • 105k
5 votes
Accepted

Most efficient way to store number in EEPROM?

My best off-the-top-of-my-head figure is 6 bytes. 4 bytes for the timestamp (assuming a 32-bit value). Two byte for -32768 to +32767. Multiply the temperature by 100 to make it into the integer ...
Majenko's user avatar
  • 105k
5 votes
Accepted

EEPROM - Storing Static Data

Some things I noticed in your code: You are writing everything to the same address (is that intentional?) You are only writing the first 6 six bytes of your arrays (I am pretty sure that is ...
DarthRubik's user avatar
5 votes
Accepted

What is the best way to get more RAM for a sound buffer?

A simple SPI SRAM chip. Available up to 128KB, such as the 23LC1024: http://www.microchip.com/wwwproducts/en/23LC1024
Majenko's user avatar
  • 105k
5 votes

EEPROM put and get not working on ESP8266 (NodeMCU)

The ESP8266 doesn't have any EEPROM. Instead it emulates it using Flash. In order not to wear out your flash you have to "commit" changes to the flash once they have been queued for writing - ...
Majenko's user avatar
  • 105k
5 votes
Accepted

How to increase life of EEPROM?

I can think of a few: don't power it on unless you have to; don't write to it unless you have to; write as little data to you as you can - compress the data; only write to it during brown out or ...
dannyf's user avatar
  • 2,760
5 votes

EEPROM - Arduino

(1) How many locations are there in EEPROM? (For ARDUINO UNO & MEGA) Read the datasheet for the chip on the board. It tells you how many bytes or kilobytes the chip has for EEPROM. For instance ...
Majenko's user avatar
  • 105k
5 votes

Is it possible to use extra AVR Flash memory as non-volatile EEPROM-like Flash memory storage?

Yes you can. This Arduino IDE add on lets you make calls to code store in the bootload of memory so you can make changes to the flash memory. https://majek.sh/en/writing-to-internal-flash-on-arduino/ ...
CrossRoads's user avatar
  • 2,407
5 votes
Accepted

Is it possible to use extra AVR Flash memory as non-volatile EEPROM-like Flash memory storage?

The answer is "yes, you can use extra AVR Flash memory as non-volatile EEPROM-like Flash memory storage, very similar to an STM32 microcontroller." One of these days I'm going to write an Arduino ...
Gabriel Staples's user avatar
5 votes
Accepted

Write faster on AT24C32

after writing a value to EEPROM, and terminating the I2C connection with a STOP, the EEPROM enters a self writing mode to write what you have sent to it, to it's internal memory. (you don't actually ...
Tirdad Sadri Nejad's user avatar
5 votes

How can I read the data stored in EEPROM although is powered OFF based on the simple code I wrote?

The problem is that you fail to initialize increase during setup(). The variable is undefined when the code enters the loop() function, even regardless of whether this is the first boot or not. You ...
PMF's user avatar
  • 1,218
5 votes
Accepted

What is wrong with the way I write and or read the EEPROM adresses?

You forgot to call Serial.begin() in setup(). As a side note, your if tests are useless. The compiler warns me that: comparison is always true due to limited range of data type For reference: the ...
Edgar Bonet's user avatar
  • 41.4k
4 votes

Is using malloc() and free() a really bad idea on Arduino?

Is it a really bad idea to use malloc() and free() with Arduino? The short answer is yes. Below are the reasons why: It is all about understanding what an MPU is and how to program within the ...
Mikael Patel's user avatar
  • 7,959
4 votes

What is the real lifetime of EEPROM?

The magic solution - if you dont want to code what Cybergibbons said about reading before writing, is the EEPROM.update() function. It does exactly that: EEPROM.update(address, value); will only ...
Jorge's user avatar
  • 41

Only top scored, non community-wiki answers of a minimum length are eligible