{"action":"created","issue":{"url":"https://api.github.com/repos/esp8266/Arduino/issues/1486","labels_url":"https://api.github.com/repos/esp8266/Arduino/issues/1486/labels{/name}","comments_url":"https://api.github.com/repos/esp8266/Arduino/issues/1486/comments","events_url":"https://api.github.com/repos/esp8266/Arduino/issues/1486/events","html_url":"https://github.com/esp8266/Arduino/issues/1486","id":128323115,"number":1486,"title":"EEPROM Lost after Reboot/Power Off NODEMCU V3 ","user":{"login":"codemasterPL","id":16851305,"avatar_url":"https://avatars.githubusercontent.com/u/16851305?v=3","gravatar_id":"","url":"https://api.github.com/users/codemasterPL","html_url":"https://github.com/codemasterPL","followers_url":"https://api.github.com/users/codemasterPL/followers","following_url":"https://api.github.com/users/codemasterPL/following{/other_user}","gists_url":"https://api.github.com/users/codemasterPL/gists{/gist_id}","starred_url":"https://api.github.com/users/codemasterPL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codemasterPL/subscriptions","organizations_url":"https://api.github.com/users/codemasterPL/orgs","repos_url":"https://api.github.com/users/codemasterPL/repos","events_url":"https://api.github.com/users/codemasterPL/events{/privacy}","received_events_url":"https://api.github.com/users/codemasterPL/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-01-23T11:29:15Z","updated_at":"2016-01-23T15:25:55Z","closed_at":null,"body":"Hi Guys,\r\nSo far i had _no_ issues with programming Esp8266, great platform for IoT until i started saving/loading configuration to/from EEPROM.\r\n\r\nThe Setup i am having:\r\nMac OSX 10.11.2 (El Captain)\r\nArduino IDE: 1.6.7\r\nProgrammer: pyesptool (only this one works with Mac)\r\nBoard: LoLin Node MCU V3 (http://www.upgradeindustries.com/media/ebay/Photos/nodemcu_new/nodemcu_front_wm.jpg)\r\nI used Arduino Board Manager to download Board from the address provided here:\r\nhttp://arduino.esp8266.com/stable/package_esp8266com_index.json\r\n\r\nprogrammers.txt\r\npyesptool.name=pyesptool\r\npyesptool.communication=serial\r\npyesptool.protocol=esp\r\npyesptool.program.protocol=esp\r\npyesptool.program.tool=pyesptool\r\npyesptool.program.extra_params=\r\n\r\nplatform.txt\r\ntools.pyesptool.cmd=esptool.py\r\ntools.pyesptool.cmd.windows=esptool.exe\r\ntools.pyesptool.path={runtime.ide.path}/hardware/tools/esp8266/pyesptool\r\ntools.pyesptool.program.params.verbose=\"\"\r\ntools.pyesptool.program.params.quiet=\"\" \r\ntools.pyesptool.program.pattern=python \"{path}/{cmd}\" {program.verbose} --port \"{serial.port}\" write_flash 0x00000 \"{build.path}/{build.project_name}.bin\"\r\n\r\n\r\nProblem:\r\nI can easily save/load data from EEPROM as long as ESP8266 is powered ON.\r\nWhen i poweroff and poweronn - EEPROM comes back with random values\r\n\r\n\r\nCode:\r\n\r\n```c++\r\nvoid CSense::LoadConfig(tConfig& rtConfig)\r\n{ \r\n  //\r\n  rtConfig.m_strWiFiSSID = \"\";\r\n  rtConfig.m_strWiFiPassword = \"\";\r\n  \r\n  \r\n  // Laod SSID First\r\n  for (int i = 0; i < m_iMaxSSIDLength; i++)\r\n  {\r\n      rtConfig.m_strWiFiSSID += char(EEPROM.read(i));\r\n  }\r\n\r\n   // Load PASS \r\n   for (int i = 0; i < m_iMaxPasswordLength; i++)\r\n   {\r\n      rtConfig.m_strWiFiPassword += char(EEPROM.read(m_iMaxSSIDLength+i));\r\n   }  \r\n \r\n}\r\nvoid CSense::SaveConfig(const tConfig& rtConfig)\r\n{  \r\n  // Clear EEPROM\r\n  for(int a = 0; a < m_iMaxSSIDLength + m_iMaxPasswordLength;a++)\r\n  {\r\n    EEPROM.write(a, 0); \r\n  }\r\n\r\n  // Save SSID\r\n  for (int i = 0; i < m_iMaxSSIDLength; i++)\r\n  {\r\n    if(i < rtConfig.m_strWiFiSSID.length())\r\n      EEPROM.write(i, rtConfig.m_strWiFiSSID[i]); \r\n  }\r\n\r\n  // Save Password\r\n  for (int i = 0; i < m_iMaxPasswordLength; i++)\r\n  {\r\n    if(i < rtConfig.m_strWiFiPassword.length())\r\n      EEPROM.write(i + m_iMaxSSIDLength, rtConfig.m_strWiFiPassword[i]);    \r\n  }\r\n  EEPROM.commit();\r\n  yield();\r\n\r\n}\r\n\r\n```\r\n\r\nPlease let me know if there is anything else i need to share, i am new to this world - be patient :)"},"comment":{"url":"https://api.github.com/repos/esp8266/Arduino/issues/comments/174193589","html_url":"https://github.com/esp8266/Arduino/issues/1486#issuecomment-174193589","issue_url":"https://api.github.com/repos/esp8266/Arduino/issues/1486","id":174193589,"user":{"login":"codemasterPL","id":16851305,"avatar_url":"https://avatars.githubusercontent.com/u/16851305?v=3","gravatar_id":"","url":"https://api.github.com/users/codemasterPL","html_url":"https://github.com/codemasterPL","followers_url":"https://api.github.com/users/codemasterPL/followers","following_url":"https://api.github.com/users/codemasterPL/following{/other_user}","gists_url":"https://api.github.com/users/codemasterPL/gists{/gist_id}","starred_url":"https://api.github.com/users/codemasterPL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codemasterPL/subscriptions","organizations_url":"https://api.github.com/users/codemasterPL/orgs","repos_url":"https://api.github.com/users/codemasterPL/repos","events_url":"https://api.github.com/users/codemasterPL/events{/privacy}","received_events_url":"https://api.github.com/users/codemasterPL/received_events","type":"User","site_admin":false},"created_at":"2016-01-23T15:25:55Z","updated_at":"2016-01-23T15:25:55Z","body":"Good point, \r\n\r\nEEPROM.commit(); returns false;"}}