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()
{
...
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 ...
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.
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:
...
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....
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 ...
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 ...
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,...
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 ...
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 ...
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, ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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
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 - ...
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 ...
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 ...
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/
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
eeprom × 194arduino-uno × 51
esp8266 × 24
flash × 18
serial × 16
arduino-ide × 12
c++ × 11
memory × 11
arduino-mega × 10
i2c × 10
atmega328 × 9
programming × 8
esp32 × 8
memory-usage × 8
avr × 7
arduino-nano × 6
attiny × 6
variables × 6
power × 5
spi × 5
string × 5
sram × 5
nodemcu × 4
datalogging × 4
reset × 4