Arduino ESP8266 怎么使用EEPROM 掉电不丢失数据
(2016-12-04 11:32:27)
标签:
wifiesp8266eeprom |
分类: IoT |
Arduino ESP8266 怎么使用EEPROM 掉电不丢失数据
EEPROM.begin(512);
value = EEPROM.read(address);
EEPROM.write(addr, val);
// advance to the next address.
there are 512 bytes in
// the EEPROM, so go back to 0 when we hit
512.
// save all changes to the flash.
addr = addr + 1;
if (addr == 512)
{
addr = 0;
EEPROM.commit();
}
经过测试和标准Arduino稍稍有一点区别
读/写 之前 setup要添加一个 EEPROM.begin
写之后要加EEPROM.commit();
否则会遇到各种奇怪的问题
void setup()
{
}
读取
写入
===转====
https://github.com/esp8266/Arduino/blob/master/libraries/EEPROM/examples/eeprom_read/eeprom_read.ino